纪念第一次使用python-scanpy画出一张图

是第一次使用python
第一次使用远程服务器的jupyter
第一次使用scanpy
十分有意义。
最重要的是安装好jupyter,python并远程连接服务器 这个过程我用了3天
为啥是3天呢,因为我既有windows的python,又有windows上的linux的python还有远程服务器的python
这个混乱 的结构折腾了我3天,终于厘清,你开始用一个就好。
此外更重要的要有个服务器,这个过程我争取了一年。
次重要的是自己学一点python和linux基础,这个过程我用了1年
当然我是断断续续,你努力的话,今天画的这个图你1天就能学会~
python是我准备学的第二门数据分析的编程语言,第一个是R,
也是一年前开始学,目前已经能够熟练用R处理单细胞数据。
万事开头难,从0-1最不容易,剩下的从1-100就是水到渠成~加油
入门就要从具体项目使用开始~

import pandas as pd
import scanpy as sc
In [ ]:

import numpy as np
In [13]:

sc.settings.verbosity = 3             # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.logging.print_header()
sc.settings.set_figure_params(dpi=80, facecolor='white')
scanpy==1.7.2 anndata==0.7.6 umap==0.5.1 numpy==1.20.3 scipy==1.6.3 pandas==1.2.4 scikit-learn==0.24.2 statsmodels==0.12.2
In [14]:

results_file = 'write/pbmc3k.h5ad'  # the file that will store the analysis results

In [15]:

adata = sc.read_10x_mtx(
    'data/filtered_gene_bc_matrices/hg19/',  # the directory with the `.mtx` file
    var_names='gene_symbols',                # use gene symbols for the variable names (variables-axis index)
    cache=True)                              # write a cache file for faster subsequent reading
... reading from cache file cache/data-filtered_gene_bc_matrices-hg19-matrix.h5ad
In [16]:

cd ~

/root
In [17]:

adata = sc.read_10x_mtx(
    'data/filtered_gene_bc_matrices/hg19/',  # the directory with the `.mtx` file
    var_names='gene_symbols',                # use gene symbols for the variable names (variables-axis index)
    cache=True)                              # write a cache file for faster subsequent reading
... reading from cache file cache/data-filtered_gene_bc_matrices-hg19-matrix.h5ad
In [18]:

adata.var_names_make_unique()  # this is unnecessary if using `var_names='gene_ids'` in `sc.read_10x_mtx`

In [19]:

adata

Out[19]:
AnnData object with n_obs × n_vars = 2700 × 32738
    var: 'gene_ids'
In [20]:

sc.pl.highest_expr_genes(adata, n_top=20, )

normalizing counts per cell
    finished (0:00:00)

In [ ]:
image.png

image.png

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容