[英]Plotting both within and between groups differences
I am using ggpubr
currently to plot my values.我目前正在使用
ggpubr
来绘制我的值。 Thanks to the facets I managed to create subplots according to some factor.多亏了这些方面,我设法根据某些因素创建了子图。 Finally, using the function
stat_compare_means()
I managed to plot only the differences between groups .最后,使用函数
stat_compare_means()
我设法只绘制了组之间的差异。
The minimal code to produce my figures is生成我的数字的最小代码是
library(ggpubr)
data("ToothGrowth")
my_comparisons <- list( c("0.5", "1"), c("1", "2"), c("0.5", "2") )
p <- ggboxplot(ToothGrowth, x = "dose", y = "len",
color = "supp", palette = "npg",
add = "jitter",
facet.by = "supp", short.panel.labs = FALSE)
p + stat_compare_means(comparisons = my_comparisons, label = "p.signif")
where supp
is the grouping factor, len
the outcome and dose
the independent variable.其中
supp
是分组因子, len
为结果并为自变量提供dose
。
This is the result:这是结果:
I would like to display also differences within groups (eg statistical significance between 0.5|OJ and 0.5|VC), but I think it is not possible with my current code.我还想显示组内的差异(例如 0.5|OJ 和 0.5|VC 之间的统计显着性),但我认为用我当前的代码是不可能的。
Could someone please point me towards some example on how to achieve what I want?有人可以指出我如何实现我想要的一些例子吗?
EDIT 2编辑 2
@Tjebo For clarity purposes I attach here a plot similar to the one I am looking for, where not only the differences between groups (eg between red and blue bars), but also within groups (eg between two red bars). @Tjebo 为了清晰起见,我在此附上一个类似于我正在寻找的图,其中不仅有组之间的差异(例如红色和蓝色条之间),还有组内的差异(例如两个红色条之间)。
I would like (coming back to the minimal reproducible example) to plot as well the p-value between OJ
and VC
at a dosis
of 0.5, for instance.例如,我想(回到最小可重复示例)以 0.5 的
dosis
绘制OJ
和VC
之间的 p 值。
Statistically, I find this approach fairly questionnable.从统计上讲,我发现这种方法相当值得怀疑。 You are retrospectively creating some subgroups and not adjusting for any confounders that are likely to be present.
您正在回顾性地创建一些子组,并且没有针对可能存在的任何混杂因素进行调整。
But here we go.但我们走了。 Just change the x variable and of course the list, which
stat_compare_means
needs in order to know which groups to compare.只需更改 x 变量,当然还有
stat_compare_means
需要的列表,以便知道要比较哪些组。
library(ggpubr)
data("ToothGrowth")
my_comparisons <- list( c("OJ", "VC") )
p <- ggboxplot(ToothGrowth, x = "supp", y = "len",
add = "jitter",
facet.by = "dose", short.panel.labs = FALSE)
p + stat_compare_means(comparisons = my_comparisons, label = "p.signif")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.