建立xxxscanpy文件夹
从cellranger上游分析得到outs文件夹中的filtered_feature_bc_matrix中拷贝三个文件
barcodes.tsv.gz
features.tsv.gz
matrix.mtx.gz
到xxxscanpy/xxx分组scanpy文件夹中 oaneiD201scanpy/
根据示例文件的分析流程 建立 write文件夹
conda info -e
conda activate scanpy312
cd 到 项目文件夹 xxxscanpy/xxx分组scanpy文件夹中 oaneiD201scanpy
jupyter notebook
建立oaneiD201scanpy.ipynb文件
import pandas as pd
import scanpy as sc
sc.settings.verbosity = 3 # verbosity
sc.logging.print_header()
sc.settings.set_figure_params(dpi=300, facecolor="white")
results_file = "write/oaneiD201scanpy.h5ad"
adata = sc.read_10x_mtx(
"./", # 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
)
sc.pl.highest_expr_genes(adata, n_top=20)
sc.pp.filter_cells(adata, min_genes=200)
sc.pp.filter_genes(adata, min_cells=3)
# annotate the group of mitochondrial genes as "mt"
adata.var["mt"] = adata.var_names.str.startswith("MT-")
sc.pp.calculate_qc_metrics(
adata, qc_vars=["mt"], percent_top=None, log1p=False, inplace=True
)
sc.pl.violin(
adata,
["n_genes_by_counts", "total_counts", "pct_counts_mt"],
jitter=0.4,
multi_panel=True,
)
sc.pl.scatter(adata, x="total_counts", y="pct_counts_mt")
sc.pl.scatter(adata, x="total_counts", y="n_genes_by_counts")
adata = adata[adata.obs.n_genes_by_counts < 2500, :]
adata = adata[adata.obs.pct_counts_mt < 5, :].copy()
sc.pp.log1p(adata)
sc.pl.highly_variable_genes(adata)
adata.raw = adata.copy()
按照示例文件分析流程步骤 01 02 代码和图 跑通
jupyter notebook右键图片没有保存图片处理方法(ctrl+shift + 右键 ubuntu 22.04 有效)
感谢作者 保存其中一张高变基因的图作为封面 参考自:
2024年jupyter notebook如何复制单元格cell输出的图片_jupyter怎么下载图片-优快云博客
记录 简要的学习 成长 体会 心得 总结 思路 心流 链接 资料 懂得都懂