ggKMcat: for categorical covariate x, plot KM curve

Description Usage Arguments Details

View source: R/qplot_survival_p.R

Description

This wraps qplot_survival() function for KM curve generation.

Usage

1
2
3
4
5
6
ggKMcat(x, OS, OScensoring, main, cex.main = 0.8, tag,
  xlab = "Survival time", ylab = "Survival probability", labels,
  legendTitle, nrowL = NA, sizeaxis = 12, sizeaxistitlerel = 1.2,
  sizetitlerel = 0.8, theme_bg = theme_base(), cols, legend_within = TRUE,
  lx = 0.8, ly = 0.88, plot = TRUE, verbose = FALSE,
  addEventCount = F, countFromInput = TRUE)

Arguments

x

a factor

OS

survival time

OScensoring

censoring status, 1 is event

main

title

tag

a tag added at the start of title

xlab

x label

ylab

y label

labels

this is deprecated since labels are just values from x

legendTitle

legend title name

nrowL

legend row number

theme_bg

background theme

cols

either a named vector (names from x) to accurately specify the color or a color vecto which is to be input in the alphabetical order as the x values

legend_within

whether to put legend within the figure

lx

relative x position of legend (between 0~1)

ly

relative y position of legend (between 0~1)

verbose

whether to print warning due to survframe count incompatible with observed.

addEventCount

addEventCount whether to add event count in the legend

Details

Note no sample size indicated in text: NA omitted in x, the strata var, however, OS can still be missing so this is nominal N, effective N due to OS missing is not computed; this is good for tracking sample size and avoid confusion. We just need to bear in mind that some samples will miss OS.

modified 2014/02/14: when x has only one unique value, get error: Error in '$<-.data.frame'('*tmp*', "strata", value = character(0)) : replacement has 0 rows, data has 68 What color corresponds to what label? The labels by default are extracted from levels(x); The cols and computed labels (after adding N) are 1-to-1 mapping. So it is a matter wheather the color is pointing to the same curve, which depends on qplot_survival() function. I cannot prove qplot_survival() gets the color correct. But it seems work for categorical variable at this moment. Updates: qplot_survival() computed sframe which is a df format for ggplot2 where a variable strata is formed which makes it possible to use aes(group=strata, colour=strata). By default, the labels in strata is in alphabetical order; ——————-> Now, ggKMcat does not specify the labels. Instead, if one wants to change the labels, just rename the values in x through mapNames. Since the color and curves are created by aes(group, colour), there is always correct correspondance between curve and colour. The cols can be specified through a named vector so that one can accurately control the color for each curve. To do: add N to the legend

To check with traditional surv curve, do: mysurv <- with(clin1u, survfit(Surv(PFS, PFScensoring) ~ GENDER_PHENO))


nickytong/GenAnalysis documentation built on July 20, 2019, 8:57 a.m.