Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KM plot show quantiles #93

Closed
SHAESEN2 opened this issue Oct 15, 2020 · 8 comments · Fixed by #288
Closed

KM plot show quantiles #93

SHAESEN2 opened this issue Oct 15, 2020 · 8 comments · Fixed by #288
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed idea To post an idea for a new plot

Comments

@SHAESEN2
Copy link
Collaborator

Add drop lines to show quantiles of the KM distribution.

@SHAESEN2 SHAESEN2 added enhancement New feature or request idea To post an idea for a new plot labels Oct 15, 2020
@SHAESEN2
Copy link
Collaborator Author

Also allow to add horizontal line for median survival using a wrapper around geom_hline(yintercept=xx, linetype = xx)

@SHAESEN2 SHAESEN2 added the help wanted Extra attention is needed label Oct 14, 2021
@timtreis
Copy link
Collaborator

We used this as an "exercise to the reader" in the PSI2021 workshop, so we prepared a minimal solution for this. Just dropping this here as a starting point

m = adtte %>% estimate_KM(strata = "SEX")
half_surv_df = m %>% 
  get_quantile(probs = 0.5) %>% 
  dplyr::filter(quantity == "quantile") %>%
  dplyr::mutate(pos1 = `50`, pos2 = 0.5) %>%
  dplyr::select(-c(quantity, `50`))

half_surv_df_horizontal = half_surv_df %>% dplyr::mutate(pos1 = 0)

half_surv_df_vertical = half_surv_df %>% dplyr::mutate(pos2 = 0)

half_surv_df = rbind(half_surv_df, half_surv_df_horizontal, half_surv_df_vertical)  

m %>%
  visr() %>%
  add_CI() %>%
  add_CNSR() +
  ggplot2::geom_line(data = half_surv_df, 
                     ggplot2::aes(pos1, pos2, group = strata), 
                     linetype = "dashed")

image

@timtreis
Copy link
Collaborator

timtreis commented Nov 2, 2021

@SHAESEN2 I'll probably have some time during R/Pharma 2021 to implement this, doesn't feel like a lot of work. Do you already have a name in mind? `add_survival_quantiles()' with "half" as the default?

@timtreis
Copy link
Collaborator

timtreis commented Nov 2, 2021

Unsorted ideas:

  • lines hitting the x-axis in the colour of the strata?
  • horizontal lines solid?

@SHAESEN2
Copy link
Collaborator Author

SHAESEN2 commented Nov 2, 2021

add_quantiles and make an S3 method out of it => add_quantiles uses get_quantiles.
I like the dotted lines you show in the example and the line color as per strata.

@timtreis
Copy link
Collaborator

timtreis commented Nov 2, 2021

library(visR)
library(ggplot2)

theme_set(theme_bw())

adtte %>%
  visR::estimate_KM("SEX") %>%
  visR::visr() %>%
  visR::add_quantiles()

image

What do you think? The default behaviour is to pick linetype and colour separately for horizontal and vertical lines but are exposed as arguments accepting normal values.

library(visR)
library(ggplot2)

theme_set(theme_bw())

adtte %>%
  visR::estimate_KM("SEX") %>%
  visR::visr() %>%
  visR::add_quantiles(quantiles = c(0.25, 0.5))

image

library(visR)
library(ggplot2)

theme_set(theme_bw())

adtte %>%
  visR::estimate_KM("SEX") %>%
  visR::visr() %>%
  visR::add_quantiles(quantiles = c(0.25, 0.5),
                      linetype = "dashed",
                      linecolour = "black")

image

@timtreis timtreis linked a pull request Nov 2, 2021 that will close this issue
@timtreis timtreis mentioned this issue Nov 2, 2021
@SHAESEN2
Copy link
Collaborator Author

SHAESEN2 commented Nov 2, 2021

I think I prefer a default of dotted lines. I asked @AlexandraP-21 to look into it as well. She has a good eye for those things.

@timtreis timtreis self-assigned this Nov 2, 2021
@AlexandraP-21
Copy link
Collaborator

I took a look at the lines and like them dotted. However, I think that maybe (light) grey (and not black) would be better. The coloring ones I found them a bit confusing and distracting to be honest. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed idea To post an idea for a new plot
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants