【发布时间】:2021-11-03 12:24:05
【问题描述】:
我想制作一个 DotPlot,它添加了一个额外的特征,用于将特征基因链接到它们所来自的集群。
我可以使用 dittoDotPlot 轻松生成标准 DotPlot:
p1 <- dittoDotPlot(Liver, top10_filter$gene, group.by = "DefClustering") + coord_flip() + theme(axis.text.x.bottom = element_text(colour = my_palette_Rui_colors))
我发现了一个网站 (https://davemcg.github.io/post/lets-plot-scrna-dotplots/#lets-glue-them-together-with-cowplot),他们尝试在其中添加标签,在这种情况下将簇与 CellType 相关联(我想将基因与 CellType 相关联)
labels <- ggplot(gene_cluster %>%
mutate(`Cell Type` = Group,
cluster = factor(cluster, levels = v_clust$labels[v_clust$order])),
aes(x = cluster, y = 1, fill = `Cell Type`)) +
geom_tile() +
scale_fill_brewer(palette = 'Set1') +
theme_nothing() +
xlim2(dotplot)
现在我制作了这张表,可以轻松地将每个基因与我感兴趣的集群相关联。
head(top10_filter)
# A tibble: 6 × 7
# Groups: gene [6]
p_val avg_log2FC pct.1 pct.2 p_val_adj cluster gene
<dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
1 0 3.19 0.957 0.004 0 Arteries GJA5
2 0 1.83 0.783 0.005 0 Arteries LMO7
3 1.42e-303 2.73 0.652 0.003 4.59e-299 Arteries COL8A1
4 1.72e-282 2.67 0.783 0.006 5.56e-278 Arteries SDC1
5 1.63e-262 3.11 0.522 0.002 5.26e-258 Arteries NPR3
6 1.76e-228 2.68 0.826 0.01 5.69e-224 Arteries NRG1
那么我如何使用 ggplot 来获得我想要获得的情节?现在我可以在右侧生成条形图,但颜色与每个集群无关,它们是按比例分配的。
labels <- ggplot( top10_filter %>%
mutate(cluster,
),
aes(x = 1, y = cluster, fill = top10_filter$cluster), color = my_palette_Rui_colors) +
geom_tile() +
theme_nothing() +
xlim2(p1)
p1 + labels
我不完全了解示例中集群和细胞类型之间的相关性是如何完成的,也许在我的基因和集群之间不能以同样的方式完成。无论哪种方式,我都不知道如何前进。提前致谢!
【问题讨论】:
-
检查cookbook-r.com/Graphs,尤其是第11章“颜色”。