Clinical Trial Telemetry Aggregation and Summary Statistics Script Generator
Create an automated R statistical reporting script to process laboratory trial telemetry and generate publication-grade summary tables.
Use this template when preparing reproducible statistical batch reports from clinical or laboratory research data. It generates an end-to-end analysis script calculating cohort variance and endpoint metrics.
Role: Lead Research Informatics Engineer specializing in reproducible biostatistical reporting scripts.
Context
- Study identifier: {{trial_phase_name}}
- Raw data format: {{telemetry_data_schema}}
- Key endpoint: {{primary_endpoint_metric}}
- Comparison grouping: {{cohort_grouping_factor}}
- Significance threshold: {{statistical_significance_cutoff}}
- Export file format: {{export_file_format}}
Task
Generate a complete, fully documented R statistical script that ingests experimental trial telemetry, validates data integrity, computes baseline demographic and endpoint statistical aggregations across study arms, conducts significance tests, and exports publication-ready summary tables.
Method
- Load raw study logs matching {{telemetry_data_schema}} using tidyverse and data.table conventions.
- Filter observation records applicable strictly to {{trial_phase_name}} while stripping incomplete patient runs.
- Compute central tendency metrics (mean, median, standard deviation, IQR) for {{primary_endpoint_metric}}.
- Stratify statistical summaries across cohorts defined by {{cohort_grouping_factor}}.
- Execute two-tailed hypothesis testing evaluating cohort separation against {{statistical_significance_cutoff}}.
- Construct formatted output tables adhering to clinical summary standards (including sample size, effect sizes, and p-values).
- Write the finalized summary datasets to disk matching {{export_file_format}} specifications.
Constraints
- Code MUST be written in modern R (v4.2+) utilizing tidyverse packages (dplyr, tidyr, readr).
- MUST NOT modify or overwrite raw primary telemetry source files.
- MUST explicitly set random seeds for any resampling or non-parametric statistical methods used.
- Output table column headers must be sanitized for human-readable scientific publication.
Output format
Provide the generated deliverable in these designated sections:
- Pipeline Metadata (bulleted list of required R packages, environment assumptions, and input paths).
- Complete R Analysis Script (single executable R script structured with explicit headers, transformation functions, and export routines).
- Sample Output Table Preview (ASCII or Markdown representation of the resulting summary report).
Self-review
- Ensure the statistical tests applied are appropriate for the data types implied in {{primary_endpoint_metric}}.
- Verify all 6 variables are referenced within the R script parameters or data load blocks.
- Confirm reproducible seed management and file output paths are implemented without syntax errors.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.