06单细胞分析2025-scanpy分析流程-01项目文件分析-读取数据标准化获取高变基因

建立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怎么下载图片-优快云博客

记录 简要的学习 成长 体会 心得 总结 思路 心流 链接 资料  懂得都懂

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值