survminer icon indicating copy to clipboard operation
survminer copied to clipboard

Is it possible to get the p-value per facet in ggsurvplot_facet function

Open mavershang opened this issue 1 year ago • 1 comments

Hello, I have a simple question: in using survminer::ggsurvplot_facet function, how can I get the p-value calculcated per each facet? It's displayed on the plot, but I just want to save it for other analysis. Thanks.

mavershang avatar Oct 11 '22 18:10 mavershang

You can easily calculate it yourself with the survdiff function:

library('survival')
library('tidyverse')
library('survminer')

fit <- survfit( Surv(time, status) ~ sex, data = colon )
ggsurvplot_facet(fit, colon, facet.by = c('rx', 'perfor'), 
                 pval = TRUE, 
                 ggtheme = theme_grey())

# to reproduce the p-value in the upper left and the upper right:
survdiff(Surv(time, status) ~ sex, 
         data = colon, subset = perfor == 0 & rx == 'Obs')$pvalue
survdiff(Surv(time, status) ~ sex, 
         data = colon, subset = perfor == 1 & rx == 'Obs')$pvalue

sebastian-gerdes avatar Aug 04 '23 07:08 sebastian-gerdes