<div>
<p><br></p>
<p>I’m very pleased to announce that <strong>survminer 0.3.0</strong> is now available on CRAN. survminer makes it easy to create elegant and informative <strong>survival curves</strong>. It includes also functions for summarizing and inspecting graphically the <a href="http://www.sthda.com/cox-model-assumptions"><strong>Cox proportional hazards model assumptions</strong></a>.</p>
<p>This is a big release and a special thanks goes to <a href="https://github.com/MarcinKosinski">Marcin Kosiński</a> and <a href="https://github.com/pbiecek">Przemysław Biecek</a> for their great works in actively improving and adding new features to the survminer package. The official online documentation is available at <a href="http://www.sthda.com/english/rpkgs/survminer/">http://www.sthda.com/english/rpkgs/survminer/</a>.</p>
<br><div>
<strong>Contents</strong><br><ul><li><a href="http://www.sthda.com/#release-notes">Release notes</a></li>
<li><a href="http://www.sthda.com/#installing-and-loading-survminer">Installing and loading survminer</a></li>
<li><a href="http://www.sthda.com/#survival-curves">Survival curves</a></li>
<li><a href="http://www.sthda.com/#arranging-multiple-ggsurvplots-on-the-same-page">Arranging multiple ggsurvplots on the same page</a></li>
<li><a href="http://www.sthda.com/#distribution-of-events-times">Distribution of events’ times</a></li>
<li><a href="http://www.sthda.com/#adjusted-survival-curves-for-cox-model">Adjusted survival curves for Cox model</a></li>
<li><a href="http://www.sthda.com/#graphical-summary-of-cox-model">Graphical summary of Cox model</a></li>
<li><a href="http://www.sthda.com/#pairwise-comparisons-for-survival-curves">Pairwise comparisons for survival curves</a></li>
<li><a href="http://www.sthda.com/#visualizing-competing-risk-analysis">Visualizing competing risk analysis</a></li>
<li><a href="http://www.sthda.com/#related-articles">Related articles</a></li>
<li><a href="http://www.sthda.com/#infos">Infos</a></li>
</ul></div>
<div>
<h2>Release notes</h2>
<p>In this post, we present only the most important changes in v0.3.0. See the <a href="https://github.com/kassambara/survminer/blob/master/NEWS.md#survminer-030">release notes</a> for a complete list.</p>
<div>
<h3>New arguments in ggsurvplot()</h3>
<ul><li><p><strong>data</strong>: Now, it’s recommended to specify the data used to compute survival curves (<a href="https://github.com/kassambara/survminer/issues/142">#142</a>). This will avoid the error generated when trying to use the ggsurvplot() function inside another functions (<a href="https://github.com/kassambara/survminer/issues/125">@zzawadz, #125</a>).</p></li>
<li><p><strong>cumevents</strong> and <strong>cumcensor</strong>: logical value for displaying the cumulative number of events table (<a href="https://github.com/kassambara/survminer/issues/117">#117</a>) and the cumulative number of censored subjects table (<a href="https://github.com/kassambara/survminer/issues/155">#155</a>), respectively.</p></li>
<li><p><strong>tables.theme</strong> for changing the theme of the tables under the main plot.</p></li>
<li><p><strong>pval.method</strong> and <strong>log.rank.weights</strong>: New possibilities to compare survival curves. Functionality based on <strong>survMisc::comp</strong> (<a href="https://github.com/kassambara/survminer/issues/17">@MarcinKosinski, #17</a>). Read also the following blog post on R-Addict website: <a href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html">Comparing (Fancy) Survival Curves with Weighted Log-rank Tests</a>.</p></li>
</ul></div>
<div>
<h3>New functions</h3>
<ul><li><p><strong>pairwise_survdiff</strong>() for pairwise comparisons of survival curves (<a href="https://github.com/kassambara/survminer/issues/97">#97</a>).</p></li>
<li><p><strong>arrange_ggsurvplots</strong>() to arrange multiple ggsurvplots on the same page (<a href="https://github.com/kassambara/survminer/issues/66">#66</a>)</p></li>
</ul><p>Thanks to the work of <a href="https://github.com/pbiecek">Przemysław Biecek</a>, survminer 0.3.0 has received four new functions:</p>
<ul><li><p><strong>ggsurvevents</strong>() to plot the distribution of event’s times (<a href="https://github.com/kassambara/survminer/issues/116">@pbiecek, #116</a>).</p></li>
<li><p><strong>ggcoxadjustedcurves</strong>() to plot adjusted survival curves for Cox proportional hazards model (<a href="https://github.com/kassambara/survminer/issues/133">@pbiecek, #133</a> &amp; <a href="https://github.com/kassambara/survminer/issues/67">@markdanese, #67</a>).</p></li>
<li><p><strong>ggforest</strong>() to draw a forest plot (i.e. graphical summary) for the Cox model (<a href="https://github.com/kassambara/survminer/issues/114">@pbiecek, #114</a>).</p></li>
<li><p><strong>ggcompetingrisks</strong>() to plot the cumulative incidence curves for competing risks (<a href="https://github.com/kassambara/survminer/issues/168">@pbiecek, #168</a>).</p></li>
</ul></div>
<div>
<h3>Vignettes and examples</h3>
<p>Two new vignettes were contributed by <a href="https://github.com/MarcinKosinski">Marcin Kosiński</a>:</p>
<ul><li><a href="http://www.sthda.com/english/rpkgs/survminer/articles/Playing_with_fonts_and_texts.html">Playing with fonts and texts (@MarcinKosinski)</a>.</li>
<li><a href="http://www.sthda.com/english/rpkgs/survminer/articles/Specifiying_weights_in_log-rank_comparisons.html">Specifiying weights in Log-rank comparisons (@MarcinKosinski)</a>.</li>
</ul></div>
</div>
<div>
<h2>Installing and loading survminer</h2>
<p>Install the latest developmental version from <a href="https://github.com/kassambara/survminer">GitHub</a>:</p>
<pre><code>if(!require(devtools)) install.packages(&quot;devtools&quot;)
devtools::install_github(&quot;kassambara/survminer&quot;, build_vignettes = TRUE)</code></pre>
<p>Or, install the latest release from <a href="https://cran.r-project.org/package=survminer">CRAN</a> as follow:</p>
<pre><code>install.packages(&quot;survminer&quot;)</code></pre>
<p>To load survminer in R, type this:</p>
<pre><code>library(&quot;survminer&quot;)</code></pre>
</div>
<div>
<h2>Survival curves</h2>
<p>New arguments displaying supplementary survival tables - cumulative events &amp; censored subjects - under the main survival curves:</p>
<br><div>
<ul><li><strong>risk.table = TRUE</strong>: Displays the risk table</li>
<li><strong>cumevents = TRUE</strong>: Displays the cumulative number of events table.</li>
<li><strong>cumcensor = TRUE</strong>: Displays the cumulative number of censoring table.</li>
<li><strong>tables.height = 0.25</strong>: Numeric value (in [0 - 1]) to adjust the height of all tables under the main survival plot.</li>
</ul></div>
<p><br></p>
<pre><code># Fit survival curves
require(&quot;survival&quot;)
fit </code></pre>
<div>
<p>
survminer
</p>
</div>
<p><span>Cumulative events and censored tables are good additional feedback to survival curves, so that one could realize: what is the number of risk set AND what is the cause that the risk set become smaller: is it caused by events or by censored events?</span></p>
</div>
<div>
<h2>Arranging multiple ggsurvplots on the same page</h2>
<p>The function <strong>arrange_ggsurvplots</strong>() [in survminer] can be used to arrange multiple ggsurvplots on the same page.</p>
<pre><code># List of ggsurvplots
splots </code></pre>
<div>
<p>
survminer
</p>
</div>
<p><br></p>
<p>If you want to save the output into a pdf, type this:</p>
<pre><code># Arrange and save into pdf file
res </code></pre>
</div>
<div>
<h2>Distribution of events’ times</h2>
<p>The function <strong>ggsurvevents</strong>() [in survminer] calculates and plots the distribution for events (both status = 0 and status = 1). It helps to notice when censoring is more common (<a href="https://github.com/kassambara/survminer/issues/116">@pbiecek, #116</a>). This is an alternative to cumulative events and censored tables, described in the previous section.</p>
<p>For example in colon dataset, as illustrated below, censoring occur mostly after the 6’th year:</p>
<pre><code>require(&quot;survival&quot;)
surv </code></pre>
<div>
<p>
survminer
</p>
</div>
</div>
<div>
<h2>Adjusted survival curves for Cox model</h2>
<p>Adjusted survival curves show how a selected factor influences survival estimated from a cox model. If you want read more about why we need to adjust survival curves, see this document: <a href="https://cran.r-project.org/web/packages/survival/vignettes/adjcurve.pdf">Adjusted survival curves</a>.</p>
<p>Briefly, in clinical investigations, there are many situations, where several known factors, potentially affect patient prognosis. For example, suppose two groups of patients are compared: those with and those without a specific genotype. If one of the groups also contains older individuals, any difference in survival may be attributable to genotype or age or indeed both. Hence, when investigating survival in relation to any one factor, it is often desirable to adjust for the impact of others.</p>
<p>The cox proportional-hazards model is one of the most important methods used for modelling survival analysis data.</p>
<p>Here, we present the function <strong>ggcoxadjustedcurves</strong>() [in survminer] for plotting adjusted survival curves for cox proportional hazards model. The <strong>ggcoxadjustedcurves</strong>() function models the risks due to the confounders as described in the section 5.2 of this article: <a href="https://cran.r-project.org/web/packages/survival/vignettes/adjcurve.pdf">Terry M Therneau (2015); Adjusted survival curves</a>. Briefly, the key idea is to predict survival for all individuals in the cohort, and then take the average of the predicted curves by groups of interest (for example, sex, age, genotype groups, etc.).</p>
<pre><code># Data preparation and computing cox model
library(survival)
lung$sex </code></pre>
<div>
<p>
survminer
</p>
</div>
<pre><code># Adjusted survival curves for the variable &quot;sex&quot;
ggcoxadjustedcurves(res.cox, data = lung,
                   variable  = lung[, &quot;sex&quot;],   # Variable of interest
                   legend.title = &quot;Sex&quot;,        # Change legend title
                   palette = &quot;npg&quot;,             # nature publishing group color palettes
                   curv.size = 2                # Change line size
                   )</code></pre>
<div>
<p>
survminer
</p>
</div>
</div>
<div>
<h2>Graphical summary of Cox model</h2>
<p>The function <strong>ggforest</strong>() [in survminer] can be used to create a graphical summary of a Cox model, also known as forest plot. For each covariate, it displays the hazard ratio (HR) and the 95% confidence intervals of the HR. By default, covariates with significant p-value are highlighted in red.</p>
<pre><code># Fit a Cox model
library(survival)
res.cox </code></pre>
<pre><code>## Call:
## coxph(formula = Surv(time, status) ~ sex + age + ph.ecog, data = lung)
##
##               coef exp(coef) se(coef)     z       p
## sexFemale -0.55261   0.57544  0.16774 -3.29 0.00099
## age        0.01107   1.01113  0.00927  1.19 0.23242
## ph.ecog    0.46373   1.58999  0.11358  4.08 4.4e-05
##
## Likelihood ratio test=30.5  on 3 df, p=1.08e-06
## n= 227, number of events= 164
##    (1 observation deleted due to missingness)</code></pre>
<pre><code># Create a forest plot
ggforest(res.cox)</code></pre>
<div>
<p>
survminer
</p>
</div>
</div>
<div>
<h2>Pairwise comparisons for survival curves</h2>
<p>When you compare three or more survival curves at once, the function <strong>survdiff</strong>() [in survival package] returns a global p-value whether to reject or not the null hypothesis.</p>
<p>With this, you know that a difference exists between groups, but you don’t know where. You can’t know until you test each combination.</p>
<p>Therefore, we implemented the function <strong>pairwise_survdiff</strong>() [in survminer]. It calculates pairwise comparisons between group levels with corrections for multiple testing.</p>
<ul><li><strong>Multiple survival curves with global p-value: </strong></li>
</ul><pre><code>library(&quot;survival&quot;)
library(&quot;survminer&quot;)
# Survival curves with global p-value
data(myeloma)
fit2 </code></pre>
<div>
<p>
survminer
</p>
</div>
<p><br></p>
<ul><li><strong>Pairwise survdiff: </strong></li>
</ul><pre><code># Pairwise survdiff
res </code></pre>
<pre><code>##
##  Pairwise comparisons using Log-Rank test
##
## data:  myeloma and molecular_group
##
##                  Cyclin D-1 Cyclin D-2 Hyperdiploid Low bone disease MAF   MMSET
## Cyclin D-2       0.723      -          -            -                -     -
## Hyperdiploid     0.328      0.103      -            -                -     -
## Low bone disease 0.644      0.447      0.723        -                -     -
## MAF              0.943      0.723      0.103        0.523            -     -
## MMSET            0.103      0.038      0.527        0.485            0.038 -
## Proliferation    0.723      0.988      0.103        0.485            0.644 0.062
##
## P value adjustment method: BH</code></pre>
<ul><li><strong>Symbolic number coding: </strong></li>
</ul><pre><code># Symbolic number coding
symnum(res$p.value, cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 0.1, 1),
   symbols = c(&quot;****&quot;, &quot;***&quot;, &quot;**&quot;, &quot;*&quot;, &quot;+&quot;, &quot; &quot;),
   abbr.colnames = FALSE, na = &quot;&quot;)</code></pre>
<pre><code>##                  Cyclin D-1 Cyclin D-2 Hyperdiploid Low bone disease MAF MMSET
## Cyclin D-2
## Hyperdiploid
## Low bone disease
## MAF
## MMSET                       *                                        *
## Proliferation                                                            +
## attr(,&quot;legend&quot;)
## [1] 0 '****' 1e-04 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1 \t    ## NA: ''</code></pre>
</div>
<div>
<h2>Visualizing competing risk analysis</h2>
<p>Competing risk events refer to a situation where an individual (patient) is at risk of more than one mutually exclusive event, such as death from different causes, and the occurrence of one of these will prevent any other event from ever happening.</p>
<p>For example, when studying relapse in patients who underwent HSCT (Hematopoietic stem cell transplantation), transplant related mortality is a competing risk event and the cumulative incidence function (CIF) must be calculated by appropriate accounting.</p>
<p>A ‘competing risks’ analysis is implemented in the R package <a href="https://cran.r-project.org/package=cmprsk">cmprsk</a>. Here, we provide the <strong>ggcompetingrisks</strong>() function [in survminer] to plot the results using ggplot2-based elegant data visualization.</p>
<pre><code># Create a demo data set
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set.seed(2)
failure_time </code></pre>
<div>
<p>
survminer
</p>
</div>
<p>The <strong>ggcometingrisks</strong>() function has also support for <strong>multi-state survival</strong> objects (type = “mstate”), where the status variable can have multiple levels. The first of these will stand for censoring, and the others for various event types, e.g., causes of death.</p>
<pre><code># Data preparation
df </code></pre>
<div>
<p>
survminer
</p>
</div>
</div>
<div>
<h2>Related articles</h2>
<ul><li><a href="http://www.sthda.com/survival-analysis">Survival Analysis</a>
<ul><li><a href="http://www.sthda.com/survival-analysis-basics">Survival Analysis Basics: Curves and Logrank Tests</a></li>
<li><a href="http://www.sthda.com/cox-proportional-hazards-model">Cox Proportional Hazards Model</a></li>
<li><a href="http://www.sthda.com/cox-model-assumptions">Cox Model Assumptions</a></li>
</ul></li>
</ul></div>
<div>
<h2>Infos</h2>
<p><span> This analysis has been performed using <strong>R software</strong> (ver. 3.3.2). </span></p>
</div>
</div>