R/Pharma 2026 Workshop
2026-09-28
The views and opinions expressed in this presentation are those of the individual presenters and do not represent those of their affiliated organizations or institutions.
R/Pharma organizers
Team members from Meta Platforms and Merck & Co., Inc., Rahway, NJ, USA
Contributors of pycsr and r4csr training materials
rtflite provides Python classes RTFDocument that map to table elements. The goal is to help you translate data frame to tables in RTF file.
rtflite
A Python package designed specifically to organize analysis scripts and code for a clinical trial project.
Purpose:
Our primary focus is creating a standard folder structure to organize the project, with 3 goals in mind:
Combines:
demo-py-esub/
├── pyproject.toml # Project metadata
├── .python-version # Python version
├── uv.lock # Locked dependencies
├── src/demo001/ # Study-specific code
│ ├── __init__.py
│ └── utils.py
├── analysis/ # Quarto analysis docs
│ └── tlf-*.qmd
├── data/ # ADaM datasets
├── output/ # Generated TLFs
└── tests/ # Validation tests
Consistency
Reproducibility
uv.lock pins dependencies.python-version specifies PythonAutomation
uv sync restores environmentquarto render generates outputspytest validates codeCompliance
Core principle: All project assets in version control.
Plain text workflow:
.qmd files for analysis (not .ipynb for final deliverables).md files for documentation.toml files for configuration.xlsx files for trackingProject tracking:
Planning:
Development:
analysis/ and src/Validation:
tests/ruff, mypy, pytest)Delivery:
quarto renderFDA Study Data Technical Conformance Guide Section 4.1.2.10:
Submit programs for primary and secondary efficacy analyses. Specify software in ADRG. Use ASCII text format. No executable extensions.
Goal: Enable reviewers to understand and confirm analysis algorithms.
Analysis package: https://github.com/elong0527/demo-py-esub
Submission package: https://github.com/elong0527/demo-py-ectd
Clone and explore to see complete examples.
m5/datasets/<study-id>/analysis/adam/
├── datasets/
│ ├── *.xpt # ADaM datasets
│ ├── define.xml
│ ├── adrg.pdf # Instructions
│ └── analysis-results-metadata.pdf
└── programs/
├── py0pkgs.txt # Packed Python package
├── tlf-01-*.txt # Analysis programs
└── tlf-02-*.txt
Key: All files in programs/ must be ASCII text.
Packs Python projects into portable text files.
Why needed:
pkglite capabilities:
.txt fileDocumentation: https://pharmaverse.github.io/py-pkglite/
1. Create .pkgliteignore
2. Pack the package
3. Convert Quarto to Python scripts
.qmd -> verify it works.qmd -> .ipynb -> .pyruff.txt (no .py extension)Human-readable Debian Control File (DCF) format:
# Generated by py-pkglite
# Use `pkglite unpack` to restore
Package: demo-py-esub
File: pyproject.toml
Format: text
Content:
[project]
name = "demo001"
version = "0.1.0"
...
Reviewers can read without special tools.
Document the Python environment:
Python environment:
| Software | Version | Description |
|---|---|---|
| Python | 3.14.0 | Programming language |
| uv | 0.9.9 | Package manager |
Packages:
| Package | Version | Description |
|---|---|---|
| polars | 1.35.1 | Data manipulation |
| rtflite | 1.1.0 | RTF generation |
| demo001 | 0.1.0 | Study functions |
Appendix: Step-by-step reproduction instructions.
Essential: Simulate reviewer experience before submission.
Workflow:
uvx pkglite unpack programs/py0pkgs.txt -o .cd demo-py-esub && uv syncpython ../programs/tlf-*.txtCatches: Missing dependencies, path errors, platform issues.
Regulatory:
Technical: