客户想把每个样本的质控前后基因、UMI和线粒体占比的图组合到一块儿,接下来的代码将会帮助我们完成这个任务!
load('./sce_merge.Rdata')
sce_list <- SplitObject(sce_merge,split.by = 'orig.ident')
length(sce_list)
sce <- sce_list
# F1 <- paste0('P',1:15)
# F2 <- paste0('P1-',1:15)
for (i in (1:length(samples))){
sce_list[[i]] <- PercentageFeatureSet(sce_list[[i]],pattern = '^mt-',col.name = 'percent.mt')
P0 <- VlnPlot(sce_list[[i]], features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3, group.by = "orig.ident", pt.size = 0)&theme(axis.title.x = element_blank(),axis.text.x = element_text(angle = 0,vjust = 1,hjust = 0.5))
pic <- paste0(c("P"),i)
assign(pic,P0)
}
for (i in (1:length(sce_list))){
sce_list[[i]] <- subset(sce_list[[i]],subset = nFeature_RNA > 200 & nFeature_RNA < 7000 & percent.mt < 10)
F0 <- VlnPlot(sce_list[[i]], features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3, group.by = "orig.ident", pt.size = 0)&theme(axis.title.x = element_blank(),axis.text.x = element_text(angle = 0,vjust = 1,hjust = 0.5))
pic <- paste0(c("F"),i)
assign(pic,F0)
}
(P1|F1)/(P2|F2)/(P3|F3)/(P4|F4)/(P5|F5)/(P6|F6)/(P7|F7)/(P8|F8)/(P9|F9)/(P10|F10)/(P11|F11)/(P12|F12)/(P13|F13)/(P14|F14)/(P15|F15)
ggsave('vlnplot.pdf',width = 18,height = 49)