http://www.bioconductor.org/packages/release/bioc/vignettes/SingleR/inst/doc/SingleR.html
https://zhuanlan.zhihu.com/p/497286137
https://www.jianshu.com/p/1c4abf05cb3e?ivk_sa=1024320u
1. 可直接使用的数据格式
SingleCellExperiment
SummarizedExperiment
2. 获得 SingleCellExperiment
数据格式
需要的R包:
Seurat
load("/home/zhiyong/Desktop/Feature_over_2000/Human_REP1_RPL35_KD_25uM_3_200_filtered_feature_over_2000.RData")
object_used <- Human_REP1_RPL35_KD_25uM_3_200_filtered_feature_over_2000
class(object_used)
pp <- as.SingleCellExperiment(object_used)
class(pp)
3. 获得 SummarizedExperiment
数据格式
需要的R包:
SummarizedExperiment
4. 使用
require(Seurat)
require(scuttle)
require(SingleR)
'#-------------------------------------------------------------------------#
# Data for train
load("/home/zhiyong/Desktop/BBBBBBBB-Brain-ZYP/Reference/2017_Yi-Zhang_CR/Data/object_used.RData")
Train_data <- as.SingleCellExperiment(object_used)
Train_data@colData[["Label"]] <- as.character(Train_data$ident)
Train_data <- logNormCounts(Train_data)
#-------------------------------------------------------------------------#
# Data for test
load("/home/zhiyong/Desktop/BBBBBBBB-Brain-ZYP/Figure_1/C/Feature_number_cutoff/J20_1---used/HVF_2000_dim_6/Mouse_brain_J20_1__raw_3_200__Feature_over_500__HVF_2000_dim_6.RData")
Test_data <- as.SingleCellExperiment(Mouse_brain_J20_1__raw_3_200__Feature_over_500__HVF_2000_dim_6)
Test_data <- logNormCounts(Test_data)
#-------------------------------------------------------------------------#
# Annotation
Annotation_result <- SingleR(test=Test_data, ref=Train_data, labels=Train_data$Label, de.method="wilcox")
head(Annotation_result)
Mouse_brain_J20_1__raw_3_200__Feature_over_500__HVF_2000_dim_6@meta.data[["Celltype_from_SingleR"]] <- Annotation_result$pruned.labels
Note: 如果设置
clusters=
,则会在 cluster 层面进行细胞类型的注释;否则是在 细胞 层面