pharmaverse / ggsurvfit

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

Add survMisc to the related packages #157

Closed m7pr closed 1 year ago

m7pr commented 1 year ago

There are a couple more popular R packages for drawing survival curves. Would you consider adding survMisc https://cranlogs.r-pkg.org/badges/grand-total/survMisc ? It has 985K downloads so would be a good comparison CC @rossfarrugia

ddsjoberg commented 1 year ago

Thanks for the post @m7pr !

Does survMisc add risk tables to survival figures?

bailliem commented 1 year ago

@ddsjoberg anf @m7pr - survMisc is one of the packages we considered for the comparison table on the package website. But I think we didn't include as it doesn't look like it's an active project anymore. For example, I wasn't able to run the autoplot example without error i.e.

library(survMisc)
data("bmt", package="KMsurv")
s2 <- survfit(Surv(time=t2, event=d3) ~ group, data=bmt)
autoplot(s2)

For transparency, the related packages provides a good overview of alternatives to ggsurvfit.

m7pr commented 1 year ago

@bailliem I get such message when I run your code (extended with library(survival))

! Objects of class are not supported by autoplot.

So I guess there are other functions to support plotting survfit in survMisc.

Based on examples in ?survMisc::autoplot.survfit you can see you need to apply ten function over survfit object

t1 <- ten(survfit(Surv(time, delta) ~ type, data=kidney))
autoplot(t1)
autoplot(t1, type="fill", survLineSize=2, jitter="all")
autoplot(t1, timeTicks="months", 
         type="CI", jitter="all",
         legLabs=c("surgical", "percutaneous"),
         title="Time to infection following catheter placement \n
   by type of catheter, for dialysis patients",
         titleSize=10, censSize=2)$plot

first two calls of autoplot() with minimal parameter setup will fail (weeird)

> autoplot(t1)
Error in if (is.nan(times1[1])) times1 <- times : 
  argument is of length zero
> autoplot(t1, type="fill", survLineSize=2, jitter="all")
Error in if (is.nan(times1[1])) times1 <- times : 
  argument is of length zero

but this last, broader specification, gives this

autoplot(t1, timeTicks="months", 
         type="CI", jitter="all",
         legLabs=c("surgical", "percutaneous"),
         title="Time to infection following catheter placement \n
   by type of catheter, for dialysis patients",
         titleSize=10, censSize=2)$plot

image

m7pr commented 1 year ago

@ddsjoberg

Does survMisc add risk tables to survival figures?

I think they do not

ddsjoberg commented 1 year ago

Thanks for following up with those code examples @m7pr !

I took a look at the available vignette on CRAN, and it is full of errors https://cran.r-project.org/web/packages/survMisc/vignettes/plots.pdf

given that some pretty basic code is erring, I don't think there is a benefit to adding it to the list. moreover, we could perhaps remove all the packages that don't add risktable (since creating a survival curve without the risktable is somewhat trivial)...

Thanks again for the post!

m7pr commented 1 year ago

Yes, you are right