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

相关推荐
万粉变现经纪人14 小时前
如何解决 pip install 安装报错 [WinError 32] 文件被占用(杀毒/占用进程)问题
python·pycharm·flask·beautifulsoup·bug·pandas·pip
文人sec21 小时前
使用python-pandas-openpyxl编写运营查询小工具
开发语言·python·pandas
咋吃都不胖lyh1 天前
比较两个excel文件的指定列是否一致
爬虫·python·pandas
IT小哥哥呀3 天前
Python实用技巧:批量处理Excel数据并生成销售报表(含实战案例)
python·pandas·数据可视化·数据处理·报表生成·excel自动化·办公神器
Serendipity_Carl4 天前
爬虫数据清洗可视化链家房源
python·pandas·matplotlib
husterlichf4 天前
pandas___get_dummies详解
pandas
wudl55664 天前
Pandas-数据清洗与缺失值处理
pandas
东方佑4 天前
Pandas积木MCP工具 - 完整项目代码
pandas
景彡先生4 天前
Python pandas数据透视表(pivot_table)详解:从入门到实战,多维数据分析利器
python·数据分析·pandas
wudl55666 天前
Pandas--数据读取与写入
pandas