We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://mp.weixin.qq.com/s/_W1OT8fEcD8k3pLgCB0Oqw
The text was updated successfully, but these errors were encountered:
一如即往,来一段无脑的Seurat操作:
library(Seurat)pbmc_counts <- Read10X( data.dir = file.path(input_dir, "filtered_gene_bc_matrices/hg19/"))pbmc <- CreateSeuratObject(counts = pbmc_counts, project = "pbmc3k", min.cells = 3)pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000)pbmc <- ScaleData(pbmc)pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))pbmc <- RunUMAP(pbmc, dims = 1:10)pbmc <- FindNeighbors(pbmc, dims = 1:10)pbmc <- FindClusters(pbmc, resolution = 0.5)seurat_cluster_id <- c("Naive CD4 T", "CD14+ Mono", "Memory CD4 T", "B", "CD8 T", "FCGR3A+ Mono", "NK", "DC", "Platelet")names(seurat_cluster_id) <- levels(pbmc)pbmc <- RenameIdents(pbmc, seurat_cluster_id)
pbmc.markers <- FindAllMarkers(pbmc, only.pos = TRUE)pbmc.markers %>% group_by(cluster) %>% dplyr::filter(avg_log2FC > 1) %>% slice_head(n = 20) %>% ungroup() -> top20
拿出前20来当Markers。
library(clusterProfiler)bitr(top20$gene, 'SYMBOL', 'ENTREZID', 'org.Hs.eg.db') -> ggtop20 <- merge(top20, gg, by.x='gene', by.y = 'SYMBOL')head(top20)kk <- compareCluster(ENTREZID~cluster, data = top20, fun=enrichKEGG)
先来一段我们富集分析的经典点图:
library(enrichplot)g <- dotplot(kk) + aes(x=sub("\n.*", "", Cluster)) + xlab("Cell Clusters")
【和降维图保持一致的细胞类群统计图】,再用这篇文章介绍的方法先来画图:
librrary(ggsc)p = sc_dim(pbmc) + sc_dim_geom_label()p2 = sc_dim_count(p) + coord_cartesian() + ggfun::theme_noxaxis() + xlab(NULL)
见证奇怪的时刻到了:
library(aplot)insert_top(g, p2, height=.2)
有了aplot这个神奇的包,本来两个对不齐的图,现在完美地对齐了。于是能够同时展示细胞类型的数目,和刻画通路的富集分析结果。这也对应到了上次说到的KISS原则,简单简洁优雅。
aplot
Sorry, something went wrong.
No branches or pull requests
https://mp.weixin.qq.com/s/_W1OT8fEcD8k3pLgCB0Oqw
The text was updated successfully, but these errors were encountered: