美文网首页
SingleR [用参考数据集注释scRNA-seq clust

SingleR [用参考数据集注释scRNA-seq clust

作者: 重拾生活信心 | 来源:发表于2023-12-19 17:47 被阅读0次

    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")
    
    
    
    predicted_id

    相关文章

      网友评论

          本文标题:SingleR [用参考数据集注释scRNA-seq clust

          本文链接:https://www.haomeiwen.com/subject/rowzgdtx.html