sachsmc / ggkm

Compute and display Kaplan-Meier Curves with ggplot2
Other
22 stars 4 forks source link

Using a Stepped version of ribbon for the confidence bands ? #6

Closed smouksassi closed 8 years ago

smouksassi commented 8 years ago

Hi thanks for the nice and only real extension to ggplot to include a KM "stat". I have an issue which is probably related to nousing a stepped ribbon for the confidence intervals. This result in sometimes truncating the ribbon see below the ecog 2 curve while the ecog 3 curve is not shown at all it only appears in the legend : Compare:

library(survival)
library(rms)
lung$SurvObj <- with(lung, Surv(time, status == 2))
km.by.ecog <- npsurv(SurvObj ~ ph.ecog , data = lung)
survplot(fit  = km.by.ecog, conf = c("bands"))

rms survplot output rmsplot

ggplot(lung, aes(time = time, status = ifelse(
          status == 2,1,0),col=as.factor(ph.ecog ),fill=as.factor(ph.ecog ))) +
 geom_km(fill="transparent")+ stat_km(geom="ribbon",alpha=0.1,color="black")+ # this to make the legend include the fill
          geom_kmticks() 

geom_km /stat_km output (ecog 2 ribbon truncated, ecog 3 not shown): stat_kmplot

A potential solution is to use code from but it is only a stat we might need to add a "step_ribbon" geom: https://groups.google.com/forum/?fromgroups=#!topic/ggplot2/9cFWHaH1CPs

sachsmc commented 8 years ago

Thanks for pointing this out, I will work on adding it into the package.

smouksassi commented 8 years ago
                                                                                  ‎ggalt has it already maybe just import it?https://github.com/hrbrmstr/ggaltThank you for the followup.Samer                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         From: Michael SachsSent: Tuesday, August 2, 2016 08:42To: sachsmc/ggkmReply To: sachsmc/ggkmCc: Samer Mouksassi; AuthorSubject: Re: [sachsmc/ggkm] Using a Stepped version of ribbon for the confidence bands ? (#6)Thanks for pointing this out, I will work on adding it into the package. 

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

sachsmc commented 8 years ago

Try it out now using the master branch. install_github("sachsmc/ggkm") The grey line that appears is for the single case where ph.ecog is NA.

fix