#' @title Creates survival analysis
#' @description Creates a survival plot from MMRF patient clinical data
#' using survival library. It uses the fields days_to_death and vital, plus a
#' columns for groups.
#'
#' @param clin.mm MMRF Clinical patient with the information days_to_death
#' @param clusterCol Column with groups to plot. This is a mandatory field, the
#' caption will be based in this column
#' @param legend Legend title of the figure
#' @param xlim x axis limits e.g. xlim = c(0, 1000). Present narrower X axis, but not affect survival estimates.
#' @param main main title of the plot
#' @param labels labels of the plot
#' @param ylab y axis text of the plot
#' @param xlab x axis text of the plot
#' @param filename The name of the pdf file.
#' @param color Define the colors/Pallete for lines.
#' @param risk.table show or not the risk table
#' @param width Image width
#' @param height Image height
#' @param pvalue show p-value of log-rank test
#' @param conf.int show confidence intervals for point estimates of survival curves.
#' @param dpi Figure quality
#' @importFrom survminer ggsurvplot
#' @importFrom survival survfit Surv
#' @importFrom scales percent
#' @importFrom ggthemes theme_base
#' @importFrom ggrepel geom_text_repel
#' @importFrom gridExtra gtable_rbind
#' @importFrom TCGAbiolinks TCGAanalyze_survival
#' @export
#' @return Survival plot
#' @examples
#' # clin.mm<-MMRFqueryGDC_clinic(type = "clinical")
#' clin.mm <- data.frame(
#' vital_status = c("alive","alive","alive","dead","alive",
#' "alive","dead","alive","dead","alive"),
#' days_to_death = c(NA,NA,NA,172,NA,NA,3472,NA,786,NA),
#' days_to_last_follow_up = c(3011,965,718,NA,1914,423,NA,5,656,1417),
#' gender = c(rep("male",5),rep("female",5))
#' )
#' MMRFanalyzeGDC_survival(clin.mm, clusterCol="gender")
#' MMRFanalyzeGDC_survival(clin.mm, clusterCol="gender", xlim = 1000)
#' MMRFanalyzeGDC_survival(clin.mm,
#' clusterCol="gender",
#' risk.table = FALSE,
#' conf.int = FALSE,
#' color = c("pink","blue"))
#' MMRFanalyzeGDC_survival(clin.mm,
#' clusterCol="gender",
#' risk.table = FALSE,
#' xlim = c(100,1000),
#' conf.int = FALSE,
#' color = c("Dark2"))
MMRFanalyzeGDC_survival <- function(clin.mm,
clusterCol = NULL,
legend = "Legend",
labels = NULL,
risk.table = TRUE,
xlim = NULL,
main = "Kaplan-Meier Overall Survival Curves",
ylab = "Probability of survival",
xlab = "Time since diagnosis (days)",
filename = "survival.pdf",
color = NULL,
height = 8,
width = 12,
dpi = 300,
pvalue = TRUE,
conf.int = TRUE,
barcode =NULL)
{
if (is.null(barcode)){
TCGAanalyze_survival(clin.mm,
clusterCol,
legend,
labels,
risk.table,
xlim,
main,
ylab,
xlab,
filename,
color,
height,
width,
dpi,
pvalue,
conf.int)
}
else{
clin.mm.filt<-clin.mm[clin.mm$bcr_patient_barcode %in% barcode,]
TCGAanalyze_survival(clin.mm.filt,
clusterCol,
legend,
labels,
risk.table,
xlim,
main,
ylab,
xlab,
filename,
color,
height,
width,
dpi,
pvalue,
conf.int)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.