Learn R Programming

admiral

ADaM in R Asset Library

Purpose

To provide an open source, modularized toolbox that enables the pharmaceutical programming community to develop ADaM datasets in R.

Installation

The package is available from CRAN and can be installed with:

install.packages("admiral")

To install the development version of the package from GitHub run:

# install.packages("devtools")
devtools::install_github("pharmaverse/admiral")

Cheat Sheet

Release Schedule

The {admiral} family has several downstream and upstream dependencies and so releases are done in two Phases:

Release SchedulePhase 1- Date and PackagesPhase 2- Date and Packages
Q4-2024December 2ndDecember 9th
{pharmaversesdtm}{admiralonco}
{admiraldev}{admiralophtha}
{admiral}{admiralvaccine}{pharmaverseadam}
Q2-2025June 2ndJune 10th
{pharmaversesdtm}{admiralonco}
{admiraldev}{admiralophtha}
{admiral}{admiralvaccine}{pharmaverseadam}

Main Goal

Provide users with an open source, modularized toolbox with which to create ADaM datasets in R. As opposed to a "run 1 line and an ADaM appears" black-box solution or an attempt to automate ADaM.

One of the key aspects of {admiral} is its development by the users for the users. It gives an entry point for all to collaborate, co-create and contribute to a harmonized approach of developing ADaMs in R across the pharmaceutical industry.

Scope

To set expectations: It is not our target that {admiral} will ever provide all possible solutions for all ADaM datasets outside of study specific needs. It depends on the user's collaboration and contribution to help grow over time to an asset library that is robust, easy to use and has an across-industry focus. We do not see a coverage of 100% of all ADaM derivations as ever achievable---ADaM is endless.

We will provide:

  • A toolbox of re-usable functions and utilities to create ADaM datasets using R scripts in a modular manner (an "opinionated" design strategy).
  • Pharmaceutical communities and companies are encouraged to contribute to {admiral} following the provided programming strategy and modular approach
  • Functions that are comprehensively documented and tested, including example calls---these are all listed in the Reference section.
  • Vignettes on how to create ADSL, BDS and OCCDS datasets, including example scripts.
  • Vignettes for ADaM dataset specific functionality (i.e. dictionary coding, date imputation, SMQs ...).

The {admiral} Family of Packages

There are three types of packages in the {admiral} family:

  • Core package---one package containing all core functions required to create ADaMs, usable by any company (i.e. general derivations, utility functions and checks for ADSL, OCCDS and BDS).
  • TA (Therapeutic Area) package extensions---one package per TA with functions that are specific to algorithms and requirements for that particular TA (e.g. {admiralonco}).
  • Company package extensions---specific needs and plug-ins for the company, such as access to metadata (e.g. {admiralroche} or {admiralgsk}).

Related Packages

Related data packages include:

Both these packages are developed by the {admiral} team, but can used across the pharmaverse as common, open-source test SDTM or ADaM data.

The following packages are also useful when working with ADaM datasets:

  • {metacore} and {metatools}---these enable users to manipulate and work with dataset metadata.
  • {xportr}---this provides functionality to get xpt files ready for transport.

Admiral Manifesto

For {admiral} and all extension packages, we prioritize providing our users with a simple to adopt toolkit that enables them to produce readable and easily constructible ADaM programs. The following explains our philosophy, which we try to adhere to across the {admiral} family of packages. There isn't always a clear single, straightforward rule, but there are guiding principles we adhere to for {admiral}. This manifesto helps show the considerations of our developers when making decisions.

We have four design principles to achieve the main goal:

Usability

All {admiral} functions should be easy to use.

  • Documentation is an absolute priority. Each function reference page should cover the purpose, descriptions of each argument with permitted values, the expected input and output, with clear real-life examples---so that users don't need to dig through code to find answers.
  • Vignettes that complement the functional documentation to help users see how best the functions can be applied to achieve ADaM requirements.
  • Functions should be written and structured in a way that users are able to read, re-use or extend them for study specific purposes if needed (see Readability below).

Simplicity

All {admiral} functions have a clear purpose.

  • We try not to ever design single functions that could achieve numerous very different derivations. For example if you as a user pick up a function with >10 different arguments then chances are it is going to be difficult to understand if this function could be applied for your specific need. The intention is that arguments/parameters can influence how the output of a function is calculated, but not change the purpose of the function.

  • We try to combine similar tasks and algorithms into one function where applicable to reduce the amount of repetitive functions with similar algorithms and to group together similar functionality to increase usability (e.g. one study day calculation rather than a function per variable).

  • We strive to design functions that are not too general and trying to fulfill multiple, complex purposes.

  • Functions should not allow expressions as arguments that are used as code snippets in function calls.

  • We recommend to avoid copy and paste of complex computational algorithms or repetitive code like checks and advise to wrap them into a function. However we would also like to avoid multi-layered functional nesting, so this needs to be considered carefully to keep the nesting of 3-4 functions an exception rather than the rule.

Findability

All {admiral} functions are easily findable.

  • In a growing code base, across a family of packages, we make every effort to make our functions easily findable.
  • We use consistent naming conventions across all our functions, and provide vignettes and ADaM templates that help users to get started and build familiarity. Each {admiral} family package website is searchable.
  • We avoid repetitive functions that will do similar tasks (as explained above with study day example).
  • Each package extension is kept focused on the specific scope, e.g. features that are relevant across multiple extension packages will be moved to the core {admiral} package.

Readability

All {admiral} functions follow the Programming Strategy that all our developers and contributors must follow, so that all our code has a high degree of consistency and readability.

  • We encourage use of tidyverse (e.g. dplyr) over similar functionality existing in base R.
  • For sections of code that perform the actual derivations (e.g. besides assertions or basic utilities), we try to limit nesting of too many dependencies or functions.
  • Modularity is a focus---we don't try to achieve too many steps in one.
  • All code has to be well commented.
  • We recognize that a user or a Health Authority reviewer may have the wish to delve into the code base (especially given this open source setting), or users may need to extend/adapt the code for their study specific needs. We therefore want any module to be understandable to all, not only the {admiral} developers.

References and Documentation

Pharmaverse Blog

If you are interested in R and Clinical Reporting, then visit the pharmaverse blog. This contains regular, bite-sized posts showcasing how {admiral} and other packages in the pharmaverse can be used to realize the vision of full end-to-end Clinical Reporting in R.

We are also always looking for keen {admiral} users to publish their own blog posts about how they use the package. If this could be you, feel free make an issue in the GitHub repo and get started!

Recent Conference Presentations

For a full collection of {admiral} conference presentations over the years, please travel to our Presentation Archive.

Contact

We use the following for support and communications between user and developer community:

  • Slack---for informal discussions, Q&A and building our user community. If you don't have access, use this link to join the pharmaverse Slack workspace.
  • GitHub Issues---for direct feedback, enhancement requests or raising bugs.

Acknowledgments

Along with the authors and contributors, thanks to the following people for their work on the package:

Jaxon Abercrombie, Mahdi About, Teckla Akinyi, James Black, Claudia Carlucci, Asha Chakma, Bill Denney, Kamila Duniec, Alice Ehmann, Romain Francois, Ania Golab, Alana Harris, Declan Hodges, Anthony Howard, Shimeng Huang, Samia Kabi, James Kim, John Kirkpatrick, Leena Khatri, Robin Koeger, Konstantina Koukourikou, Pavan Kumar, Pooja Kumari, Shan Lee, Wenyi Liu, Iain McCay, Jack McGavigan, Jordanna Morrish, Syed Mubasheer, Thomas Neitmann, Yohann Omnes, Barbara O'Reilly, Hamza Rahal, Nick Ramirez, Tom Ratford, Sukalpo Saha, Tamara Senior, Sophie Shapcott, Ondrej Slama, Andrew Smith, Daniil Stefonishin, Vignesh Thanikachalam, Michael Thorpe, Annie Yang, Ojesh Upadhyay and Franciszek Walkowiak.

Copy Link

Version

Install

install.packages('admiral')

Monthly Downloads

1,197

Version

1.1.1

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

June 17th, 2024

Functions in admiral (1.1.1)

compute_age_years

Compute Age in Years
compute_egfr

Compute Estimated Glomerular Filtration Rate (eGFR) for Kidney Function
compute_framingham

Compute Framingham Heart Study Cardiovascular Disease 10-Year Risk Score
compute_bsa

Compute Body Surface Area (BSA)
compute_duration

Compute Duration
censor_source

Create a censor_source Object
compute_bmi

Compute Body Mass Index (BMI)
compute_dtf

Derive the Date Imputation Flag
compute_map

Compute Mean Arterial Pressure (MAP)
chr2vars

Turn a Character Vector into a List of Expressions
compute_qual_imputation_dec

Compute Factor for Value Imputations When Character Value Contains < or >
convert_blanks_to_na

Convert Blank Strings Into NAs
compute_rr

Compute RR Interval From Heart Rate
consolidate_metadata

Consolidate Multiple Meta Datasets Into a Single One
convert_dtc_to_dt

Convert a Date Character Vector into a Date Object
compute_qual_imputation

Function to Impute Values When Qualifier Exists in Character Result
convert_date_to_dtm

Convert a Date into a Datetime Object
compute_qtc

Compute Corrected QT
compute_scale

Compute Scale Parameters
create_single_dose_dataset

Create dataset of single doses
compute_tmf

Derive the Time Imputation Flag
count_vals

Count Number of Observations Where a Variable Equals a Value
convert_dtc_to_dtm

Convert a Date Character Vector into a Datetime Object
country_code_lookup

Country Code Lookup
date_source

Create a date_source object
convert_na_to_blanks

Convert NAs Into Blank Strings
derivation_slice

Create a derivation_slice Object
default_qtc_paramcd

Get Default Parameter Code for Corrected QT
create_query_data

Creates a queries dataset as input dataset to the dataset_queries argument in derive_vars_query()
create_period_dataset

Create a Reference Dataset for Subperiods, Periods, or Phases
derive_param_bmi

Adds a Parameter for BMI
derive_param_exist_flag

Add an Existence Flag Parameter
derive_extreme_event

Add the Worst or Best Observation for Each By Group as New Records
derive_expected_records

Derive Expected Records
derive_locf_records

Derive LOCF (Last Observation Carried Forward) Records
derive_param_computed

Adds a Parameter Computed from the Analysis Value of Other Parameters
derive_extreme_records

Add the First or Last Observation for Each By Group as New Records
derive_param_bsa

Adds a Parameter for BSA (Body Surface Area) Using the Specified Method
derive_basetype_records

Derive Basetype Variable
derive_param_doseint

Adds a Parameter for Dose Intensity
derive_param_tte

Derive a Time-to-Event Parameter
derive_param_map

Adds a Parameter for Mean Arterial Pressure
derive_summary_records

Add New Records Within By Groups Using Aggregation Functions
derive_var_age_years

Derive Age in Years
derive_param_qtc

Adds a Parameter for Corrected QT (an ECG measurement)
derive_param_framingham

Adds a Parameter for Framingham Heart Study Cardiovascular Disease 10-Year Risk Score
derive_param_rr

Adds a Parameter for Derived RR (an ECG measurement)
derive_param_exposure

Add an Aggregated Parameter and Derive the Associated Start and End Dates
derive_param_wbc_abs

Add a parameter for lab differentials converted to absolute values
derive_param_extreme_record

Adds a Parameter Based on First or Last Record from Multiple Sources
derive_var_atoxgr

Derive Lab High toxicity Grade 0 - 4 and Low Toxicity Grades 0 - (-4)
derive_var_anrind

Derive Reference Range Indicator
derive_var_analysis_ratio

Derive Ratio Variable
derive_var_chg

Derive Change from Baseline
derive_var_extreme_dtm

Derive First or Last Datetime from Multiple Sources
derive_var_base

Derive Baseline Variables
derive_var_dthcaus

Derive Death Cause
derive_var_atoxgr_dir

Derive Lab Toxicity Grade 0 - 4
derive_var_extreme_flag

Add a Variable Flagging the First or Last Observation Within Each By Group
derive_var_extreme_dt

Derive First or Last Date from Multiple Sources
derive_var_pchg

Derive Percent Change from Baseline
derive_var_relative_flag

Flag Observations Before or After a Condition is Fulfilled
derive_var_joined_exist_flag

Derives a Flag Based on an Existing Flag
derive_var_merged_ef_msrc

Merge an Existence Flag From Multiple Sources
derive_var_ontrtfl

Derive On-Treatment Flag Variable
derive_var_shift

Derive Shift
derive_var_obs_number

Adds a Variable Numbering the Observations Within Each By Group
derive_var_merged_exist_flag

Merge an Existence Flag
derive_var_merged_summary

Merge Summary Variables
derive_var_trtdurd

Derive Total Treatment Duration (Days)
derive_vars_dtm_to_dt

Derive Date Variables from Datetime Variables
derive_var_trtemfl

Derive Treatment-emergent Flag
derive_vars_atc

Derive ATC Class Variables
derive_vars_dtm_to_tm

Derive Time Variables from Datetime Variables
derive_vars_duration

Derive Duration
derive_vars_dt

Derive/Impute a Date from a Date Character Vector
derive_vars_dy

Derive Relative Day Variables
derive_vars_dtm

Derive/Impute a Datetime from a Date Character Vector
derive_vars_aage

Derive Analysis Age
derive_vars_computed

Adds Variable(s) Computed from the Analysis Value of one or more Parameters
dt_level

Create a dt_level object
derive_vars_extreme_event

Add the Worst or Best Observation for Each By Group as New Variables
dose_freq_lookup

Pre-Defined Dose Frequencies
derive_vars_merged_lookup

Merge Lookup Table with Source Dataset
derive_vars_period

Add Subperiod, Period, or Phase Variables to ADSL
derive_vars_query

Derive Query Variables
derive_vars_transposed

Derive Variables by Transposing and Merging a Second Dataset
dthcaus_source

Create a dthcaus_source Object
derive_vars_merged

Add New Variable(s) to the Input Dataset Based on Variables from Another Dataset
derive_vars_joined

Add Variables from an Additional Dataset Based on Conditions from Both Datasets
filter_exist

Returns records that fit into existing by groups in a filtered source dataset
ex_single

Single Dose Exposure Dataset
filter_extreme

Filter the First or Last Observation for Each By Group
dtm_level

Create a dtm_level object
extract_duplicate_records

Extract Duplicate Records
event_joined

Create a event_joined Object
example_qs

Example QS Dataset
extract_unit

Extract Unit From Parameter Description
event_source

Create an event_source Object
event

Create a event Object
get_duplicates_dataset

Get Duplicate Records that Led to a Prior Error
filter_joined

Filter Observations Taking Other Observations into Account
get_imputation_target_date

Get Date Imputation Targets
get_hori_data

Creating Temporary Parameters and <variable>.<parameter> Variables
get_flagged_records

Create an Existence Flag
format.basket_select

Returns a Character Representation of a basket_select() Object
get_admiral_option

Get the Value of an Admiral Option
filter_not_exist

Returns records that don't fit into existing by groups in a filtered source dataset
get_terms_from_db

Get Terms from the Queries Database
get_summary_records

Create Summary Records
get_not_mapped

Get list of records not mapped from the lookup table.
filter_relative

Filter the Observations Before or After a Condition is Fulfilled
get_many_to_one_dataset

Get Many to One Values that Led to a Prior Error
flag_event

Create a flag_event Object
impute_dtc_dtm

Impute Partial Date(-time) Portion of a '--DTC' Variable
get_joined_data

Join Data for "joined" functions
get_vars_query

Get Query Variables
get_imputation_target_time

Get Time Imputation Targets
impute_dtc_dt

Impute Partial Date Portion of a '--DTC' Variable
get_partialdatetime

Parse DTC variable and Determine Components
get_one_to_many_dataset

Get One to Many Values that Led to a Prior Error
print.adam_templates

Print adam_templates Objects
min_cond

Minimum Value on a Subset
params

Create a Set of Parameters
print.duplicates

Print duplicates Objects
list_tte_source_objects

List all tte_source Objects Available in a Package
queries

Queries Dataset
max_cond

Maximum Value on a Subset
list_all_templates

List All Available ADaM Templates
desc

dplyr desc
exprs

rlang exprs
query

Create an query object
records_source

Create a records_source Object
signal_duplicate_records

Signal Duplicate Records
restrict_imputed_dtc_dtm

Restrict Imputed DTC date to Minimum/Maximum Dates
queries_mh

Queries MH Dataset
set_admiral_options

Set the Value of Admiral Options
tte_source

Create a tte_source Object
print_named_list

Print Named List
%>%

Pipe operator
print.source

Print source Objects
slice_derivation

Execute a Derivation with Different Arguments for Subsets of the Input Dataset
death_event

Pre-Defined Time-to-Event Source Objects
negate_vars

Negate List of Variables
restrict_imputed_dtc_dt

Restrict Imputed DTC date to Minimum/Maximum Dates
use_ad_template

Open an ADaM Template Script
restrict_derivation

Execute a Derivation on a Subset of the Input Dataset
yn_to_numeric

Map "Y" and "N" to Numeric Values
atoxgr_criteria_ctcv4

Metadata Holding Grading Criteria for NCI-CTCAEv4
admiral_adlb

Lab Analysis Dataset
admiral_adsl

Subject Level Analysis Dataset
atoxgr_criteria_daids

Metadata Holding Grading Criteria for DAIDs
atoxgr_criteria_ctcv5

Metadata Holding Grading Criteria for NCI-CTCAEv5
admiral-package

admiral: ADaM in R Asset Library
call_user_fun

Calls a Function Provided by the User
assert_parameters_argument

Asserts parameters Argument and Converts to List of Expressions
basket_select

Create a basket_select object
call_derivation

Call a Single Derivation Multiple Times