Open barrel0luck opened 4 years ago
Hi,
Thank you for the positive feedback, appreciated!
1/ Adding significance symbols: the function rstatix::add_significance() might help, like this:
t_test_results <- data_to_plot %>%
group_by(x_label) %>%
t_test(response~treatment) %>%
add_significance() %>%
add_y_position(fun = "mean", step.increase = 0.02)
(Feature request #70 opened for automatic significance symbols)
(Note also that, you're plotting group mean in the ggplot, so consider using fun="mean" instead of fun = "max" in the add_y_position())
2/ For the log scale:
The plot you obtained is what is expected in log scale for this data. The transformation log10(t_test_results$y.position)
returns 9.002153, 9.021177, 9.176075, 9.778149, 10.707570
in log scale. The first 3 points are flat (around y = 9).
One possibility is to manually adapt the y.position to create the desired output in log scale; for example:
t_test_results$y.position[1:3] <- c(10^7, 10^8, 10^9)
ggplot(data_to_plot, aes(x = x_label, y = response)) +
stat_summary(aes(color = treatment, linetype = treatment), fun = "mean", geom = "line") +
stat_summary(aes(color = treatment), fun.data = "mean_sd", geom = "errorbar", width = 0.2) +
geom_text(data = t_test_results,
mapping = aes(x = x_label, y = y.position, label = p.signif),
size = 5, show.legend = F) +
scale_y_log10()
rstatix::add_significance()
Thanks for this and also for opening #7
Note also that, you're plotting group mean in the ggplot, so consider using fun="mean" instead of fun = "max" in the add_y_position())
Ah, thanks for pointing this out. I think I just copy that everywhere without changing it and that's where it came from.
One possibility is to manually adapt the y.position to create the desired output in log scale; for example:
Yes, I'm doing that currently. I've only given a simple example here where this problem is very easy to fix manually. But with a larger dataset and with multiple comparisons, adjusting the position of stars on the log scale becomes really complex and so I was wondering if there was a more automated fix for this...
OK, let's this issue open
Thanks and sorry for increasing your work! You must already be really busy with maintaining this package and with your own science.
Hi! I absolutely love your package and use it regularly in my work. I've bothered you before with feedback and the great thing is you've responded and made improvements in your package, so thanks a lot for that! Here are some more things I noticed: (1) When performing a test with a single comparison, having a p.singif column with representation of significance (that matches the p.adj.signif representation) would be greatly appreciated. Especially since the rules for what should be , **, *** etc is difficult to script quickly such that it matches the rules you use when multiple comparisons are present. So for consistency, it'd be great if it's available in the single comparison as well. (2) y.position doesn't seem to be calculated correctly when the plot is made on the log10 scale. I'm not sure exactly exactly what the problem is, as without the log scale the y.position seems to be correctly calculated. It's really strange. It's probably something really simple that I don't understand.
Here's the code for reproducing the problems:
Here's the plot with log10 y scale:
Here's the plot without log10 y scale: