Seurat標(biāo)準(zhǔn)流程
# 讀取數(shù)據(jù)
pbmc <- CreateSeuratObject(counts = data)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
LabelPoints(plot = VariableFeaturePlot(pbmc), points = head(VariableFeatures(pbmc), 10), repel = TRUE)
pbmc <- ScaleData(pbmc)
pbmc <- RunPCA(pbmc)
ElbowPlot(pbmc)
pbmc <- RunUMAP(pbmc, dims = 1:20)
DimPlot(pbmc, reduction = "umap")
# 聚類
pbmc <- FindNeighbors(pbmc, dims = 1:20)
pbmc <- FindClusters(pbmc, resolution = 0.5)
# 尋找差異基因
cluster1.markers <- FindMarkers(pbmc, ident.1 = 0, logfc.threshold = 0.25, test.use = "roc", only.pos = TRUE)
pbmc.markers <- FindAllMarkers(pbmc, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
pbmc.markers %>% group_by(cluster) %>% top_n(n = 2, wt = avg_logFC)
top10 <- pbmc.markers %>% group_by(cluster) %>% top_n(n = 10, wt = avg_logFC)
# 可視化marker基因
VlnPlot(pbmc, features = c("MS4A1", "CD79A"))
FeaturePlot(pbmc, features = c("MS4A1", "CD79A"))
一行版
pbmc <- CreateSeuratObject(data) %>% NormalizeData(verbose = FALSE) %>%
FindVariableFeatures(verbose = FALSE) %>% ScaleData(verbose = FALSE) %>%
RunPCA(npcs = 20,verbose = FALSE) %>% RunUMAP(dims = 1:20,verbose = FALSE) %>%
FindNeighbors(dims = 1:20,verbose = FALSE) %>%
FindClusters(verbose = FALSE)
DimPlot(pbmc,group.by = 'true',label = T)
SCTransform
pbmc <- CreateSeuratObject(data) %>% PercentageFeatureSet(pattern = "^MT-", col.name = "percent.mt") %>%
SCTransform(vars.to.regress = "percent.mt") %>% RunPCA() %>% FindNeighbors(dims = 1:30) %>%
RunUMAP(dims = 1:30) %>% FindClusters()