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/PRStNRokP3oCgGStbiNRLw
The text was updated successfully, but these errors were encountered:
首先来个Seurat的套路代码:
library(Seurat)dir = "data/filtered_gene_bc_matrices/hg19"pbmc.data <- Read10X(data.dir = dir)pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells=3, min.features=200)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)## Assigning cell type identity to clusterscluster.ids <- c("Naive CD4 T", "CD14+ Mono", "Memory CD4 T", "B", "CD8 T", "FCGR3A+ Mono", "NK", "DC", "Platelet")names(cluster.ids) <- levels(pbmc)pbmc <- RenameIdents(pbmc, cluster.ids)
再来画个降维图:
library(ggplot2)library(ggsc)p <- sc_dim(pbmc) + sc_dim_geom_label()p
如果你想可视化不同类别的细胞数目,是不是还稍微有点麻烦,统计一下,画个柱状图,这个一点都不麻烦,麻烦的是你要和你的降维图保持颜色对应。所以有一些解决方案,是写个函数,同时把两个图都出了,画在一起。但这样子绑死呢,就会降低灵活性。我的一向思路是保持最简单,然后可组合。那么在ggsc我们是怎么做的?那就是你画你的降维图,然后拿降维图来做为输入,画柱状图,让柱状图和降维图保持一致。
ggsc
一条指令出图:
sc_dim_count(p)
假设我换个配色方案,柱状图跟着变:
p <- p + scale_color_viridis_d()p2 <- sc_dim_count(p)aplot::plot_list(p, p2, widths=c(1, .5))
另外如果你是用Seurat画的图,也是可以支持的。
p3 <- DimPlot(pbmc, reduction = "umap", label = TRUE, pt.size = 0.5) p4 <- sc_dim_count(p3)aplot::plot_list(p3, p4, widths=c(1, .5))
KISS(Keep It Simple and Stupid)原则是我们所追求的。
Sorry, something went wrong.
No branches or pull requests
https://mp.weixin.qq.com/s/PRStNRokP3oCgGStbiNRLw
The text was updated successfully, but these errors were encountered: