10 Manuscript Assembly
The sa-manuscript-quarto module generates publication-ready manuscripts from analysis outputs. It builds Table 1 (baseline characteristics), drafts the results section with extracted statistics, and renders the final document via Quarto in both PDF and DOCX formats.
10.1 IMRAD Structure
The generated manuscript follows the standard Introduction-Methods-Results-And-Discussion (IMRAD) format:
05_manuscript/
├── _quarto.yml # Render settings
├── manuscript.qmd # Main Quarto source
├── references.bib # BibTeX bibliography
├── american-medical-association.csl
└── output/
├── manuscript.pdf
└── manuscript.docx
10.2 Table 1 with gtsummary
Script build_table1.R generates a formatted baseline characteristics table:
library(gtsummary)
df |>
select(age, sex, stage, comorbidity, group) |>
tbl_summary(
by = group,
statistic = list(
all_continuous() ~ "{mean} ({sd})",
all_categorical() ~ "{n} ({p}%)"
),
missing = "ifany"
) |>
add_p() |>
add_overall() |>
bold_labels()For observational studies, consider reporting standardised mean differences (SMD) instead of p-values in Table 1, as balance metrics are more informative than hypothesis tests for baseline comparisons.
10.3 Auto-Generated Results Draft
Script build_results_section.R extracts key statistics from the analysis outputs and generates a prose draft:
- Sample size and follow-up duration
- Event counts and rates
- Hazard ratios with 95% CI
- Model diagnostics summary
- Key figure references
This draft is embedded as a child document in the main manuscript.qmd.
10.4 AMA Citation Style
The pipeline uses the American Medical Association citation style. References are stored in references.bib and formatted via american-medical-association.csl:
# In _quarto.yml
bibliography: references.bib
csl: american-medical-association.cslInline citations use the standard Quarto syntax: [@cox1972] renders as a superscript number.
10.5 Rendering
# Build Table 1 and results section
make manuscript PROJECT=my-study
# Render to PDF + DOCX
make render PROJECT=my-studyPDF rendering requires a LaTeX distribution. Install TinyTeX with quarto install tinytex if PDF output fails.
10.6 Output
The rendered manuscript appears in projects/<name>/05_manuscript/output/ as both manuscript.pdf and manuscript.docx.