plot_cox_res: Plot Cox Regression Results

Description Usage Arguments Value Examples

Description

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.

Usage

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)

Arguments

cox.res.df

data.frame output from get_cox_res.

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 iter_get_cox_res or when the parameter group is used in get_cox_res and iter_get_cox_res.

facet.scales

Parameter passed to the scales parameter in ggplot2::facet_grid.

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.

Value

Forest plot of cox regression results in the ggplot framework.

Examples

 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)

tinyheero/survutils documentation built on May 31, 2019, 3:36 p.m.