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

Spearman p-value inconsistency #205

Open
tiagochst opened this issue Aug 20, 2019 · 5 comments
Open

Spearman p-value inconsistency #205

tiagochst opened this issue Aug 20, 2019 · 5 comments

Comments

@tiagochst
Copy link

tiagochst commented Aug 20, 2019

Hello,

Someone notice a weird p-value in my correlation plot. When I checked the spearman test from stat_cor is different from the one given by cor.test. The pearson seems to be correct.

Here is an example: http://rpubs.com/tiagochst/inconsistency. I get a 2.2e-16 from stat_cor and 0.3333 from cor.test.

Minimal code below:

data <- data.frame(met = c(0.1073659,0.5130488, 0.0800250), 
                   exp = c(26.10,18.95,47.01)
)
data
spearman.test <- cor.test(x = data$met,y = data$exp, method = "spearman")
spearman.test
p <- ggscatter(data,
               x = "met",
               y = "exp",
               ylab = "log2(TPM + 1)",
               font.label = c(4),
               xlab = "DNA methylation",
               add = "reg.line",                              
               conf.int = FALSE,                                  
               add.params = list(color = "blue",
                                 fill = "lightgray")
)  +    theme(legend.title = element_text(size=8),
          legend.text = element_text(size=8),
          legend.position="right",
          plot.title = element_text(size=8,face="bold"))
p + stat_cor(method = "spearman")
@kassambara
Copy link
Owner

The option exact= FALSE was systematically specified when computing correlation in stat_cor(). Removed now! Thank you for pointing this out.

@tombuurke
Copy link

tombuurke commented Aug 26, 2020

We're still running into a similar issue, can someone help us out?

We're using ggpubr 0.4.0.

The following code produces a p-value of 0.019:

library(ggpubr)
SLAVScatterPlot<- ggscatter(SLAVdata, x= "SLAVAdaptationFirstExposure", y= "SLAVAdaptationSecondExposure", 
          add = "reg.line", conf.int = TRUE, 
          cor.coef = TRUE, cor.method = "spearman",
          xlab = "SLA Adaptation Volume First Exposure", ylab = "SLA Adaptation Volume Second Exposure"
)
SLAVScatterPlot <- annotate_figure(SLAVScatterPlot,
                fig.lab = "A", fig.lab.face = "bold"
)
SLAVScatterPlot

While the code below gives a p-value of 0.1158:

resSLAV <- cor.test(Adapt_data$SLAFirstVolume, Adapt_data$SLASecondVolume,
                method = "spearman")
resSLAV

The data (Adapt_data and SLAVdata) are the same, just structured differently, we checked this.

Does anyone have a clue?

@khayer
Copy link

khayer commented Mar 23, 2022

I am running into the same issue. Also using the spearman. None of it matches with cor.test.

@yzhan360
Copy link

I have the same issue. Could you reopen this discussion?

@tiagochst tiagochst reopened this Sep 26, 2022
@JessQWu
Copy link

JessQWu commented Feb 15, 2024

I'm having the same issue too. Has this been resolved?

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

6 participants