The goal of reportRmd is to automate the reporting of clinical data in Rmarkdown environments. Functions include table one-style summary statistics, compilation of multiple univariate models, tidy output of multivariable models and side by side comparisons of univariate and multivariable models. Plotting functions include customisable survival curves, forest plots, and automated bivariate plots.
Installing from CRAN:
install.packages('reportRmd')
You can install the development version of reportRmd from GitHub with:
# install.packages("devtools")
::install_github("biostatsPMH/reportRmd") devtools
library(reportRmd)
data("pembrolizumab")
rm_covsum(data=pembrolizumab, maincov = 'sex',
covs=c('age','pdl1','change_ctdna_group'),
show.tests=TRUE)
Full Sample (n=94) | Female (n=58) | Male (n=36) | p-value | Effect Size | StatTest | |
---|---|---|---|---|---|---|
age | 0.30 | 0.008 | Wilcoxon Rank Sum, Eta sq | |||
Mean (sd) | 57.9 (12.8) | 56.9 (12.6) | 59.3 (13.1) | |||
Median (Min,Max) | 59.1 (21.1, 81.8) | 56.6 (34.1, 78.2) | 61.2 (21.1, 81.8) | |||
pdl1 | 0.76 | 0.002 | Wilcoxon Rank Sum, Eta sq | |||
Mean (sd) | 13.9 (29.2) | 15.0 (30.5) | 12.1 (27.3) | |||
Median (Min,Max) | 0 (0, 100) | 0.5 (0.0, 100.0) | 0 (0, 100) | |||
Missing | 1 | 0 | 1 | |||
change ctdna group | 0.81 | 0.02 | Fisher Exact, Cramer | |||
Decrease from baseline | 33 (45) | 19 (48) | 14 (42) | |||
Increase from baseline | 40 (55) | 21 (52) | 19 (58) | |||
Missing | 21 | 18 | 3 |
rm_uvsum(data=pembrolizumab, response='orr',
covs=c('age','pdl1','change_ctdna_group'))
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
OR(95%CI) | p-value | N | |
---|---|---|---|
age | 0.96 (0.91, 1.00) | 0.09 | 94 |
pdl1 | 0.97 (0.95, 0.98) | <0.001 | 93 |
change ctdna group | 0.002 | 73 | |
Decrease from baseline | Reference | 33 | |
Increase from baseline | 28.74 (5.20, 540.18) | 40 |
<- glm(orr~change_ctdna_group+pdl1+cohort,
glm_fit family='binomial',
data = pembrolizumab)
rm_mvsum(glm_fit,showN=T)
OR(95%CI) | p-value | Global p-value | N | VIF | |
---|---|---|---|---|---|
change ctdna group | 0.009 | 73 | 1.00 | ||
Decrease from baseline | Reference | 33 | |||
Increase from baseline | 19.99 (2.08, 191.60) | 40 | |||
pdl1 | 0.97 (0.95, 1.00) | 0.07 | 73 | 1.18 | |
cohort | 0.004 | 73 | 1.04 | ||
A | Reference | 14 | |||
B | 2.6e+07 (0e+00, Inf) | 1.00 | 11 | ||
C | 4.2e+07 (0e+00, Inf) | 1.00 | 10 | ||
D | 0.07 (4.2e-03, 1.09) | 0.06 | 10 | ||
E | 0.44 (0.04, 5.10) | 0.51 | 28 |
<- rm_uvsum(data=pembrolizumab, response='orr',
uvsumTable covs=c('age','sex','pdl1','change_ctdna_group'),tableOnly = TRUE)
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
<- glm(orr~change_ctdna_group+pdl1,
glm_fit family='binomial',
data = pembrolizumab)
<- rm_mvsum(glm_fit,tableOnly = TRUE)
mvsumTable
rm_uv_mv(uvsumTable,mvsumTable)
Unadjusted OR(95%CI) | N | p | Adjusted OR(95%CI) | p (adj) | |
---|---|---|---|---|---|
age | 0.96 (0.91, 1.00) | 94 | 0.09 | ||
sex | 94 | 0.11 | |||
Female | Reference | 58 | |||
Male | 0.41 (0.13, 1.22) | 36 | |||
pdl1 | 0.97 (0.95, 0.98) | 93 | <0.001 | 0.98 (0.96, 1.00) | 0.02 |
change ctdna group | 73 | 0.002 | 0.004 | ||
Decrease from baseline | Reference | 33 | Reference | ||
Increase from baseline | 28.74 (5.20, 540.18) | 40 | 24.71 (2.87, 212.70) |
Shows events, median survival, survival rates at different times and the log rank test. Does not allow for covariates or strata, just simple tests between groups
rm_survsum(data=pembrolizumab,time='os_time',status='os_status',
group="cohort",survtimes=c(12,24),
# group="cohort",survtimes=seq(12,36,12),
# survtimesLbls=seq(1,3,1),
survtimesLbls=c(1,2),
survtimeunit='yr')
cohort | Events/Total | Median (95%CI) | 1yr (95% CI) | 2yr (95% CI) |
---|---|---|---|---|
A | 12/16 | 8.30 (4.24, NA) | 0.38 (0.20, 0.71) | 0.23 (0.09, 0.59) |
B | 16/18 | 8.82 (4.67, 20.73) | 0.32 (0.16, 0.64) | 0.06 (9.6e-03, 0.42) |
C | 12/18 | 17.56 (7.95, NA) | 0.61 (0.42, 0.88) | 0.44 (0.27, 0.74) |
D | 4/12 | NA (6.44, NA) | 0.67 (0.45, 0.99) | 0.67 (0.45, 0.99) |
E | 20/30 | 14.26 (9.69, NA) | 0.63 (0.48, 0.83) | 0.34 (0.20, 0.57) |
Log Rank Test | ChiSq | 11.3 on 4 df | ||
p-value | 0.02 |
ggkmcif(response = c('os_time','os_status'),
cov='cohort',
data=pembrolizumab)
require(ggplot2)
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 4.2.2
forestplot2(glm_fit)
#> Warning: Vectorized input to `element_text()` is not officially supported.
#> ℹ Results may be unexpected or may change in future versions of ggplot2.
These plots are designed for quick inspection of many variables, not for publication.
require(ggplot2)
plotuv(data=pembrolizumab, response='orr',
covs=c('age','cohort','pdl1','change_ctdna_group'))
#> Boxplots not shown for categories with fewer than 20 observations.
#> Boxplots not shown for categories with fewer than 20 observations.