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

相关推荐
威尔逊·柏斯科·希伯理2 小时前
机器学习第一天(共12天)
人工智能·python·机器学习·conda·numpy·pandas·matplotlib
星越华夏3 小时前
Polars中导入excel文件
python·pandas
我材不敲代码2 天前
零基础快速上手 Pandas 数据处理
pandas
星越华夏2 天前
pandas中时间处理
pandas
Cloud_Shy6183 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 下篇)
python·plotly·数据分析·excel·numpy·pandas
云和数据.ChenGuang4 天前
基于鲲鹏 HPC 的 AI 对话机器人架构设计与技术实现
人工智能·数据分析·机器人·pandas·数据预处理·数据训练
Cloud_Shy6184 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 中篇)
python·数据分析·excel·pandas
沉下去,苦磨练!4 天前
python的数据分析Pandas
python·数据分析·pandas
毋语天5 天前
Pandas 数据处理进阶:缺失值、合并、分组聚合与透视表
python·数据分析·pandas·数据清洗·透视表
hef2885 天前
探索Pandas groupby的各种技巧和应用实例
pandas