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

相关推荐
F_D_Z3 天前
DataFrame中.iloc 属性
pandas·dataframe·.iloc
husterlichf4 天前
pandas__unstack方法与set_index详解
数据挖掘·数据分析·pandas
wudl55667 天前
Pandas-之数据可视化
信息可视化·数据分析·pandas
万粉变现经纪人8 天前
如何解决 pip install 安装报错 [WinError 32] 文件被占用(杀毒/占用进程)问题
python·pycharm·flask·beautifulsoup·bug·pandas·pip
文人sec8 天前
使用python-pandas-openpyxl编写运营查询小工具
开发语言·python·pandas
咋吃都不胖lyh8 天前
比较两个excel文件的指定列是否一致
爬虫·python·pandas
IT小哥哥呀10 天前
Python实用技巧:批量处理Excel数据并生成销售报表(含实战案例)
python·pandas·数据可视化·数据处理·报表生成·excel自动化·办公神器
Serendipity_Carl11 天前
爬虫数据清洗可视化链家房源
python·pandas·matplotlib
husterlichf11 天前
pandas___get_dummies详解
pandas