1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| f_QC_plot <- function(sce){ options(repr.plot.width = 12, repr.plot.height = 6) print(Seurat::VlnPlot(sce, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)) plot1 <- Seurat::FeatureScatter(sce, feature1 = "nCount_RNA", feature2 = "percent.mt") plot2 <- Seurat::FeatureScatter(sce, feature1 = "nCount_RNA", feature2 = "nFeature_RNA") plot1 + plot2 } f_read10x <- function(sce, project='sce'){ sce <- Seurat::CreateSeuratObject(sce, project = project, min.cells = 3, min.features = 200) sce[["percent.mt"]] <- Seurat::PercentageFeatureSet(sce, pattern = "^MT-") sce[["percent.rp"]] <- Seurat::PercentageFeatureSet(sce, pattern = "^RP[SL]") sce <- subset(sce, nFeature_RNA >= quantile(nFeature_RNA, 0.025) & nFeature_RNA <= quantile(nFeature_RNA, 0.975) & nCount_RNA >= quantile(nCount_RNA, 0.025) & nCount_RNA <= quantile(nCount_RNA, 0.975) & percent.mt <= quantile(percent.mt, 0.975)) sce <- Seurat::NormalizeData(sce) g2m_genes <- Seurat::CaseMatch(search=Seurat::cc.genes$g2m.genes, match=rownames(sce)) s_genes <- Seurat::CaseMatch(search=Seurat::cc.genes$s.genes, match=rownames(sce)) sce <- Seurat::CellCycleScoring(sce, g2m.features=g2m_genes, s.features=s_genes) sce$CC.Difference <- sce$S.Score - sce$G2M.Score sce <- sce[!grepl(pattern = "(^MT-^RP[SL])",x = rownames(sce)),] sce <- Seurat::SCTransform(sce, vst.flavor = "v2", vars.to.regress = c("CC.Difference", "percent.mt", "percent.rp"), verbose = F) sce }
|