This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Survival analysis with survminer package in R: change number of decimal places in p-value

Hi everyone.

This is my first post on Biostars, so I am not completely sure that this is the best place to ask this question.

I have been using the survminer package in R to do survival analysis (Kaplan-Meier time-to-event) on my data. It is a great package that works very well for me. The only thing that I have not figured out how to do yet is how to change the number of decimal places that the p-value is displayed at. I have looked at the reference manual and cannot find it there either.

I am hoping that someone knows how to do this and could provide some help please.

Thank you!

survminer survival pval r

Just in case this helps, the code below shows the function that produces the Kaplan-Meier curve.

plot10 <- ggsurvplot( fit10, xlab = "Months", 
                     ylab ="Disease free survival probability",
                     legend.title= "Treatment group",
                     legend.labs= c("A", "B"),
                     censor= FALSE,
                     break.time.by= 12,
                     conf.int= TRUE,
                     risk.table = TRUE,
                     risk.table.y.text = TRUE,
                     pval = TRUE,
                     pval.method = TRUE,
                     surv.median.line = "hv",
                     axes.offset= FALSE)

I had the same query long back. What I was doing to resolve this issue is, extracting the p-value manually using surv_pvalue() and then adding it on the KM-plot with the pval parameter

#parse p-value 
p.value <- surv_pvalue(fit = fit, data = surv_data)

#plot it on KM-plot
ggsurvplot(fit, data = surv_data, pval = p.value$pval, ggtheme = theme_survminer(), ......) 
# you can control the decimal points using `format()` in R; format(p.value$pval, digits = 2)

Thank you! That's a good workaround and I will give it a go.

Still, I find it a bit strange that there isn't an argument that does this within survminer itself. That would improve reproducibility probably.

Thank you again for taking the time to post your answer above.

0 answers

No answers yet.

Log in to answer this question.