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.

36 lines
1.9 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, xcol=NULL, y="max", bracket.offset=0.05, bracket.inspace=0.05, exclude_group=NULL)
  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{group}{The X-axis variable. If null (the default), the function will pick the first column. This is intended when exclude_group is null.}
  12. \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".}
  13. \item{bracket.offset}{Increasing this parameter incresases the y position of the brackets.}
  14. \item{bracket.inspace}{Increasing this parameter increases the space between brackets.}
  15. \item{exclude_group}{Variable(s) that will not be grouped. This aims to preserve the variable in order to facet.}
  16. }
  17. \description{
  18. Generates a table with the coordinates that is required by the ggpubr function "stat_pvalue_manual".
  19. }
  20. \examples{
  21. library(tidyverse)
  22. library(ggpubr)
  23. library(rstatix)
  24. 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)))
  25. mdf<-gather(df, "Cytokine","Value",-c(pats,Group))
  26. g<-ggplot(mdf, aes(Cytokine, Value, color=Group))+
  27. geom_boxplot()+
  28. geom_point(position=position_dodge(width = 0.75))
  29. stat.test<-mdf \%>\% group_by(Cytokine) \%>\% t_test(Value~Group)
  30. g+stat_pvalue_manual(ggstats_add_xy(stat.test, mdf, "Group"), label = "p", tip.length = 0.02, hide.ns = T)
  31. }