sceasy转h5ad到rds之后基因名字消失的解决方案
最近在做各种各样的物种的单细胞数据清洗,在清洗到某个数据的时候,用sceasy转格式从h5ad到rds,发现了一个问题,基因名字消失了。
没有再去看sceasy的源码,从源码去解决问题,只能是把原先的基因名字进行迁移。
# 首先是是原先的基因的名字导出
adata.var.to_csv('Mop_10X_nuclei_v3_Broad_forRDS.csv')
接着是rds的基因名字的赋予
# 读取没有header的表格
df <- read.table('/data/work/stTransfer/data/sc_cell/Mop_10X_nuclei_v3_Broad_forRDS.csv', header = FALSE)
r = readRDS('/data/work/stTransfer/data/sc_cell/Mop_10X_nuclei_v3_Broad_forRDS.rds')
counts= r@assays$RNA@counts
meta = r@meta.data
counts <- as.matrix(counts)
counts = data.frame(counts)
rownames(counts) = gene_names
data_m = CreateSeuratObject(counts = counts, metadata = meta)
saveRDS(data_m, file = "your_file_name.rds")
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment