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

相关推荐
小白学大数据4 天前
Python爬虫实现无限滚动页面的自动点击与内容抓取
开发语言·爬虫·python·pandas
LilySesy6 天前
【SAP-MOM项目】二、接口对接(中)
开发语言·python·pandas·restful·sap·abap
qq_3814549911 天前
Python Pandas完全指南:从核心数据结构到实战操作
pandas
TUTO_TUTO12 天前
【python-词汇指标提取工具开发】自学笔记(1)-后端程序
人工智能·python·pandas·visual studio code
葱明撅腚12 天前
shapely空间数据分析
python·pandas·gis·shapely
忘忧记13 天前
pandas基础三
pandas
叫我:松哥15 天前
基于scrapy的网易云音乐数据采集与分析设计实现
python·信息可视化·数据分析·beautifulsoup·numpy·pandas
测试摆渡媛15 天前
Excel模板填充工具(工具&脚本分享)
python·数据挖掘·pandas
_Soy_Milk15 天前
【算法工程师】—— Python 数据分析
python·数据分析·numpy·pandas·matplotlib
Data-Miner16 天前
类似Pandas AI的几个数据分析处理智能体介绍
人工智能·数据分析·pandas