单细胞转录组——SingleR自动注释

# The objective of this R script: Run SingleR 
# Author: Yuan.Sh
# Date: 2021-10-07 17:07:34
# Blog: https://blog.csdn.net/qq_40966210/category_11165022.html
# Best Regards,  
# Yuan.Sh (Major in Bioinfomatics & Deep-learning)
# ---------------------------------------
# School of Basic Medical Sciences,  
# Fujian Medical University,  
# Fuzhou, Fujian, China.  
# please contact with me via the following ways:  
# (a) e-mail :yuansh3354@163.com 
# (b) QQ : 1044532817
################################################################### 

# options
rm(list=ls())
dir()
options(stringsAsFactors = F)
options(as.is = T)
gc()

# packages
library(stringr)
library(magrittr)
library(SingleR)
library(Seurat)
# load data
load('/media/yuansh/14THHD/胰腺癌/pdac.RData')
sce = sce.big
rm(sce.big)
gc()

# SingleR
sce_for_SingleR <- GetAssayData(sce, slot="data")
sce_for_SingleR
# PD1(in T cell) PDCD1 // PDL1(in tumor) CD274
grep('CD274',rownames(sce),value = T)
library(SingleR)
hpca.se <- celldex::HumanPrimaryCellAtlasData()
hpca.se
clusters=sce@meta.data$seurat_clusters
pred.hesc <- SingleR(test = sce_for_SingleR, 
                     ref = hpca.se,
                     labels = hpca.se$label.main,
                     #method = "cluster",
                     clusters = clusters, 
                     assay.type.test = "logcounts",
                     assay.type.ref = "logcounts")
table(pred.hesc$labels)


save(list=ls(),file = '/media/yuansh/TOSHIBA EXT/singleR.rdata')





版权声明:本文为qq_40966210原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。