1 2 3 4 5 6 7 8 9 10 11 12 13 14
| sce_for_SingleR <- GetAssayData(sce, slot="data") clusters <- sce[['h_resolution_1.5']][[1]] pred_MID <- SingleR(test = sce_for_SingleR, ref = ref_MID, labels = ref_MID$label.main, method = "cluster", clusters = clusters, assay.type.test = "logcounts", assay.type.ref = "logcounts") pred_NHD <- SingleR(test = sce_for_SingleR, ref = ref_NHD, labels = ref_NHD$label.main, method = "cluster", clusters = clusters, assay.type.test = "logcounts", assay.type.ref = "logcounts") cellType=data.frame(ClusterID=levels(sce@meta.data$seurat_clusters), pred_MID=pred_MID$labels, pred_NHD=pred_NHD$labels ) head(cellType) sce@meta.data$pred_MID <- cellType[match(clusters,cellType$ClusterID), 'pred_MID'] sce@meta.data$pred_NHD <- cellType[match(clusters,cellType$ClusterID), 'pred_NHD']
|