summary_stats.Rd
This function provides the following summary statistics:
median_survival
: Median survival with 95% confidence intervals
logrank
: Log-rank test - is there a difference between two (or more) survival curves?
pairwise
: Pairwise log-rank test with p-value correction between conditions.
Default correction: "BH".
summary_stats(df_isurv, type = "all", p_adjust_method = "BH")
a data.frame
of survival data, with one individual per row.
If starting with bulk survival data (multiple observations per row), run get_indiv_surv()
first.
character, either "median_survival", "logrank", "pairwise" or "all". Default: "all"
character, either "holm", "hochberg", "hommel", "bonferroni",
"BH", "BY", "fdr", "none". For details, see ?stats::p.adjust
.
If type == "all"
: a list
object containing results from statistical tests.
Otherwise, returns a ggplot
object containing the survival/mortality curve
logrank
: Calls survival::survdiff()
to test if there is a difference
between two or more survival curves using the G^rho family of tests
pairwise
: Calls survminer::pairwise_survdiff()
, which calculates pairwise comparisons
between groups with corrections for multiple testing.
df_isurv <- get_indiv_surv(sample_data,
sample_order = c("WT", "Drug1", "Drug2"))
#> Joining with `by = join_by(x, condition, day, sex, status)`
stats <- summary_stats(df_isurv)
#>
#> call: formula = Surv(day, status) ~ condition
stats
#> $median_survival
#> Call: survfit(formula = Surv(day, status) ~ condition, data = df_isurv)
#>
#> n events median 0.95LCL 0.95UCL
#> condition=WT 50 47 20.0 19 21
#> condition=Drug1 50 46 4.5 4 6
#> condition=Drug2 50 42 33.0 32 35
#>
#> $logrank
#> Call:
#> survival::survdiff(formula = Surv(day, status) ~ condition, data = df_isurv)
#>
#> N Observed Expected (O-E)^2/E (O-E)^2/V
#> condition=WT 50 47 31.2 7.94 12.9
#> condition=Drug1 50 46 12.5 89.99 128.1
#> condition=Drug2 50 42 91.3 26.60 123.3
#>
#> Chisq= 186 on 2 degrees of freedom, p= <2e-16
#>
#> $pairwise
#>
#> Pairwise comparisons using Log-Rank test
#>
#> data: df_isurv and condition
#>
#> WT Drug1
#> Drug1 2.3e-14 -
#> Drug2 < 2e-16 < 2e-16
#>
#> P value adjustment method: BH
#>