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

相关推荐
jarreyer15 小时前
python,numpy,pandas和matplotlib版本对应关系
python·numpy·pandas
写代码的【黑咖啡】21 小时前
Python中的Pandas:数据分析的利器
python·数据分析·pandas
laocooon5238578863 天前
对传入的 x , y 两个数组做折线图, x 对应 x 轴, y 对应 y 轴。并保存到 Task1/image1/T2.png
python·numpy·pandas·matplotlib
Maxwell_li14 天前
新冠检测例子学习查准率和召回率
学习·机器学习·数据分析·回归·numpy·pandas
渡我白衣4 天前
Python 与数据科学工具链入门:NumPy、Pandas、Matplotlib 快速上手
人工智能·python·机器学习·自然语言处理·numpy·pandas·matplotlib
IT北辰5 天前
用 Python 自动解析药品规格并计算包装总容量 —— pandas + 正则实战
开发语言·python·pandas
lbb 小魔仙5 天前
Python 读取 Excel 文件:openpyxl 与 pandas 实战对比
python·excel·pandas
Amber_375 天前
数据分析之(MySQL+普通程序) VS (Python的NumPy/Pandas)
python·mysql·数据分析·numpy·pandas
Lucky高6 天前
Pandas库实践3_索引
开发语言·python·pandas
墨上烟雨6 天前
Pandas读写CSV、Excel、JSON文件
pandas