pharmaverse / ggsurvfit

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

ggsurvfit should use the mitre linejoin for geom_step #207

Open psoldath opened 2 months ago

psoldath commented 2 months ago

Hi Daniel

I know you are working on releasing a new version of ggsurvfit to accommodate the recent changes in the survival package and ggplot2. In this regard, I think it would be beneficial to also update the defaults of the ggsurvfit() and ggcuminc() geoms to use the newly implemented "mitre" linejoin for geom_step() instead of the "round" linejoin. The mitre linejoin would allow for more accurate digitisation of the plot data and reconstruction of the event times as described in these GitHubs: https://github.com/tidyverse/ggplot2/issues/5705 https://github.com/tidyverse/ggplot2/pull/5706

ddsjoberg commented 2 months ago

Hi @psoldath , I hadn't read about that update yet. Thanks for letting me know. Can you show a side-by-side comparison of the difference in the appearance of the rendered plot? This will also require updates to the exported step ribbon method as well to match.

psoldath commented 2 months ago

Of course, @ddsjoberg It does not require you to update the geom_ribbon as it already uses sharp corners at steps. As you can see the mitre linejoin allows for digitization software to find the exact time of events as the midpoint of the diagonal line of each step, whereas the round linejoin curves one of the corners and hereby shortens the diagonal distance, so the midpoint of the diagonal line doesn't reflect the exact time of event.

library(tidyverse) library(ggsurvfit)

Round linejoin

round <- survfit2(Surv(time, status) ~ surg, data = df_colon) %>% ggsurvfit()

Mitre linejoin

mitre <- survfit2(Surv(time, status) ~ surg, data = df_colon) %>% ggsurvfit(linejoin = "mitre")

Round linejoin:

round

Mitre linejoin: mitre