读取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

相关推荐
奔跑的蜗牛FelixChioa1 天前
python学习之通过pandas处理excel和csv数据
python·pandas
AI_56781 天前
Pandas高效清洗:5个函数让脏数据处理快80%
人工智能·pandas
闲人编程2 天前
Python在数据工程中的角色:Airflow和Pandas实践
开发语言·python·pandas·airflow·数据工程·codecapsule
Fleshy数模2 天前
数据“整容”术:Pandas+Matplotlib让你的数据会说话
pandas·matplotlib
小玲男友2 天前
三大库-pandas
python·pandas
星辰徐哥2 天前
人工智能从入门到精通:NumPy 与 Pandas 数据分析基础
人工智能·ai·数据分析·numpy·pandas
玄同7652 天前
NumPy 与 Pandas 中「有无返回值函数」的易错点整理
人工智能·python·机器学习·数据挖掘·数据分析·numpy·pandas
普通网友2 天前
掌握 requests、BeautifulSoup 等库的网络爬虫基础,或使用 pandas 进行简单数据分析
爬虫·beautifulsoup·pandas
语文天才高斯2 天前
Dify Sandbox 如何安装第三方库(matplotlib / numpy / pandas 通用方法)
人工智能·chatgpt·numpy·pandas·matplotlib
kong79069282 天前
Python核心语法-Numpy
人工智能·numpy·pandas·python核心语法