gpt4 book ai didi

r - 当某些组有多个人而其他组只有一个人时,有什么更好的方法来可视化数据?

转载 作者:行者123 更新时间:2023-12-01 00:15:57 25 4
gpt4 key购买 nike

我正在尝试绘制属于五个亚属(组)的物种的不同基因的突变率。对于某些群体,有多个物种,但对于其他群体,该群体中只有一个物种。在 R 中使用 ggplot2 的 Boxplot 工作正常,但很难区分不同的组,尤其是只有一个物种的组。

关于在这种情况下哪种类型的图表会更好的任何建议?

这是箱线图的结果:
png of boxplot using ggplot2

我用来获取箱线图的代码是:

ggplot(data = df) + geom_boxplot(mapping = aes(x=dS, y = Genes, color = Subgenus))

这是我的数据的样子(仅适用于第一个基因):
df <- tibble(Subgenus =c("Adenia", "Astrophea", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Decaloba", "Deidamiodies", "Deidamiodies", "Deidamiodies", "Deidamiodies", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Passiflora", "Tetrapathea"), Species = c("A.mannii", "P.pittieri", "P.affinis", "P.auriculata_FG", "P.auriculata_S", "P.biflora", "P.filipes", "P.jatusachensis", "P.lutea", "P.microstipula", "P.misera", "P.rufa", "P.suberosa", "P.tenuiloba", "P.arbelaezii", "P.cirrhifolia", "P.contracta", "P.obovata", "P.actinia", "P.cincinnata", "P.edulis", "P.foetida", "P.laurifolia", "P.ligularis", "P.menispermifolia", "P.nitida", "P.oerstedii", "P.quadrangularis", "P.retipetala", "P.serratifolia", "P.serratodigitata", "P.vitifolia", "P.tetrandra"), Genes = c("atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA", "atpA"), dS = c("0.2929", "0.2596", "0.3069", "0.3178", "0.3138", "0.3014", "0.3009", "0.3293", "0.292", "0.2894", "0.32", "0.3154", "0.334", "0.339", "0.28", "0.2946", "0.2841", "0.2947", "0.2959", "0.3153", "0.2939", "0.3095", "0.2988", "0.2964", "0.3177", "0.2928", "0.3145", "0.2933", "0.314", "0.3037", "0.2995", "0.2981", "0.2807"))

最佳答案

如果重点是比较突变率(我假设是 dS ),请考虑使用它来定义排序顺序,而不是按字母顺序对基因进行排序。

思考和试验您想要突出视觉上的哪些比较可能也很有用:它是跨物种、跨亚属还是跨基因的 dS 差异?我建议那些用位置或长度编码,并在视觉上排列成相邻的和在一个共同的尺度上。

ggplot(df, aes(x = dS, 
y = Species %>% fct_reorder(dS),
color = Subgenus)) +
geom_point() +
facet_wrap(~Genes) +
scale_colour_brewer(palette = "Dark2") +
labs(y="") + theme_bw()

enter image description here

关于r - 当某些组有多个人而其他组只有一个人时,有什么更好的方法来可视化数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52656697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com