Skip to content
New issue

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

change the position of pvalue in the figure? #144

Open
marwa38 opened this issue Feb 21, 2022 · 1 comment
Open

change the position of pvalue in the figure? #144

marwa38 opened this issue Feb 21, 2022 · 1 comment

Comments

@marwa38
Copy link

marwa38 commented Feb 21, 2022

hello .. I am running wilcox_test() on my data but I don't know what is the option that I can use for grouping as in the case of group.by in compare_means()

my codes

my_comparisons <- list(c("marine", "vegetable"))

stat.test <- ps.prev0.gen1.rel.melt %>%
  wilcox_test(Abundance ~ treatment, comparisons = my_comparisons) %>%
  add_significance("p")

# .y.       group1 group2       n1    n2 statistic     p p.signif
# * <chr>     <chr>  <chr>     <int> <int>     <dbl> <dbl> <chr>   
#   1 Abundance marine vegetable   180   170     15397 0.919 ns 

while I want to the results output to be like the following
where I used the grouping (group.by) in compare_means()

compare_means(Abundance ~ treatment,
              group.by = "Genus",
              ps.prev0.gen1.rel.melt,
              p.adjust.method = "BH") 

# # A tibble: 10 × 9
# Genus           .y.       group1 group2         p p.adj p.format p.signif method  
# <fct>           <chr>     <chr>  <chr>      <dbl> <dbl> <chr>    <chr>    <chr>   
#   1 Pseudomonas     Abundance marine vegetable 0.351   0.81 0.351    ns       Wilcoxon
# 2 Lactobacillus   Abundance marine vegetable 0.568   0.81 0.568    ns       Wilcoxon
# 3 Sphingopyxis    Abundance marine vegetable 0.176   0.81 0.176    ns       Wilcoxon
# 4 Photobacterium  Abundance marine vegetable 0.703   0.81 0.703    ns       Wilcoxon
# 5 Yersinia        Abundance marine vegetable 0.680   0.81 0.680    ns       Wilcoxon
# 6 Pediococcus     Abundance marine vegetable 0.438   0.81 0.438    ns       Wilcoxon
# 7 Leuconostoc     Abundance marine vegetable 0.400   0.81 0.400    ns       Wilcoxon
# 8 Bifidobacterium Abundance marine vegetable 0.729   0.81 0.729    ns       Wilcoxon
# 9 Lactococcus     Abundance marine vegetable 0.908   0.91 0.908    ns       Wilcoxon
# 10 Staphylococcus  Abundance marine vegetable 0.0532  0.53 0.053    ns       Wilcoxon

many thanks

@marwa38 marwa38 closed this as completed Feb 21, 2022
@marwa38
Copy link
Author

marwa38 commented Feb 21, 2022

I found the way to do it
but I couldn't change the position of the pvalue on the figure (as I can't see it well in Pseudomonas for example)
your advice please? is very much appreciated

my_comparisons <- list(c("marine", "vegetable"))

stat.test <- ps.prev0.gen1.rel.melt %>%
  group_by(Genus) %>%
  wilcox_test(data =., Abundance ~ treatment) %>%
  adjust_pvalue(method = "BH") %>%
  add_significance("p.adj")

# Add p-values to a boxplot
stat.test <- stat.test %>% add_xy_position(x = "treatment")
ggboxplot(ps.prev0.gen1.rel.melt, x = "treatment", y = "Abundance", color = "Phylum", facet.by = "Genus") +
  stat_pvalue_manual(stat.test, label = "p = {p}{p.adj.signif}")

image

thanks in advance for your help

@marwa38 marwa38 reopened this Feb 21, 2022
@marwa38 marwa38 changed the title adding a layer of group in wilcox_test()? change the position of pvalue in the figure? Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant