Description Usage Arguments Details Value Functions See Also Examples
Creates a forest plot from SurvivalAnalysisResult objects.
Both univariate (analyse_survival
) results, typically with use_one_hot=TRUE,
and multivariate (analyse_multivariate
) results are acceptable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | forest_plot(
...,
use_one_hot = FALSE,
factor_labeller = identity,
endpoint_labeller = identity,
orderer = identity_order,
categorizer = NULL,
relative_widths = c(1, 1, 1),
ggtheme = theme_bw(),
labels_displayed = c("endpoint", "factor"),
label_headers = c(endpoint = "Endpoint", factor = "Subgroup", n = "n"),
values_displayed = c("HR", "CI", "p"),
value_headers = c(HR = "HR", CI = "CI", p = "p", n = "n", subgroup_n = "n"),
HRsprintfFormat = "%.2f",
psprintfFormat = "%.3f",
p_lessthan_cutoff = 0.001,
log_scale = TRUE,
HR_x_breaks = seq(0, 10),
HR_x_limits = NULL,
factor_id_sep = ":",
na_rm = TRUE,
title = NULL,
title_relative_height = 0.1,
title_label_args = list(),
base_papersize = dinA(4)
)
forest_plot.df(
.df,
factor_labeller = identity,
endpoint_labeller = identity,
orderer = identity_order,
categorizer = NULL,
relative_widths = c(1, 1, 1),
ggtheme = theme_bw(),
labels_displayed = c("endpoint", "factor"),
label_headers = c(endpoint = "Endpoint", factor = "Subgroup", n = "n"),
values_displayed = c("HR", "CI", "p"),
value_headers = c(HR = "HR", CI = "CI", p = "p", n = "n", subgroup_n = "n"),
HRsprintfFormat = "%.2f",
psprintfFormat = "%.3f",
p_lessthan_cutoff = 0.001,
log_scale = TRUE,
HR_x_breaks = seq(0, 10),
HR_x_limits = NULL,
factor_id_sep = ":",
na_rm = TRUE,
title = NULL,
title_relative_height = 0.1,
title_label_args = list(),
base_papersize = dinA(4)
)
|
... |
The SurvivalAnalysisResult objects.
You can also pass one list of such objects, or use explicit splicing (!!! operator).
If not |
use_one_hot |
If not use_one_hot (default), will take univariate or multivariate results and plot hazard ratios
against the reference level (as provided to the |
factor_labeller, endpoint_labeller |
Either
|
orderer |
A function which returns an integer ordering vector for the input:
Example:
|
categorizer |
A function which returns one logical value if a breaking line should be
inserted _above_ the input: Same semantics as for orderer.
!Please note!: The order of the data is not yet ordered as per your orderer!
If you do calculations depending on order, first order with your own orderer function.
A proper implementation is easy using |
relative_widths |
relation of the width of the plots, labels, plot, values. Default is 1:1:1. |
ggtheme |
ggplot2 theme to use |
labels_displayed |
Combination of "endpoint", "factor", "n", determining what is shown on the left-hand table and in which order. |
label_headers |
Named vector with name=<allowed values of labels_displayed>, value=<your heading>. |
values_displayed |
Combination of "HR", "CI", "p", "subgroup_n", determining what is shown on the right-hand table and in which order. Note: subgroup_n is only applicable if oneHot=TRUE. |
value_headers |
Named vector with name=<allowed values of values_displayed>, value=<your heading>. |
HRsprintfFormat, psprintfFormat |
sprintf() format strings for hazard ratio and p value |
p_lessthan_cutoff |
The lower limit below which p value will be displayed as "less than". If p_lessthan_cutoff == 0.001, the a p value of 0.002 will be displayed as is, while 0.0005 will become "p < 0.001". |
log_scale |
Plot on log scale, which is quite common and gives symmetric length for the CI bars. Note that HRs of 0 (did not converge) will not be plotted in this case. |
HR_x_breaks |
Breaks of the x scale for plotting HR and CI |
HR_x_limits |
Limits of the x scale for plotting HR and CI. Default (HR_x_lim = NULL) depends on log_scale and existing limits. Pass NA to use the existing minimum and maximum values without interference. Pass a vector of size 2 to specify (min, max) manually |
factor_id_sep |
Allows you to customize the separator of the factor id, the documentation of factor_labeller. |
na_rm |
Only used in the multivariate case (use_one_hot = FALSE). Should null coefficients (NA/0/Inf) be removed? |
title, title_relative_height, title_label_args |
A title on top of the plot, taking a fraction of title_relative_height of the returned plot.
The title is drawn using |
base_papersize |
numeric vector of length 2, c(width, height), unit inches. forest_plot will store a suggested "papersize" attribute in the return value, computed from base_papersize and the number of entries in the plot (in particular, the height will be adjusted) The attribute is read by save_pdf. It will also store a "forestplot_entries" attribute which you can use for your own calculations. |
.df |
Data frame containing the columns
|
df |
For the variant taking a data frame: A data frame which must contain (at least) the columns: endpoint, factor.id, factor.name, factor.value, HR, Lower_CI, Upper_CI, p, n, subgroup_n |
The plot has a left column containing the labels (covariate name, levels for categorical variables, optionally subgroup size), the actual line plot in the middle column, and a right column to display the hazard ratios and their confidence intervals. A rich set of parameters allows full customizability to create publication-ready plots.
A ggplot2 plot object
forest_plot.df
: Creates a forest plot from the given data frame
1 2 3 4 5 6 | library(magrittr)
library(dplyr)
survival::colon %>%
analyse_multivariate(vars(time, status),
vars(rx, sex, age, obstruct, perfor, nodes, differ, extent)) %>%
forest_plot()
|
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Warning messages:
1: Problem with `mutate()` input `endpointLabel`.
ℹ `lgl_along()` is deprecated as of rlang 0.2.0.
This warning is displayed once per session.
ℹ Input `endpointLabel` is `remove_sequential_duplicates_unless_breakafter(...)`.
2: `lgl_along()` is deprecated as of rlang 0.2.0.
This warning is displayed once per session.
3: `data_frame()` is deprecated as of tibble 1.1.0.
Please use `tibble()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
4: `set_attrs()` is deprecated as of rlang 0.3.0
This warning is displayed once per session.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.