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

相关推荐
程序大视界17 小时前
【Python系列课程】Pandas(四):数据统计与排序——describe、sort_values、sample
开发语言·python·pandas
知识分享小能手1 天前
数据预处理入门学习教程,从入门到精通,数据获取 — 知识点详解与案例代码(4)
python·学习·pandas
乔江seven2 天前
【python 数据分析】 Numpy、pandas、matplotlib
数据分析·numpy·pandas
石工记4 天前
CTO如何落地AI?从0到1的实战路径
人工智能·python·django·flask·numpy·pandas·pyqt
weixin_468466854 天前
Data-Engineering-Zoomcamp 新手实战指南
python·自动化·pandas·编程·数据处理
威尔逊·柏斯科·希伯理7 天前
机器学习第一天(共12天)
人工智能·python·机器学习·conda·numpy·pandas·matplotlib
星越华夏7 天前
Polars中导入excel文件
python·pandas
我材不敲代码9 天前
零基础快速上手 Pandas 数据处理
pandas
星越华夏9 天前
pandas中时间处理
pandas
Cloud_Shy61810 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 下篇)
python·plotly·数据分析·excel·numpy·pandas