Spearman p-value inconsistency
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")
The option exact= FALSE was systematically specified when computing correlation in stat_cor(). Removed now! Thank you for pointing this out.
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?
I am running into the same issue. Also using the spearman. None of it matches with cor.test.
I have the same issue. Could you reopen this discussion?
I'm having the same issue too. Has this been resolved?