- library(celldex)
- ref <- HumanPrimaryCellAtlasData()
- save(ref,file = 'HumanPrimaryCellAtlasData.Rdata')
- ref <- BlueprintEncodeData()
- save(ref,file = 'BlueprintEncodeData.Rdata')
- ref <- MouseRNAseqData()
- save(ref,file = 'MouseRNAseqData.Rdata')
- ref <- ImmGenData()
- save(ref,file = 'ImmGenData.Rdata')
- ref <- DatabaseImmuneCellExpressionData()
- save(ref,file = 'DatabaseImmuneCellExpressionData.Rdata')
- ref <- NovershternHematopoieticData()
- save(ref,file = 'NovershternHematopoieticData.Rdata')
- ref <- MonacoImmuneData()
- save(ref,file = 'MonacoImmuneData.Rdata')
复制代码 可以通过常用函数探索 SummarizedExperiment 类。
- class(ref)
- dim(ref)
- str(ref)
- assayNames(ref)
- assays(ref)
- rowData(ref)
- colData(ref)
- rownames(ref@assays@data@listData$logcounts)colData(x, ...)
复制代码
4.2 SingleR 使用
- #读入Seurat数据
- pbmc <- readRDS("pbmc3k_final.rds")
- #获得表达矩阵
- query <- pbmc@assays$RNA@data
- class(query)
- #SingleR注释
- pred.pbmc <- SingleR(test=query, assay.type.test=1, ref=ref,clusters = [email protected],labels=ref$label.main)
- head(pred.pbmc)
- # ref$label.fine
- #查看注释结果
- View(as.data.frame(pred.pbmc))
- pred.pbmc$pruned.labels
- #统计
- table(pred.pbmc$pruned.labels)
- #注释结果验证
- library(pheatmap)
- plotScoreHeatmap(pred.pbmc)
- plotDeltaDistribution(pred.pbmc, ncol = 3)
- new.cluster.ids <- pred.pbmc$labels
- names(new.cluster.ids)
- names(new.cluster.ids) <- levels(pbmc)
- pbmc <- RenameIdents(pbmc,new.cluster.ids)
- levels(pbmc)
- #重新绘图
- DimPlot(pbmc, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
- DimPlot(pbmc, reduction = "tsne", label = TRUE, pt.size = 0.5) + NoLegend()
复制代码
singleR 注释完成之后细胞进行重命名
|