Reppo for internal functions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.6 KiB

  1. \name{ggstats_add_xy}
  2. \alias{ggstats_add_xy}
  3. \title{ggstats_add_xy}
  4. \usage{
  5. ggstats_add_xy(table_stat, table, group, y="max", bracket.offset=0.05, bracket.inspace=0.05)
  6. }
  7. \arguments{
  8. \item{table_stat}{A table generated by a rstatix funcion such as t_test() or wilcox_test().}
  9. \item{table}{The original table that was introduced to ggplot.}
  10. \item{group}{The grouping variable.}
  11. \item{y}{The algorithm used to calculate the y height. Is useful to adapt to plots that show all events, bars with the mean, etc... Options are "max" (default), "mean", "mean+sd", "mean+sem".}
  12. \item{bracket.offset}{Increasing this parameter incresases the y position of the brackets.}
  13. \item{bracket.inspace}{Incresaing this parameter increases the space between brackets.}
  14. }
  15. \description{
  16. Generates a table with the coordinates that is required by the ggpubr function "stat_pvalue_manual".
  17. }
  18. \examples{
  19. library(tidyverse)
  20. library(ggpubr)
  21. library(rstatix)
  22. df<-data.frame("pats"=paste0("PAT", 1:20), "Group"=rep(c("A","B"),each=10),"CytA"=rnorm(20,5), "CytB"=rnorm(20,5),"CytC"=c(rnorm(5,10),rnorm(5,10),rnorm(5,5),rnorm(5,5)),"CytD"=rnorm(20,5),"CytE"=c(rnorm(5,10),rnorm(5,5),rnorm(5,10),rnorm(5,5)),"CytF"=rnorm(20,5),"CytG"=c(rnorm(5,5),rnorm(5,5),rnorm(5,7),rnorm(5,7)))
  23. mdf<-gather(df, "Cytokine","Value",-c(pats,Group))
  24. g<-ggplot(mdf, aes(Cytokine, Value, color=Group))+
  25. geom_boxplot()+
  26. geom_point(position=position_dodge(width = 0.75))
  27. stat.test<-mdf \%>\% group_by(Cytokine) \%>\% t_test(Value~Group)
  28. g+stat_pvalue_manual(ggstats_add_xy(stat.test, mdf, "Group"), label = "p", tip.length = 0.02, hide.ns = T)