| name | bio-workflows-clinical-trial-pipeline |
| description | End-to-end clinical trial analysis workflow from CDISC SDTM/ADaM loading through ICH E9(R1) estimand-driven primary analysis to CONSORT 2025 regulatory-compliant reporting. Covers data preparation, FDA 2023 marginal vs conditional logistic regression, categorical tests with Boschloo, modern HTE/subgroup methods, missing-data sensitivity (MMRM, reference-based MI, Permutt tipping point), graphical multiplicity (Bretz-Maurer), survival analysis (Cox/RMST/competing risks) when applicable, and Table 1. Use when performing a complete analysis of clinical trial data. |
| tool_type | python |
| primary_tool | statsmodels |
| workflow | true |
| depends_on | ["clinical-biostatistics/cdisc-data-handling","clinical-biostatistics/logistic-regression","clinical-biostatistics/categorical-tests","clinical-biostatistics/effect-measures","clinical-biostatistics/subgroup-analysis","clinical-biostatistics/trial-reporting","clinical-biostatistics/missing-data-sensitivity","clinical-biostatistics/multiplicity-graphical","clinical-biostatistics/survival-analysis","clinical-biostatistics/power-and-sample-size"] |
| qc_checkpoints | [{"after_estimand_definition":"ICH E9(R1) 5 attributes pre-specified in SAP: treatment, population, endpoint, summary measure, ICE handling strategy"},{"after_data_prep":"One row per USUBJID, no duplicate subjects, treatment arms balanced, DS domain tabulated for dropout patterns by arm"},{"after_primary_analysis":"Model converged, no separation warnings, marginal RD via g-computation reported as primary per FDA 2023; conditional OR as supportive"},{"after_subgroup":"Interaction tests run via single model (not per-subgroup p-comparisons), graphical multiplicity adjustment via gMCP, forest plot generated"},{"after_missing_data":"Per ICH E9(R1) ICE strategy: MMRM/MAR or reference-based MI (J2R/CR/CIR); Permutt tipping-point delta reported in residual SD units"},{"after_reporting":"Table 1 with SMD, missing data per CONSORT 2025 item 21c, harms per item 15, estimand statement per ICH E9(R1)"}] |
Version Compatibility
Reference examples tested with: statsmodels 0.14+, scipy 1.12+, tableone 0.9+, pyreadstat 1.2+, pandas 2.1+, numpy 1.26+, matplotlib 3.8+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package> then help(module.function) to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Clinical Trial Analysis Pipeline
"Analyze my clinical trial data end to end" -> Load CDISC domain tables, prepare a subject-level analysis dataset, run primary statistical models, perform subgroup analyses, and generate regulatory-compliant tables and figures.
Complete workflow for clinical trial statistical analysis from raw data to publication-ready results.
Scientific Reasoning Framework
Before executing any analysis step, establish the causal framework. For an RCT, randomization justifies causal interpretation of the primary analysis, but subgroup analyses and observational comparisons within the trial (e.g., adherence effects) do not inherit this protection. Key decisions requiring scientific judgment at each step: (1) data preparation -- which aggregation strategy matches the estimand, (2) covariate selection -- include confounders and prognostic factors from the SAP, exclude mediators and colliders, (3) subgroup analysis -- test only biologically motivated interactions, (4) missing data -- link DS domain reasons to the assumed mechanism before choosing a method. The workflow below provides the technical steps; the scientific reasoning at each decision point determines whether the results are valid.
Workflow Overview
CDISC Domain Files (DM, AE, EX, LB)
|
v
[1. Data Preparation] ----> Subject-level dataset with outcomes and covariates
|
v
[2. Table 1] ------------> Baseline characteristics by treatment arm
|
v
[3. Primary Analysis] ---> Logistic regression with OR extraction
|
v
[4. Categorical Tests] --> Chi-square / Fisher's exact for key associations
|
v
[5. Subgroup Analysis] --> Interaction terms, stratified ORs, forest plot
|
v
[6. Missing Data] -------> Multiple imputation sensitivity analysis
|
v
Results tables and figures
Step 1: Data Preparation
Goal: Create a single subject-level analysis dataset from CDISC domain tables.
Approach: Load domain files, aggregate event-level data to one row per subject, merge on USUBJID, and code the outcome variable.
import pandas as pd
pyreadstat
dm, _ = pyreadstat.read_xport()
ae, _ = pyreadstat.read_xport()
target_ae = ae[ae[] == ]
severity_map = {: , : , : , : , : }
target_ae[] = target_ae[].(severity_map)
had_event = target_ae.groupby()[].().reset_index()
had_event.columns = [, ]
analysis = dm[[, , , , ]].merge(had_event, on=, how=)
analysis[] = analysis[].notna().astype()
analysis[] = (analysis[] != ).astype()