Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for sensitive cases #637

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions R/ggsurvplot_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ ggsurvplot_core <- function(fit, data = NULL, fun = NULL,
pms <- attr(p, "parameters")
surv.color <- pms$color

pms = c(pms,list(...))
pms$fit <- fit
pms$data <- data
pms$risk.table.type <- risk.table.type
Expand Down
7 changes: 6 additions & 1 deletion R/ggsurvtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ NULL
#' labels will be colored by strata.
#'@param fontsize text font size.
#'@param font.family character vector specifying text element font family, e.g.: font.family = "Courier New".
#'@param obscure.less.than numeric, obscure numbers smaller than this.
#'@param obscure.zero logical, obscure or keep zero.
#'@param ... other arguments passed to the function \code{\link{ggsurvtable}} and \code{\link[ggpubr]{ggpar}}.
#'@return a ggplot.
#'@author Alboukadel Kassambara, \email{alboukadel.kassambara@@gmail.com}
Expand Down Expand Up @@ -188,6 +190,7 @@ ggsurvtable <- function (fit, data = NULL, survtable = c("cumevents", "cumcenso
font.family = "",
axes.offset = TRUE,
ggtheme = theme_survminer(), tables.theme = ggtheme,
obscure.less.than = -1, obscure.zero = FALSE,
...)
{

Expand Down Expand Up @@ -254,11 +257,12 @@ ggsurvtable <- function (fit, data = NULL, survtable = c("cumevents", "cumcenso
if(survtable == "cumevents"){
mapping <- aes(x = time, y = rev(strata),
label = cum.n.event, shape = rev(strata))
survsummary$cum.n.event[survsummary$cum.n.event<obscure.less.than & (survsummary$cum.n.event>0 | obscure.zero)] <- paste0('<',obscure.less.than)
}
else if (survtable == "cumcensor"){
mapping <- aes(x = time, y = rev(strata),
label = cum.n.censor, shape = rev(strata))

survsummary$cum.n.event[survsummary$cum.n.censor<obscure.less.than & (survsummary$cum.n.censor>0 | obscure.zero)] <- paste0('<',obscure.less.than)
}
else if (survtable == "risk.table"){
# risk table labels depending on the type argument
Expand All @@ -270,6 +274,7 @@ ggsurvtable <- function (fit, data = NULL, survtable = c("cumevents", "cumcenso
nrisk_cumevents = paste0(survsummary$n.risk, " (", survsummary$cum.n.event, ")"),
survsummary$n.risk
)
llabels[llabels<obscure.less.than & (llabels>0 | obscure.zero)] <- paste0('<',obscure.less.than)
survsummary$llabels <- llabels
mapping <- aes(x = time, y = rev(strata),
label = llabels, shape = rev(strata))
Expand Down