plot_surv.Rd
Plots a survival curve from survfit
object.
plot_surv(
fit,
type,
legend.title = "Condition",
legend.position = "right",
xlab = "Day",
add.median.survival = FALSE,
add.conf.int = FALSE,
add.pval = FALSE,
p_adjust_method = "BH",
...
)
a survfit
object, created by fit_surv()
character, either "survival" (a survival curve) or "mortality" (a mortality curve)
character, the legend title. For no title, use legend.title = "". Default: "Condition"
character, one of type "right", "left", "bottom", or "top". For in-plot legends, can be coordinates. c(0,0): bottom left, c(1,1): top right.
character, the x-axis label. Default: "Day"
logical, whether to add the median survival line. Default: FALSE
logical, whether to add confidence intervals. Default: FALSE
logical, whether to add the p-value. Default: FALSE
character, either "holm", "hochberg", "hommel", "bonferroni",
"BH", "BY", "fdr", "none". Default: "BH". For details, see ?stats::p.adjust
.
additional arguments passed to survminer::ggsurvplot()
.
See full list of arguments at survminer::ggsurvplot()
.
A ggplot2
object plotted by the survminer
package
# Convert bulk survival to individual survival
df_isurv <- get_indiv_surv(sample_data,
sample_order = c("WT", "Drug1", "Drug2"))
#> Joining with `by = join_by(x, condition, day, sex, status)`
# Fit survival object
surv_fit <- fit_surv(df_isurv)
#>
#> call: formula = Surv(day, status) ~ condition
# Plot survival curve
plot_surv(fit = surv_fit, type = "survival")
#> Error in eval(fit$call$data): object 'df_isurv' not found