读取h5ad文件

python 复制代码
import scanpy as sc

annData = sc.read_h5ad("D:/xzj-2023/c0.h5ad")

var_df=pd.DataFrame(annData.var)

var_df.to_csv('D:/c0_var.csv', index=False, sep='\t')

obs_df=pd.DataFrame(annData.obs)

obs_df.to_csv('D:/c0_obs.csv', index=False, sep='\t')

X_df=pd.DataFrame(annData.X)

X_df.to_csv('D:/c0_X.csv', index=False, sep='\t')

#读取细胞类型
print(adata.obs['cell_type'])
#Name: cell_type, Length: 11851, dtype: category
# Categories (7, object): ['fibroblast', 'T cell', 'endothelial cell', 'hepatocyte', 'macrophage',
   #                      'monocyte', 'malignant cell']

图片来源https://www.jianshu.com/p/18006139bbed

相关推荐
databook6 小时前
经常听到的透视表是干什么的?
python·数据分析·pandas
benchmark_cc2 天前
A 股、港股、美股如何建立统一的标的主数据格式?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
benchmark_cc2 天前
用 00700.HK 做港股行情清洗:字段核对、校验与个人量化开发实践
python·数据分析·pandas·量化交易·股票数据·quantdash
第九序言T2 天前
数据分析岗 Pandas 面试题 20 道(上):概念与读代码
python·数据分析·pandas·数据处理
2601_966949652 天前
如何封装 qd.klines.batch(),让批量 K 线查询函数在多个策略中复用?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
Blockbuater_drug2 天前
《经典机器学习实战》第 2 课:回归入门——环境、工具与数据准备
线性回归·pandas·scikit-learn·数据可视化·数据清洗·最小二乘法·conda环境
烂蜻蜓3 天前
Pandas入门教程(十六):常用函数速查手册——读写、清洗、选择、排序、分组与统计
pandas
quantdash_cc3 天前
个人开发者用 QuantDash 读取港股行情:00700.HK 的 Python 函数封装与校验实践
python·数据分析·pandas·量化交易·股票数据·quantdash
databook4 天前
Pandas 与 Polars:语法、性能和资源占用方面的对比
python·数据分析·pandas
桑年4 天前
四、Pandas数据处理
人工智能·python·线性代数·pandas·数据可视化·数据处理