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. For several files, a list of entries, each with apathand an optionalassaythat fills theassaycolumn of a file that has none. The files are stacked asread_manifest()stacks them.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.logs: a map with up to three keys,qc,derive, andcorrections, each the path of a CSV file thatwrite_study_yaml()wrote. They fillqc_log(),derive_log(), andcorrections_log().
Every path (manifest, an entry of paths, corrections, an entry of
logs) is resolved relative to the YAML file's own directory unless it is
already absolute.
The audit of a corrections file is kept in the cohort, after the audit
read from logs, so corrections_log() shows both.
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)