使用seurat包,导出特定cluster的细胞-基因counts矩阵。初始数据命名为pbmc
用的代码为:
library(Seurat)
# 读取数据 pbmc <- Read10X(data.dir = "pbmc")
# 初始化Seurat对象 pbmc <- CreateSeuratObject(counts = pbmc)
# 进行预处理 pbmc <- NormalizeData(pbmc) pbmc <- FindVariableFeatures(pbmc) pbmc <- ScaleData(pbmc)
# 进行聚类
pbmc <- FindClusters(pbmc, resolution = 0.5)
# 导出特定cluster的细胞-基因counts矩阵
cluster_id <- 1
# 指定cluster的ID
cluster_cells <- WhichCells(pbmc, ident = cluster_id)
cluster_matrix <- GetAssayData(pbmc, slot = "counts")[cluster_cells,]
最后一步报错:
Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) :
invalid character indexing
该如何解决?
你好世界