pharmaverse / ggsurvfit

http://www.danieldsjoberg.com/ggsurvfit/
Other
69 stars 19 forks source link

Feature request: Add feature to plot a curve for pooled data (similar to Survminer::ggsurvplot_add_all) #219

Open drhmoosavi opened 1 month ago

drhmoosavi commented 1 month ago

Is your feature request related to a problem? Please describe. Currently it seems not possible to add a curve for pooled patient data to the plot.

for example in the example below, it is not possible to create a third curve from combined patient data, in addition to the other 2 curves.

fA <- survfit2(Surv(time, status) ~ sex + adhere, data = df_colon %>% filter(sex == "Female") ) 
fA %>% 
  ggsurvfit(linewidth = 1,linetype_aes = FALSE) +
  add_quantile(y_value = 0.5, color = "black", linewidth = 0.5, linetype= "D3") +
  scale_color_manual(NULL, values = c("red3","#0F8A2F","#30196F")) +
  scale_x_continuous('Time (months)', breaks = seq(0, 9, 3)) +
  labs(x = "Months", y = "OS")  +
  theme_cowplot()
ddsjoberg commented 1 month ago

Hi @drhmoosavi ,

You can add more plots to the same figure by stacking the dataset before passing to survfit(). Example here: https://github.com/pharmaverse/ggsurvfit/issues/212

But let's keep this open, and when we get to a point when ggsurvfit comes to the top of the list for development, we can think of some solutions.