The inverse of read_study_yaml(): writes the cohort's study metadata,
its manifest, its paths, its registered analysis specs, and its logs to a
study YAML file, with the manifest and the logs as CSV files.
Arguments
- cohort
A Cohort object.
- path
Output path for the study YAML file.
- manifest
Path for the manifest file, resolved relative to
path's directory unless absolute. Default"manifest.csv".
Details
A cohort has no stored corrections file, so a corrections: key is never
written; the manifest written out already reflects any correction that
was applied before the cohort was built.
Each log that has rows is written next to the manifest, as
qc_log.csv, derive_log.csv, and corrections_log.csv, and listed
under a logs: key. A time is written in UTC, such as
2026-09-29T21:19:07Z, and the cutoffs of a derived column as
young=0|old=40. Text files keep the record readable in a diff and from
other languages. cohort_save() keeps the same logs in a binary file.
Examples
data(example_cohort)
dir <- tempfile()
dir.create(dir)
write_study_yaml(example_cohort, file.path(dir, "study.yaml"))
cat(readLines(file.path(dir, "study.yaml")), sep = "\n")
#> manifest: manifest.csv
#> study:
#> study_id: STUDY001
#> title: Cross-species genomics comparison
#> description: Example study comparing rat and mouse genomes
#> hypotheses:
#> - Orthologous genes show conserved expression patterns
#> - Species-specific variants drive phenotypic differences
#> aims:
#> - Map rat genes to mouse orthologs
#> - Identify conserved regulatory regions
#> assays:
#> - WES
#> - snRNA-seq
#> genome_builds:
#> rat: rn7
#> mouse: mm10
#> human: hg38
#> sample_cols:
#> - fastq_1
#> - fastq_2