{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "*Compiled on: July, 23 2017.*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# My example" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "My example." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running Scanpy version 0.1+139.g2c509d7.dirty on 2017-07-23 11:49.\n" ] } ], "source": [ "%config InlineBackend.figure_formats = ['png2x'] # for vector graphics quality, set to svg\n", "import numpy as np\n", "import scanpy.api as sc\n", "\n", "sc.settings.verbosity = 3 # show some output\n", "sc.settings.set_dpi(80) # low pixel number yields small inline figures\n", "sc.logging.print_version_and_date()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get help." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# help(sc.read)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read and annotate data." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# read data from any path on your system \n", "path_to_data = './data/myexample/'\n", "adata = sc.read(path_to_data + 'myexample.csv')\n", "\n", "# other data reading examples\n", "# adata = sc.read(path_to_data + 'myexample.csv')\n", "# adata = sc.read(path_to_data + 'myexample.h5', sheet='countmatrix')\n", "# adata = sc.read(path_to_data + 'myexample.xlsx', sheet='countmatrix')\n", "# adata = sc.read(path_to_data + 'myexample.txt')\n", "\n", "# in the data matrix adata.X, rows should correspond to samples and columns to genes \n", "# to match this convention, transpose your data if necessary \n", "# adata = adata.transpose()\n", "\n", "# set group names (as strings)\n", "adata.smp['my_groups'] = np.genfromtxt(path_to_data + 'mygroups.csv', dtype=str)\n", "# set root cell\n", "adata.add['iroot'] = 336" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For single-cell RNA-seq, consider running a preprocessing recipe." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "sc.pp.recipe_zheng17(adata)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Run and plot a tool." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "sc.tl.dpt(adata)\n", "sc.pl.dpt(adata)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [conda env:py35]", "language": "python", "name": "conda-env-py35-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 2 }