-
Notifications
You must be signed in to change notification settings - Fork 31
Package Architecture
Tim Treis edited this page Jul 30, 2021
·
5 revisions
The package aims at keeping data wrangling, plotting and styling independent to maximize code resuability. Preferred workflows of wrangling, plotting and styling for a specific use case (e.g., analysing the time to event in a cohort) into convenience functions that easily generate the visual directly from a less cleaned up data set.
In detail, this is set up as
- Fixed input data models for:
- Estimator function: computes estimates, as well as upper and lower bounds, p-values, etc.
- Visualization function: Visualizes data as a plot or a table (or something else).
- Tables should have specific columns, with the order being important, e.g. first column is the treatment, second column is time, third column is status flag).
- Broom can handle different variations of survival plot (KM, cumulative incidence, etc).
- We could define custom time windows (e.g. three years).
- We could also add the p-value (with custom hypothesis tests, mentioned in the footnote).
vr_time_to_event(data, N_unit = "patients", time_unit = "days", type = "km", abbreviations = "", variable_definitions = "", additional_footnote = "", data_source = "", title = "", xlab = NA, ylab = NA)
[e.g. estimator function: vr_estimate_km, plotting function: vr_plot_tte]
- N can be calculated from the number of rows.
- N unit needs to be specified.
- Time unit needs to be specified.
- N changes over time.
- Number at risk, number of censored observations, number of events can be all computed from the data.
- Abbreviations, variable definitions, hypothesis tests, could be shown as footnotes, or even shown in other ways.
- Definitely include the table with number of events, at risk, censored observations as part of the plot, since it must be aligned with the rest of the plot (we can look at cowplot for aligning the plot and the table if needed).
- We can add a set of input validation checks prior to execution for each function.