Description Usage Arguments Value Examples
plot_cox_res
takes the output from get_cox_res
and generates
a forest plot showing the hazard ratio and confidence interval of the cox
cox regression.
1 2 3 | plot_cox_res(cox.res.df, x.lab, y.lab, y.col = "term", color.col,
color.legend.name, coord.flip = FALSE, facet.formula = NULL,
facet.scales = "fixed", add_sig_line = TRUE)
|
cox.res.df |
data.frame output from |
x.lab |
x-axis label. |
y.lab |
y-axis label. |
y.col |
Column name that contains the values for the y-values. |
color.col |
Column name that contains color groups. |
color.legend.name |
Title for the color legend. |
coord.flip |
By default hazard ratio and its confidence interval is plotted on the y-axis using ggplot2::geom_errorbarh(). If this is set to TRUE, then this information is plotted along the x-axis using ggplot2::geom_errorbar(). This means that the x.lab and y.lab will be flipped to. |
facet.formula |
Facet formula for faceting the plot. This should be
used plotting results from |
facet.scales |
Parameter passed to the scales parameter in
|
add_sig_line |
Boolean to indicate if a red, dotted, vertical line should be added to allow users to see if a Cox regression confidence interval overlaps with 1. |
Forest plot of cox regression results in the ggplot framework.
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 | ## Not run:
library("survival")
library("magrittr")
library("dplyr")
in.df <- colon
endpoint <- "time"
endpoint.code <- "status"
# Run and Plot Multivariate Cox Regression on Entire data.frame
features <- c("age", "obstruct")
cox.res.df <- get_cox_res(colon, endpoint, endpoint.code, features)
plot_cox_res(cox.res.df)
# Run and Plot Multivariate Cox Regression For Each rx Group
group <- "rx"
cox.res.df <- get_cox_res(colon, endpoint, endpoint.code, features, group)
plot_cox_res(cox.res.df, facet.formula = ". ~ group")
# Change x and y labels
plot_cox_res(cox.res.df, facet.formula = ". ~ group",
x.lab = "Hazard Ratio", y.lab = "Feature")
# Adding colors
cox.res.df %>%
mutate(sig_flag = p.value < 0.05) %>%
plot_cox_res(facet.formula = ". ~ group", x.lab = "Hazard Ratio",
y.lab = "Feature",
color.col = "sig_flag",
color.legend.name = "Significant Flag")
# Flipping Plot
cox.res.df %>%
mutate(sig_flag = p.value < 0.05) %>%
plot_cox_res(facet.formula = ". ~ group", x.lab = "Hazard Ratio",
y.lab = "Feature",
color.col = "sig_flag",
color.legend.name = "Significant Flag",
coord.flip = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.