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

P-value for multiple comparisons by group - stat_compare_means() #135

Closed
elisheva100 opened this issue Nov 12, 2018 · 14 comments
Closed

P-value for multiple comparisons by group - stat_compare_means() #135

elisheva100 opened this issue Nov 12, 2018 · 14 comments

Comments

@elisheva100
Copy link

elisheva100 commented Nov 12, 2018

I am trying to add p-values for my box plots, but I get an error: Computation failed in stat_compare_means(): argument is of length zero
Where my data.frame: plot.data looks like:
Group value element
1 Transcribed, 0.08620690, Exons
2 Transcribed, 0.09090909, Exons
3 NonTranscribed, 0.02631579, Exons
4 Transcribed, 0.05882353, Introns
5 NonTranscribed, 0.04458599, Introns
6 NonTranscribed, 0.06716418, Introns
And my function is:
makeBoxPlot <- function(plot.data) { p <- ggplot(plot.data, aes(x = element, y = value, fill = Group)) stat_compare_means(aes(group = Group), paired = TRUE, label = "p.signif") }
I dont get any p-values bacause of the above error and I have no idea why I get this error, this function used to work before.

@giuliagrisot
Copy link

giuliagrisot commented Nov 13, 2018

I have a similar problem from today after updating the ggpubr package, significance labels (*** etc) that used to be between columns by group disappeared the following,

ggbarplot(paired_dataset, "Text", "IA_FIRST_FIXATION_DURATION", fill = "Modified", add = "mean_se", add.params = list(group = "Modified"), position = position_dodge(0.8))+ stat_compare_means(method = "t.test", aes(group = Modified), label = "p.signif", label.y = 320, na.rm = TRUE) + labs(x = "Passage number", y = "First fixation duration", caption = "* = p value < 0.5; **** = p value < 0.0001") + scale_fill_manual(values=c("#CCCCCC","#FFFFFF")) + theme_minimal()

and I get these errors:

Removed 67697 rows containing non-finite values (stat_summary).
Removed 67697 rows containing non-finite values (stat_signif).
Computation failed in stat_signif(): missing value where TRUE/FALSE needed

any help would really be appreciated.

@sbbmu
Copy link

sbbmu commented Nov 13, 2018

I have the same problem too. Using the standard data.

`library(ggpubr)
p <- ggboxplot(ToothGrowth, x = "supp", y = "len",
color = "supp", palette = "jco",
add = "jitter",
facet.by = "dose", short.panel.labs = FALSE)

p + stat_compare_means(method = "t.test", label = "p.format")`

I got these errors and no p-values show up.

Warning messages: 1: Computation failed in 'stat_compare_means()': argument is of length zero 2: Computation failed in 'stat_compare_means()': argument is of length zero 3: Computation failed in 'stat_compare_means()': argument is of length zero

1

@kassambara
Copy link
Owner

fixed now, thanks

@benjamin942
Copy link

I am a beginner in R. The bug is fixed now, thanks but what should i do to use stat_compare_means now ? update ggpubr package ? It doesn't work. thank you

@kassambara
Copy link
Owner

Kindly install the latest developmental version of ggpubr as follow:

if(!require(devtools)) install.packages("devtools")
devtools::install_github("kassambara/ggpubr")

Let me know if it works on your computer, so that we can close this issue

@benjamin942
Copy link

after install the last version from your link, the answer is the same

Warning messages:
1: Computation failed in stat_compare_means():
argument is of length zero
2: Computation failed in stat_compare_means():
argument is of length zero
3: Computation failed in stat_compare_means():
argument is of length zero

I try with ToothGrowth datas

library(ggpubr)
p <- ggboxplot(ToothGrowth, x = "supp", y = "len",
color = "supp", palette = "jco",
add = "jitter",
facet.by = "dose", short.panel.labs = FALSE)

p + stat_compare_means(method = "t.test", label = "p.format")

thank you for your help

@kassambara
Copy link
Owner

Please, make sure you have re-started R.

Please, provide the output of the R code devtools::session_info().

When posting your session info, insert the content inside

 
, to make it more readable on GitHub.

Thanks

@benjamin942
Copy link

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : l'espace de noms ‘processx’ 3.1.0 est en train de charger, mais >= 3.2.0 est requis

@kassambara
Copy link
Owner

This is strange, try to install process R package 3.2.0

install.packages("processx")

@benjamin942
Copy link

After process R installation

`- Session info -------------------------------------------------------------------------------------
setting value
version R version 3.4.2 (2017-09-28)
os Windows >= 8 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate French_France.1252
ctype French_France.1252
tz Europe/Paris
date 2018-11-13

  • Packages -----------------------------------------------------------------------------------------
    ! package * version date lib source
    assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.4.4)
    backports 1.1.2 2017-12-13 [1] CRAN (R 3.4.3)
    base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.4.1)
    bindr 0.1.1 2018-03-13 [1] CRAN (R 3.4.4)
    bindrcpp 0.2.2 2018-03-29 [1] CRAN (R 3.4.4)
    boot 1.3-20 2017-08-06 [2] CRAN (R 3.4.2)
    callr 3.0.0 2018-08-24 [1] CRAN (R 3.4.4)
    cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.4.2)
    cli 1.0.1 2018-09-25 [1] CRAN (R 3.4.4)
    colorspace 1.3-2 2016-12-14 [1] CRAN (R 3.4.4)
    crayon 1.3.4 2017-09-16 [1] CRAN (R 3.4.4)
    curl 3.2 2018-03-28 [1] CRAN (R 3.4.4)
    desc 1.2.0 2018-05-01 [1] CRAN (R 3.4.4)
    devtools 2.0.1 2018-10-26 [1] CRAN (R 3.4.4)
    digest 0.6.18 2018-10-10 [1] CRAN (R 3.4.4)
    dplyr 0.7.8 2018-11-10 [1] CRAN (R 3.4.4)
    fs 1.2.6 2018-08-23 [1] CRAN (R 3.4.4)
    ggplot2 * 3.1.0 2018-10-25 [1] CRAN (R 3.4.4)
    ggpubr * 0.1.9 2018-11-11 [1] CRAN (R 3.4.2)
    glue 1.3.0 2018-07-17 [1] CRAN (R 3.4.4)
    gtable 0.2.0 2016-02-26 [1] CRAN (R 3.4.4)
    labeling 0.3 2014-08-23 [1] CRAN (R 3.4.1)
    lazyeval 0.2.1 2017-10-29 [1] CRAN (R 3.4.4)
    magrittr * 1.5 2014-11-22 [1] CRAN (R 3.4.4)
    memoise 1.1.0 2017-04-21 [1] CRAN (R 3.4.4)
    munsell 0.5.0 2018-06-12 [1] CRAN (R 3.4.4)
    pastecs * 1.3.21 2018-03-15 [1] CRAN (R 3.4.4)
    pillar 1.3.0 2018-07-14 [1] CRAN (R 3.4.4)
    pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.4.4)
    pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.4.4)
    pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.4.4)
    plyr 1.8.4 2016-06-08 [1] CRAN (R 3.4.4)
    prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.4.4)
    processx 3.2.0 2018-08-16 [1] CRAN (R 3.4.4)
    ps 1.2.1 2018-11-06 [1] CRAN (R 3.4.4)
    purrr 0.2.5 2018-05-29 [1] CRAN (R 3.4.4)
    V R6 2.2.2 2018-10-04 [1] CRAN (R 3.4.4)
    Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.4.4)
    readxl * 1.0.0 2017-04-18 [1] CRAN (R 3.4.2)
    remotes 2.0.2 2018-10-30 [1] CRAN (R 3.4.4)
    rlang 0.3.0.1 2018-10-25 [1] CRAN (R 3.4.4)
    rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.4.4)
    rstudioapi 0.7 2017-09-07 [1] CRAN (R 3.4.4)
    R scales 0.5.0 [1]
    sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.4.4)
    testthat 2.0.0 2017-12-13 [1] CRAN (R 3.4.4)
    tibble 1.4.2 2018-01-22 [1] CRAN (R 3.4.4)
    tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.4.4)
    usethis 1.4.0 2018-08-14 [1] CRAN (R 3.4.4)
    withr 2.1.2 2018-03-15 [1] CRAN (R 3.4.4)
    yaml 2.1.19 2018-05-01 [1] CRAN (R 3.4.4)

[1] C:/Users/benjd/OneDrive/Documents/R/win-library/3.4
[2] C:/Program Files/R/R-3.4.2/library

V -- Loaded and on-disk version mismatch.
R -- Package was removed from disk.`

but stat_compare_means shows
Warning message: Computation failed in stat_compare_means(): argument is of length zero

@kassambara
Copy link
Owner

I can see that you have the CRAN version of ggpubr. You need to install the latest developmental version from GitHub as follow:

if(!require(devtools)) install.packages("devtools")
devtools::install_github("kassambara/ggpubr")

@benjamin942
Copy link

It works!!! great. thank you

@giuliagrisot
Copy link

the development version install resolved that for me too. thanks

@kassambara
Copy link
Owner

thank you!!

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

5 participants