Reference
install.packages("devtools")
library(devtools)
install_github("LTLA/SingleR")
install.packages("remotes")
remotes::install_github("LTLA/celldex")
library(SingleR)
library(celldex)
ref <- HumanPrimaryCellAtlasData()
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')
load("../ref/MonacoImmuneData.Rdata")
ls()
head(ref$label.main)
data_for_SingleR <- GetAssayData(SeuratObj, layer="scale.data")
clusters <- SeuratObj@meta.data$seurat_cluster
predicted_id <- SingleR(test = data_for_SingleR,
ref = ref,
labels = ref$label.main,
clusters = clusters)
predicted_id
write.csv(predicted_id,"output/predicted_id_MonacoImmuneData.csv",quote = F,row.names = F)
cellType=data.frame(ClusterID=levels(SeuratObj@meta.data$seurat_clusters),
SingleR_MonacoImmune=predicted_id$labels)
# ADD Predicted id to my SeuratObjecct
SeuratObj@meta.data$SingleR_MonacoImmune <- cellType[match(clusters,cellType$ClusterID),'SingleR_MonacoImmune']
DimPlot(SeuratObj,reduction = "umap.harmony",group.by = "singleR",label=T)
ggsave(file="output/cell_anno/SingleR_MonacoImmune_umap.pdf")