代码library(SingleR)
counts<-pbmc@assays$RNA@counts
clusters<-pbmc@meta.data$seurat_clusters
ann=pbmc@meta.data$orig.ident
singler = CreateSinglerObject(counts, annot = ann, "pbmc", min.genes = 0,
species = "Human", citation = "",
ref.list = list(), normalize.gene.length = F, variable.genes = "de",
fine.tune = F, do.signatures = T, clusters = clusters, do.main.types = T,
reduce.file.size = T, numCores = 1)
singler$seurat = pbmc
singler$meta.data$xy = pbmc@reductions$tsne@cell.embeddings
clusterAnn=singler$singler[[2]]$SingleR.clusters.main$labels
write.table(clusterAnn,file="07.clusterAnn.txt",quote=F,sep="\t",col.names=F)
write.table(singler$other,file="07.cellAnn.txt",quote=F,sep="\t",col.names=F)
报错
library(SingleR) > counts<-pbmc@assays$RNA@counts 错误: 没有名称为"counts"的插槽对于此对象类 "Assay5" > clusters<-pbmc@meta.data$seurat_clusters > ann=pbmc@meta.data$orig.ident > singler = CreateSinglerObject(counts, annot = ann, "pbmc", min.genes = 0, + species = "Human", citation = "", + ref.list = list(), normalize.gene.length = F, variable.genes = "de", + fine.tune = F, do.signatures = T, clusters = clusters, do.main.types = T, + reduce.file.size = T, numCores = 1) 错误于CreateSinglerObject(counts, annot = ann, "pbmc", min.genes = 0, : 没有"CreateSinglerObject"这个函数 > singler$seurat = pbmc 错误: 找不到对象'singler' > singler$meta.data$xy = pbmc@reductions$tsne@cell.embeddings 错误: 找不到对象'singler' > clusterAnn=singler$singler[[2]]$SingleR.clusters.main$labels 错误: 找不到对象'singler'