Skip to main content

📊 adamstat

Python Package CDISC Standards ICH Guidelines License: MIT Tests

Production-grade CDISC SDTM, ADaM, Biostatistics, and Clinical Study Reporting (CSR) Toolkit in Python.

adamstat is a complete clinical trial data analytics package that bridges raw electronic data capture (EDC) or clinical trial CSV records to regulatory-compliant CDISC SDTM domains, ADaM analysis datasets (ADSL, BDS, OCCDS), inferential biostatistical testing, and ICH E3 compliant Tables, Figures, and Listings (TFLs).


🌟 Key Capabilities

  • Clinical EDA & Descriptive Profiling: Multi-column descriptive statistics (mean, SD, median, IQR, quantiles), missingness matrix audits, and categorical demographic breakdown.
  • Data Cleaning & Harmonization: Standardizing case and whitespace anomalies in SEX and ARM, biometric outlier isolation (AGE, BMI), date parsing to ISO 8601 (YYYY-MM-DD), deduplication, and baseline feature median array imputations.
  • Clinical Derivations: ACC/AHA blood pressure categorization, WHO BMI classification, protocol age group stratification, days on study follow-up calculation, and multisystem high-risk flags.
  • CDISC SDTM Standardization: Built-in mapping and validation engines for DM (Demographics), VS (Vital Signs), LB (Laboratory), AE (Adverse Events), and EX (Exposure) domains with sequence numbering and ISO date formats.
  • CDISC ADaM Model Generation:
    • ADSL (Subject-Level Analysis Dataset) with trial population flags (SAFFL, ITTFL, EFFFL), baseline vital signs, and exposure metrics.
    • ADVS & ADLB (Basic Data Structure - BDS) with AVAL, BASE, CHG (change from baseline), PCHG (% change), and protocol responder criteria.
    • ADAE (Occurrence Data Structure - OCCDS) with mapped numeric severity (AESEVN) and causality (AERELN).
  • Biostatistics & Inferential Testing: Independent and paired two-sample t-tests, Cohen's d effect sizes, One-way ANOVA, post-hoc Tukey HSD pairwise comparisons, Shapiro-Wilk normality testing, Levene's test for equality of variance, and Pearson Chi-Square tests for adverse event incidence.
  • ICH E3 Clinical Study Reporting (CSR):
    • Table 14.1.1: Demographic and Baseline Characteristics.
    • Table 14.2.1: Primary and Secondary Efficacy Endpoints with 95% Confidence Intervals and treatment differences vs Placebo.
    • Table 14.3.1: Adverse Events Summary by Severity and Preferred Term.
    • Figure 14.2.1: Boxplot of Change from Baseline by Treatment Arm.
    • Figure 14.2.2: Forest Plot of Treatment Differences with 95% Confidence Intervals.
    • Narratives: Automated regulatory result summaries for CSR Section 11/12.

📦 Installation

Install adamstat locally in editable/development mode:

git clone https://github.com/VSRAJHAVEL/adamstat.git
cd adamstat
pip install -e .

Or install with test dependencies:

pip install -e ".[dev]"

🚀 Quickstart Example

import adamstat as ads

# 1. Load sample clinical trial data
trial_data = ads.load_sample_clinical_trial()

# 2. Clean and standardize the dataset
cleaner = ads.ClinicalDataCleaner()
clean_data = cleaner.fit_transform(trial_data)

# 3. Derive clinical categories (BP, BMI, Age groups, Risk flags)
derived_data = ads.derive_clinical_features(clean_data)

# 4. Generate CDISC SDTM Demographics (DM)
dm = ads.create_dm(derived_data, study_id="CT01")

# 5. Generate CDISC ADaM Subject-Level Analysis Dataset (ADSL)
adsl = ads.create_adsl(dm)

# 6. Generate ICH E3 Table 14.1.1 (Demographics)
table_14_1_1 = ads.generate_table_14_1_1_demographics(adsl)
print(table_14_1_1.to_string(index=False))

🔬 End-to-End Pipeline

Execute the full ingestion to CSR reporting workflow in a single call:

from adamstat import ClinicalStudyPipeline, generate_synthetic_clinical_trial

# Generate or load clinical trial dataset
study_data = generate_synthetic_clinical_trial(n_subjects=180)

# Initialize pipeline
pipeline = ClinicalStudyPipeline(study_id="CT01", placebo_arm="Placebo")

# Run pipeline
results = pipeline.run(
    trial_df=study_data["clinical_trial"],
    vs_long=study_data["vs_long"],
    ae_df=study_data["adverse_events"]
)

# Inspect generated ADaM datasets and CSR tables
print("ADSL shape:", results["adam_datasets"]["ADSL"].shape)
print("ADVS shape:", results["adam_datasets"]["ADVS"].shape)
print("CSR Demographics Table:\n", results["tables"]["Table_14_1_1"])
print("CSR Narrative:\n", results["narrative"])

💻 Command Line Interface (CLI)

adamstat includes a full CLI for executing clinical data workflows directly from the terminal:

# 1. Generate descriptive profiling & completeness audit
adamstat eda clinical_raw.csv -o eda_summary.csv

# 2. Clean, deduplicate, and impute raw clinical data
adamstat clean clinical_raw.csv -o clinical_clean.csv

# 3. Derive clinical parameters
adamstat derive clinical_clean.csv -o clinical_derived.csv

# 4. Run inferential biostatistical tests (t-tests, ANOVA)
adamstat stats clinical_analysis.csv --endpoints SBP_CHG DBP_CHG GLU_CHG --arm-col ARM --placebo Placebo

🧪 Running Unit Tests

Run the test suite with pytest:

python -m pytest tests -v

📂 Laboratory Experiments & Code Mapping

This repository consolidates the laboratory experiments:

Lab / Module Topic / Focus Core Implementation
Lab 01 Clinical Data Exploration & Descriptive Profiling adamstat.eda (clinical_summary, completeness_audit, categorical_profiles)
Lab 02 Clinical Data Cleaning, Imputation & Deduplication adamstat.cleaning (ClinicalDataCleaner, standardize_demographics, impute_clinical_data)
Lab 03 Clinical Feature Derivations & Risk Stratification adamstat.derivation (derive_age_group, derive_bp_category, derive_high_risk_flag)
Lab 04 Clinical Biomarker Visualizations adamstat.visualization (plot_demographics, plot_vitals_scatter, plot_treatment_boxplots)
Lab 05 CDISC SDTM Domain Generation (DM, VS, LB, AE, EX) adamstat.sdtm (create_dm, create_vs, create_lb, create_ae, create_ex, validate_sdtm_domain)
Lab 06 CDISC ADaM Datasets (ADSL, BDS, OCCDS) adamstat.adam (create_adsl, create_advs, create_adlb, create_adae, validate_adam)
Lab 07 Biostatistics & Hypothesis Testing adamstat.stats (two_sample_ttest, oneway_anova, posthoc_tukey, ae_contingency_test)
Lab 08 ICH E3 Clinical Study Report (CSR) Tables & Figures adamstat.reporting (generate_table_14_1_1, generate_table_14_2_1, plot_figure_14_2_2_forest)

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for adamstat 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adamstat 1.0.3
File Size Uploaded Provenance Actions
adamstat-1.0.3.tar.gz 59.7 kB Without provenance Details for adamstat-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adamstat 1.0.3
File Interpreter ABI Platform Actions
adamstat-1.0.3-py3-none-any.whl Python 3 none any Details for adamstat-1.0.3-py3-none-any.whl

Total release size: 120.9 kB

Release files / adamstat-1.0.3.tar.gz

Download URL adamstat-1.0.3.tar.gz
Size 59.7 kB
Tags Source
SHA-256 checksum
How to use checksums
22851c9e27f90f4d52d2b921649ad4d990f86ce24a4c42b09ef9bd63418f37e3
BLAKE2b-256 checksum
How to use checksums
0287b9733f2d59b88557e69dbac129110e31ae16ce17e2f02451af0d6f1571c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / adamstat-1.0.3-py3-none-any.whl

Download URL adamstat-1.0.3-py3-none-any.whl
Size 61.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e996fef623ecf0486f8b1a863c3a6028d9d29883005bcbfa10dd6c94d8ec92d2
BLAKE2b-256 checksum
How to use checksums
a43a83ba84ee511173a6114d85ef3103efc550ae932e9a15f368a0c1f35a16f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for adamstat 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page