# 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)
# }
Run the code above in your browser using DataLab