Skip to contents

Pipeline

Main preprocessing pipeline and configuration

run_preprocess()
AMR Data Preprocessing Pipeline
amr_config()
Create AMR Preprocessing Configuration
validate_config()
Validate AMR Configuration
print(<amr_config>)
Print AMR Configuration
print(<amr_result>)
Print Method for AMR Preprocessing Results
summary(<amr_result>)
Summary Method for AMR Preprocessing Results
print(<amr_preprocessing_report>)
Print Preprocessing Report
detect_preprocessing_capabilities()
Detect Preprocessing Capabilities
prep_report_capabilities()
Report Preprocessing Capabilities

Standardization

Standardize column names, organisms, antibiotics, specimens, and values

prep_standardize_column_names()
Standardize Column Names to Package Convention
prep_standardize_organisms()
Normalize Organism Names
prep_standardize_antibiotics()
Normalize Antibiotic Names
prep_standardize_specimens()
Normalize Specimen/Sample Type
prep_standardize_sex()
Standardize Sex Values
prep_standardize_outcome()
Standardize Outcome Values (deprecated)
prep_clean_ast_values()
Clean Antibiotic Susceptibility Values
prep_recode_intermediate_ast()
Recode Intermediate (I) Susceptibility Values
prep_parse_date_column()
Detect and decode encrypted or non-standard date columns
prep_coerce_dates()
Detect and convert all date-like columns in a table
prep_standardize_final_outcome()
Standardize Final Outcome Column
prep_standardize_infection_type()
Standardize Infection Type Column
prep_harmonize_ast()
Harmonize AST Values
prep_flag_invalid_ast()
Flag Invalid AST Values
prep_decode_antibiotic_code()
Decode Antibiotic Short Codes to Full Names

Classification

MDR/XDR classification, organism grouping, AWaRe, and mortality

prep_classify_mdr_xdr()
Classify MDR and XDR
prep_assign_organism_group()
Assign Organism Group
prep_classify_antibiotic_class()
Classify Antibiotic to WHO Class
prep_classify_aware()
Classify AWaRe Category
prep_classify_mortality()
Classify Infection-Related Mortality
prep_derive_hai_cai()
Derive HAI/CAI Infection Type
prep_extract_genus()
Extract Genus from Organism Name
prep_extract_species()
Extract Species from Organism Name
prep_classify_readmission()
Classify Readmission Type
prep_flag_organism_unmatched()
Flag Organisms Unmatched in Reference

Enrichment

Derive missing variables from existing data

prep_fill_age()
Fill Missing Age Values
prep_assign_age_bins()
Assign Age Bins
prep_infer_department()
Infer Hospital Department
prep_clean_optional_columns()
Clean Optional Columns
prep_derive_los_from_dates()
Derive Length of Stay from Date Columns
prep_derive_icu_flag()
Derive ICU Flag
prep_derive_dob_from_components()
Derive Date of Birth from Age Components
prep_flag_hai_inferred()
Flag HAI Inferred vs Observed
prep_reconcile_hai_observed_inferred()
Reconcile Observed and Inferred HAI/CAI Classification

Deduplication and collapsing

Event IDs, deduplication, contaminant flagging, and data reshaping

prep_create_event_ids()
Create Event IDs from Patient-Level Data
prep_deduplicate_events()
Deduplicate Events
prep_flag_contaminants()
Flag Contaminant Organisms
prep_get_contaminant_list()
Get Contaminant List from Reference File
prep_is_contaminant()
Check if Organism is a Contaminant
prep_flag_polymicrobial() flag_polymicrobial()
Flag Polymicrobial Infections
prep_compute_poly_weights() compute_polymicrobial_weight()
Compute Polymicrobial Weights
prep_collapse_class_level()
Collapse to Class Level
prep_pivot_ast_wide_to_long()
Convert Wide Format to Long Format
prep_create_wide_ast_matrix()
Create Wide Format AST Matrix
prep_create_resistance_profile()
Create Resistance Profile
prep_filter_analysis_ready()
Filter Analysis-Ready Records
prep_deduplicate_ast()
Handle Duplicate AST Results
prep_split_poly_episode()
Split Polymicrobial Episodes by Strategy
prep_flag_readmission()
Flag and Classify Readmissions
prep_filter_fungal()
Filter Fungal Organisms
prep_filter_minimally_usable()
Filter Minimally Usable Records

Multi-centre stewardship import

Joining and validating ICMR multi-centre stewardship datasets

prep_check_columns()
Check required columns exist and report types
prep_check_keys()
Check join key quality
prep_validate_table()
Run all pre-join sanity checks for one table
prep_detect_schema_drift()
Detect Schema Drift Across Centres
prep_apply_column_map()
Apply Column Map to Rename Columns
prep_assert_standard_names()
Assert Standard Names Are Present
prep_build_column_map()
Build and Validate a Column Map Against a Dataset

Diagnosis and syndrome mapping

Map free-text diagnoses to ICD-10 codes and clinical syndromes

prep_map_diagnosis_to_icd()
Map Diagnosis Text to ICD Candidates
prep_map_icd_to_syndrome()
Map ICD Codes to Infectious Syndromes
prep_diagnosis_text()
Prepare Diagnosis Text
prep_assign_patient_syndrome()
Assign One Syndrome Per Patient or Event
infer_patient_syndrome_wide()
Assign Syndrome from Wide-Format Syndrome Flags

Outcome cohorts and attrition

Build outcome cohorts and track patient counts through pipeline stages

prep_attrition_flow()
Track Attrition Through the Pipeline
prep_build_fatal_cohort()
Build Fatal Cohort
prep_build_nonfatal_cohort()
Build Non-Fatal Cohort

Resistance profiles

Marginal resistance, co-resistance, and profile computation

compute_marginal_resistance()
Compute Marginal Resistance per Pathogen and Antibiotic Class
compute_pairwise_coresistance()
Compute Pairwise Co-resistance Matrices per Pathogen
compute_resistance_profiles()
Compute Resistance Profile Probabilities per Pathogen
select_resistance_class()
Select Resistance Class for Burden Attribution

Burden estimation (YLL/YLD/DALY)

GBD-methodology burden calculations

daly_add_rr_mappings()
Add RR Pathogen and Drug Mappings
daly_assign_rr_to_profiles()
Assign Per-Class LOS RR to Resistance Profiles (Max Rule)
daly_calc_case_fatality()
Calculate case fatality ratio by syndrome and pathogen (CFR_{Lk})
daly_calc_cr_l()
Calculate the CFR adjustment factor (CR_L)
daly_calc_deaths_by_cause()
Calculate Deaths by Underlying Cause (D_J)
daly_calc_deaths_by_syndrome()
Calculate Deaths by Infectious Syndrome (D_L)
daly_calc_fraction_associated_yld()
Compute Associated-Burden Fractions per Resistance Profile
daly_calc_incidence_from_cfr()
Calculate syndrome incidence from deaths, CFR, and CR_L (formula-based)
daly_calc_infection_fraction()
Calculate Infection Fraction of Deaths by Cause (S_J)
daly_calc_paf_los()
Compute PAF for length of stay per resistance profile
daly_calc_paf_mortality()
Compute Mortality Population Attributable Fraction per Resistance Profile
daly_calc_pathogen_fraction_fatal()
Calculate fatal pathogen distribution (P_{Lk})
daly_calc_syndrome_fraction()
Calculate Infectious Syndrome Fraction (M_LJ)
daly_calc_yld_attributable()
Compute YLDs Attributable to Resistance
daly_calc_yll_associated()
Compute YLL Associated with AMR (Patient-Level, Facility-Direct)
daly_calc_yll_attributable()
Compute YLL Attributable to AMR
daly_compute_patient_los()
Compute Patient-Level Post-Infection LOS
daly_count_incident_cases()
Count incident cases by syndrome from facility data
daly_derive_hai_cai_for_los()
Derive Infection Type (HAI / CAI) per Patient
daly_derive_hai_cai_for_mortality()
Classify HAI/CAI Infection Type for the Mortality Cohort
daly_fit_los_rr()
Fit relative LOS using Gamma GLM with log link
daly_fit_los_rr_distribution()
Estimate Per-Class LOS Relative Risk via Parametric Distribution Fitting
daly_fit_mortality_rr()
Fit mortality model and derive adjusted relative risk of death
daly_get_top_pathogens()
Identify top N pathogens by occurrence
daly_load_rr_reference()
Load RR (Relative Risk) Reference Data
daly_lookup_rr()
Lookup Relative Risk Values
daly_map_rr_drug_class()
Map Antibiotic Class to RR Drug Category
daly_map_rr_pathogen()
Map Organism to RR Pathogen Category
compute_hospital_daly()
Compute Hospital-Level DALY Breakdown

LOS modeling

Length-of-stay distribution fitting and comparison

safe_fit()
Safely Fit a Distribution
fit_distributions()
Fit Multiple Distributions
compare_distribution_aic()
Compare Distribution Fits by AIC
summarise_distribution()
Summarise a Fitted Distribution
plot_los_distributions()
Plot LOS Distribution with Fitted Overlays
prepare_los_data()
Prepare LOS Dataset
get_los_by_resistance()
Extract LOS Vectors by Resistance Status

Burden plots

Hospital-level and organism-level burden visualizations

plot_burden_by_hospital()
Plot YLL or YLD Associated vs Attributable per Hospital
plot_burden_by_organism()
Plot YLL or YLD Associated vs Attributable by Organism
plot_yll_heatmap()
Heatmap of YLL per 1 000 Admissions by Resistance Class and Pathogen Group
plot_yld_heatmap()
Heatmap of YLD per 1 000 Admissions by Organism Group

EDA plots

Exploratory plots for AMR surveillance data

plot_top_organisms()
Plot Top Pathogens by Unique Patients
plot_abx_susceptibility()
Plot Antibiotic Susceptibility Pattern (Stacked R/S Bars)
plot_abx_heatmap()
Plot Antibiotic Resistance Heatmap
plot_outcome_distribution()
Plot Distribution of Final Outcomes
plot_outcome_by_organism()
Plot Final Outcome Proportions for Resistant or Susceptible Patients
plot_death_discharged()
Plot Death vs Discharged Counts for Top Pathogens
plot_resistance_by_sample()
Plot Distribution of Antibiotic Resistance Across Sample Types
plot_outcome_by_agebin()
Plot Final Outcome Proportions by Age Bin
plot_mono_poly_by_facility()
Plot Mono vs Polymicrobial Infections by Facility
plot_hai_cai_by_facility()
Plot HAI vs CAI Infection Distribution by Facility
plot_location_by_facility()
Plot Patient Distribution by Location Type Across Facilities
plot_los_ridge()
Ridge / Density Plot of Length of Stay (LOS)
plot_age_ridge()
Ridge / Density Plot of Patient Age
plot_los_by_agebin()
Boxplot of Length of Stay by Age Group
plot_outcome_by_year()
Plot Distribution of Final Outcomes by Year
plot_patients_by_hospital()
Plot Unique Patient Count by Hospital
plot_syndrome_distribution()
Plot Syndrome Distribution
plot_resistance_by_agebin()
Resistance proportion by age group
plot_resistance_by_organism()
Resistance proportion for top N organisms

Visualization

Generic AMR plotting utilities

amr_theme()
AMR Theme for ggplot2
eda_theme()
EDA ggplot2 Theme
get_amr_palette()
Get Color Palette
plot_bar()
Generic Bar Plot
plot_grouped_bar()
Grouped (Dodged) Bar Plot
plot_stacked_bar()
Stacked Bar Plot
plot_heatmap()
Heatmap
plot_histogram()
Histogram
plot_line()
Line Chart
plot_proportion()
Proportion Bar Plot
plot_resistance_heatmap()
Resistance Pattern Heatmap

Spatial analysis

Spatial metrics and mapping

create_spatial_object()
Create Spatial Object from AMR Data
create_choropleth_map()
Create Choropleth Map
create_interactive_map()
Create Interactive Leaflet Map
calculate_spatial_metrics()
Calculate AMR Metrics by Geographic Unit
calculate_spatial_autocorrelation()
Calculate Spatial Autocorrelation (Moran's I)
calculate_distance_matrix()
Calculate Distance Matrix Between Locations
detect_hotspots()
Detect Spatial Hotspots (Getis-Ord Gi*)

Validation and reporting

Data quality checks and reports

validate_data_quality()
Validate Data Quality
validate_required_fields()
Validate required fields exist and meet completeness threshold
summarize_column_mapping()
Summarize Column Mapping
summarize_data_quality()
Summarize Data Quality
summarize_raw_data()
Summarize Raw Data
summarize_transformations()
Summarize Data Transformations
compute_processing_statistics()
Compute Processing Statistics
generate_preprocessing_report()
Generate Preprocessing Report
export_report()
Export Report to File
prep_check_organism_ast_consistency()
Check Organism-AST Consistency
prep_validate_analysis_ready()
Validate Analysis-Ready Dataset
prep_validate_date_logic()
Validate Date Logic
prep_missingness_report()
Missingness Report

Utilities

Helper functions

round_to_sum()
Largest-Remainder Rounding
shorten_drug_class()
Shorten Antibiotic Class Names
default_column_mappings
Default column name mappings for fuzzy matching
get_age_bins()
Get Age Bin Labels
prep_inventory_columns()
Inventory Columns
prep_log_source()
Log Data Source Provenance