From 4536a565cca1c86d6884c95c51e655f17b3c2e1a Mon Sep 17 00:00:00 2001 From: Michael Ingrisch Date: Thu, 6 Apr 2017 12:31:58 +0200 Subject: [PATCH 1/6] Shape of censors can be changed from the default '+'. Hint: Shape values need to be passed numerically, see http://sape.inf.usi.ch/quick-reference/ggplot2/shape "|", which is a sensible shape for censors, has the code 124. --- R/ggsurvplot.R | 5 +++-- README.Rmd | 11 ++++++++++- ...ADME-ggplot2-basic-survival-plot-censor-1.png | Bin 0 -> 4975 bytes 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 tools/README-ggplot2-basic-survival-plot-censor-1.png diff --git a/R/ggsurvplot.R b/R/ggsurvplot.R index 5718d2a..0cbbb37 100644 --- a/R/ggsurvplot.R +++ b/R/ggsurvplot.R @@ -281,6 +281,7 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, surv.scale = c("default", "percent"), xscale = 1, conf.int = FALSE, conf.int.fill = "gray", conf.int.style = "ribbon", censor = TRUE, + censor.shape=3, pval = FALSE, pval.size = 5, pval.coord = c(NULL, NULL), pval.method = FALSE, pval.method.size = pval.size, pval.method.coord = c(NULL, NULL), log.rank.weights = c("survdiff", "1", "n", "sqrtN", "S1", "S2", "FH_p=1_q=1"), @@ -452,8 +453,8 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, } # Add cencored if (censor & any(d$n.censor >= 1)) { - p <- p + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], - colour = surv.color, size = size*4.5, shape = "+") + p <- p + scale_shape_identity() + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], + colour = surv.color, size = size*4.5, shape = censor.shape) } # Add pvalue diff --git a/README.Rmd b/README.Rmd index 287de5a..d66ddbd 100644 --- a/README.Rmd +++ b/README.Rmd @@ -145,8 +145,17 @@ fit <- survfit(Surv(time, status) ~ sex, data = lung) ```{r ggplot2-basic-survival-plot, fig.height = 4, fig.width = 5} ggsurvplot(fit, data = lung) ``` + +Censor shape can be changed: + +```{r ggplot2-basic-survival-plot-censor, fig.height = 4, fig.width = 5} +ggsurvplot(fit, data = lung, censor.shape=124) +``` - +Shape values need to be passed numerically, see http://sape.inf.usi.ch/quick-reference/ggplot2/shape + +"|", which is a sensible shape for a censor, has the value 124. + ### Customized survival curves diff --git a/tools/README-ggplot2-basic-survival-plot-censor-1.png b/tools/README-ggplot2-basic-survival-plot-censor-1.png new file mode 100644 index 0000000000000000000000000000000000000000..5f6db0d1620a61be9cef4cbed571e5a76ffb3e52 GIT binary patch literal 4975 zcma)A2{hF2yB`c@7#dr~t|I%MZEPcQdy^Bk}Q22 zdm@!ALxxfmenXZiGI#o)bMHC#-21=hzUO_bN!T)y^w&k00;yU zLLWco3IcI4IO__8ha)+##NO^4Bq#?D%Aw}u(Ake4c2n^n zDo06WQ^&fgY&JayNvBfjY&xCIX2nFX5+hh-&V0#2h z&6agMGt3DPN;rP{A_yc*`@6XMA|IXwfkb1_$E@AsN>}bKo%u|aurrj36*WWqjQbrq z_rOuE<#W{~rOC_eV2#H)-FBjiDDKwZ!~1;ldNii`K#xUYV|lA47c99b+Hgl%$YEiy z7(eMc5714-&7*WLC>ERiU*h2gsAY#8UtFhilza&nKtvHHQ3Oo8Ld=U9zkZPll8)7G zeHUDbwN9b0&@6QgFA1JsE&gKWmKqeKc#27XZ!AKZE!!IZnXY49UVNvPx9iXCKWpB1 z!=RR{dvG_>h(Z^Yof4l(7$cpY3u?Dmu}plvyQed|n~294rChcMYuV0B+qK>?^5~rk zoO*IOTmdUDKUrbs@qBM5jNP?9@ai+GPPNDMk+<&7)2Qo?w1t4#vFpo^Tr9Go_yUyA zTQ5^H>Ow=q&l3Ahv9I6}xe@<2=owPe^y5}O|4vCGx>bCzt^1rbUP4O{!7d7!{gce9 z(>~jnYZ$vb+D?ur{L>Uf%S@C_#e_k>O_kagOu&tnEDeEX7r3Q%e~^~ z*D=o-20HQ)n-frcwO1kT*IV=MvHo*3SkRt=!HS{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ih4__~)|t;rhSRn_i&Wce>E8F{5ODM8@l zWVW5ZJ*7p{68&~-WMgY%Eo{d)!EqBB(;od`Z);<5_iF3I>53$3<>(KQ#7~=&#al&= zzoF;aqlsgPrQudi*>fKa{^XE1r?7>#vd${fCeSh(Ka0)ZFLbee5P4QkqHB5E;jhD4 zqOH&h>uM_{=*Sb-*nIDwGX6R6H;J1Y;z(!M%?+XzasVeb$t@`(5T)d>fbb0N@eyZ z%CELecPZR@q~MCu1-p?OCxjtn++Z~6*Y?-XDZ=4NvOYm6D%gV8D;j(x43H8m`K3#* zAyMuNt?`9g1y<2Zq&=*w*@NEnZOg$Y`IkEMd2y91N2+NQE*^HqGP%RN|8m>+gD?&@ za*9y#in(8VKHZwx&geD{2^R!ALmJz;-VhlsK*XWUrnrU|QbIr_>BV{1DYJSiAE}Qw nlbBsw;$^H;Z23RhK)VXu+?lyobDJ=K8)s-+r(=yraisqME(kd3 literal 0 HcmV?d00001 From b51a1559303cb0efffa0c02a4b390ed081e98840 Mon Sep 17 00:00:00 2001 From: Michael Ingrisch Date: Thu, 6 Apr 2017 12:31:58 +0200 Subject: [PATCH 2/6] Fixes #186 Shape of censors can be changed from the default '+'. Hint: Shape values need to be passed numerically, see http://sape.inf.usi.ch/quick-reference/ggplot2/shape "|", which is a sensible shape for censors, has the code 124. --- R/ggsurvplot.R | 5 +++-- README.Rmd | 11 ++++++++++- ...ADME-ggplot2-basic-survival-plot-censor-1.png | Bin 0 -> 4975 bytes 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 tools/README-ggplot2-basic-survival-plot-censor-1.png diff --git a/R/ggsurvplot.R b/R/ggsurvplot.R index 5718d2a..0cbbb37 100644 --- a/R/ggsurvplot.R +++ b/R/ggsurvplot.R @@ -281,6 +281,7 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, surv.scale = c("default", "percent"), xscale = 1, conf.int = FALSE, conf.int.fill = "gray", conf.int.style = "ribbon", censor = TRUE, + censor.shape=3, pval = FALSE, pval.size = 5, pval.coord = c(NULL, NULL), pval.method = FALSE, pval.method.size = pval.size, pval.method.coord = c(NULL, NULL), log.rank.weights = c("survdiff", "1", "n", "sqrtN", "S1", "S2", "FH_p=1_q=1"), @@ -452,8 +453,8 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, } # Add cencored if (censor & any(d$n.censor >= 1)) { - p <- p + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], - colour = surv.color, size = size*4.5, shape = "+") + p <- p + scale_shape_identity() + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], + colour = surv.color, size = size*4.5, shape = censor.shape) } # Add pvalue diff --git a/README.Rmd b/README.Rmd index 287de5a..d66ddbd 100644 --- a/README.Rmd +++ b/README.Rmd @@ -145,8 +145,17 @@ fit <- survfit(Surv(time, status) ~ sex, data = lung) ```{r ggplot2-basic-survival-plot, fig.height = 4, fig.width = 5} ggsurvplot(fit, data = lung) ``` + +Censor shape can be changed: + +```{r ggplot2-basic-survival-plot-censor, fig.height = 4, fig.width = 5} +ggsurvplot(fit, data = lung, censor.shape=124) +``` - +Shape values need to be passed numerically, see http://sape.inf.usi.ch/quick-reference/ggplot2/shape + +"|", which is a sensible shape for a censor, has the value 124. + ### Customized survival curves diff --git a/tools/README-ggplot2-basic-survival-plot-censor-1.png b/tools/README-ggplot2-basic-survival-plot-censor-1.png new file mode 100644 index 0000000000000000000000000000000000000000..5f6db0d1620a61be9cef4cbed571e5a76ffb3e52 GIT binary patch literal 4975 zcma)A2{hF2yB`c@7#dr~t|I%MZEPcQdy^Bk}Q22 zdm@!ALxxfmenXZiGI#o)bMHC#-21=hzUO_bN!T)y^w&k00;yU zLLWco3IcI4IO__8ha)+##NO^4Bq#?D%Aw}u(Ake4c2n^n zDo06WQ^&fgY&JayNvBfjY&xCIX2nFX5+hh-&V0#2h z&6agMGt3DPN;rP{A_yc*`@6XMA|IXwfkb1_$E@AsN>}bKo%u|aurrj36*WWqj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00 2001 From: Michael Ingrisch Date: Thu, 6 Apr 2017 13:38:53 +0200 Subject: [PATCH 3/6] Update documentation --- R/ggsurvplot.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/ggsurvplot.R b/R/ggsurvplot.R index 0cbbb37..6293231 100644 --- a/R/ggsurvplot.R +++ b/R/ggsurvplot.R @@ -48,6 +48,7 @@ #'@param conf.int.style confidence interval style. Allowed values include #' c("ribbon", "step"). #'@param censor logical value. If TRUE, censors will be drawn. +#'@param censor.shape numeric value. Default is 3 ("+"), a sensible choice is 124 ("|"). #'@param pval logical value. If TRUE, the p-value is added on the plot. #'@param pval.size numeric value specifying the p-value text size. Default is 5. #'@param pval.coord numeric vector, of length 2, specifying the x and y From dc99e4c7ee5d0206ddb06253f629c61d850235f9 Mon Sep 17 00:00:00 2001 From: Alboukadel KASSAMBARA Date: Thu, 6 Apr 2017 13:58:55 +0200 Subject: [PATCH 4/6] setting censor.shape default value to "+" instead of 3 --- R/ggsurvplot.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/ggsurvplot.R b/R/ggsurvplot.R index 6293231..8f33ee6 100644 --- a/R/ggsurvplot.R +++ b/R/ggsurvplot.R @@ -48,7 +48,7 @@ #'@param conf.int.style confidence interval style. Allowed values include #' c("ribbon", "step"). #'@param censor logical value. If TRUE, censors will be drawn. -#'@param censor.shape numeric value. Default is 3 ("+"), a sensible choice is 124 ("|"). +#'@param censor.shape character or numeric value. Default is "+" (3), a sensible choice is "|" (124). #'@param pval logical value. If TRUE, the p-value is added on the plot. #'@param pval.size numeric value specifying the p-value text size. Default is 5. #'@param pval.coord numeric vector, of length 2, specifying the x and y @@ -282,7 +282,7 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, surv.scale = c("default", "percent"), xscale = 1, conf.int = FALSE, conf.int.fill = "gray", conf.int.style = "ribbon", censor = TRUE, - censor.shape=3, + censor.shape = "+", pval = FALSE, pval.size = 5, pval.coord = c(NULL, NULL), pval.method = FALSE, pval.method.size = pval.size, pval.method.coord = c(NULL, NULL), log.rank.weights = c("survdiff", "1", "n", "sqrtN", "S1", "S2", "FH_p=1_q=1"), @@ -454,7 +454,7 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, } # Add cencored if (censor & any(d$n.censor >= 1)) { - p <- p + scale_shape_identity() + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], + p <- p + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], colour = surv.color, size = size*4.5, shape = censor.shape) } From 4a99efcbbcc16d6f5297c9cbf21bd7285734f1e0 Mon Sep 17 00:00:00 2001 From: Alboukadel KASSAMBARA Date: Thu, 6 Apr 2017 14:02:16 +0200 Subject: [PATCH 5/6] censor.shape doc updated --- R/ggsurvplot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/ggsurvplot.R b/R/ggsurvplot.R index 8f33ee6..931ba28 100644 --- a/R/ggsurvplot.R +++ b/R/ggsurvplot.R @@ -48,7 +48,7 @@ #'@param conf.int.style confidence interval style. Allowed values include #' c("ribbon", "step"). #'@param censor logical value. If TRUE, censors will be drawn. -#'@param censor.shape character or numeric value. Default is "+" (3), a sensible choice is "|" (124). +#'@param censor.shape character or numeric value specifying the point shape of censored subjects. Default is "+" (3), a sensible choice is "|" (124). #'@param pval logical value. If TRUE, the p-value is added on the plot. #'@param pval.size numeric value specifying the p-value text size. Default is 5. #'@param pval.coord numeric vector, of length 2, specifying the x and y From f52d29a5be372cf32f3fd63f7ee2a341b8d68748 Mon Sep 17 00:00:00 2001 From: Alboukadel KASSAMBARA Date: Thu, 6 Apr 2017 14:04:58 +0200 Subject: [PATCH 6/6] README updated --- README.Rmd | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.Rmd b/README.Rmd index d66ddbd..536e743 100644 --- a/README.Rmd +++ b/README.Rmd @@ -146,15 +146,12 @@ fit <- survfit(Surv(time, status) ~ sex, data = lung) ggsurvplot(fit, data = lung) ``` -Censor shape can be changed: +Censor shape can be changed as follow: ```{r ggplot2-basic-survival-plot-censor, fig.height = 4, fig.width = 5} -ggsurvplot(fit, data = lung, censor.shape=124) +ggsurvplot(fit, data = lung, censor.shape="|") ``` -Shape values need to be passed numerically, see http://sape.inf.usi.ch/quick-reference/ggplot2/shape - -"|", which is a sensible shape for a censor, has the value 124. ### Customized survival curves