Reads a study, its manifest, its file paths, and its registered analyses
from one YAML file, and returns a ready-to-use Cohort. This turns the
handful of calls a study's setup script usually makes (study_new(),
read_manifest(), cohort_new(), one analysis_spec_new() per analysis)
into one function call and one file to edit.
Value
A Cohort built from the file.
Details
The file has these top-level keys, all optional except manifest:
study: fields forstudy_new()(study_id,title,description,hypotheses,aims,assays,genome_builds,tags).manifest: path to the manifest file, read withread_manifest(). Required.sample_cols: extra sample-level columns, passed tovalidate_manifest().species: fills aspeciescolumn when the manifest has none.paths: a map of root name to path, stored ascohort@paths.corrections: path to a corrections file, applied to the manifest withapply_corrections()before it is validated.analyses: a list ofanalysis_spec_new()field sets, one per registered analysis.
Every path (manifest, an entry of paths, corrections) is resolved
relative to the YAML file's own directory unless it is already absolute.
Examples
dir <- tempfile()
dir.create(dir)
writeLines(
c(
"subject_id,species,assay,sample_id,role",
"R1,rat,wes,T1,tumor",
"R1,rat,wes,N1,normal"
),
file.path(dir, "manifest.csv")
)
writeLines(
c(
"study:",
" study_id: PILOT",
" title: Example pilot",
"manifest: manifest.csv"
),
file.path(dir, "study.yaml")
)
cohort <- read_study_yaml(file.path(dir, "study.yaml"))
cohort
#>
#> ── Cohort: Example pilot
#> • 1 subject (1 rat)
#> • 2 samples (2 wes)