biocohort: Subject and Sample Rosters for Omics Studies
Source:R/biocohort-package.R
biocohort-package.Rdbiocohort keeps the subjects, samples, and analysis outputs of a study in
one validated object, called a Cohort. Species and assays are values in
the data, not columns or classes, so the same functions work for a rat
exome study, a mouse single-cell study, a proteomics study, or any other
organism and assay.
From a manifest to a cohort
read_manifest()reads a manifest from CSV, TSV, or Excel and returnssubject_tblandsample_map.manifest_from_wide()reshapes a wide, one-row-per-subject table into the long form first.validate_manifest()does the actual checking: it coerces every column to character, fills inroleandspecieswhere they are missing, and splits subject-level columns from sample-level ones.cohort_new()builds aCohortfrom validated tables.study_new()attaches optional project metadata (title, aims, genome builds).
Reading a cohort
subjects(),samples(), andcompleteness()return plain tibbles.subject()reads one subject as aSubjectobject.cohort_filter()keeps a subset of subjects or assays and returns a cohort that is still valid.sample_pairs()derives tumor and normal pairs fromsample_mapon demand, with configurable role labels.
Quality control, groups, and derived columns
cohort_qc()flags or drops subjects or samples, with a required reason.qc_log()reads the audit trail every call appends to the cohort, which survives latercohort_filter()calls.cohort_groups()groups a cohort's subjects by one or more columns.cohort_contrasts()enumerates every pairwise contrast between those groups, ready to filter one side against the other.cohort_derive()bins an existing numeric column at named cutoffs and writes the result as a new column, so a cutoff is a value passed in, not code.derive_log()reads its provenance.
Writing files for other tools
sample_sheet()writes the sample list a pipeline expects, with built-in templates for a few common nf-core pipelines.check_paths()tests that the file paths named in a cohort exist.as_coldata()andjoin_metadata()carry cohort metadata into aSummarizedExperiment, a Seurat object, or a plain data frame.write_manifest(),cohort_save(), andcohort_read()keep a cohort as a file in a project instead of a script that rebuilds it each time.
Analysis outputs
analysis_spec_new()andanalysis_register()describe where an analysis writes its output and how to read it back.load_analysis()andload_analyses()resolve the path for every subject or pair, read the files, and record which ones were found.
Cross-species translation
translate()moves a feature table across genome builds or species. Coordinate features go through a liftover backend (liftover_intervals()). Gene features go through an ortholog backend (ortholog_genes()). Both kinds of backend are pluggable throughregister_liftover_backend()andregister_ortholog_backend().
Configuration
read_study_yaml()builds a cohort from one YAML file that names the study, the manifest, the file paths, and the registered analyses.write_study_yaml()writes one back.apply_corrections()andread_corrections()apply documented overrides to a manifest and keep an audit trail.
Data tables
subject_tbl: one row per subject. Always hassubject_idandspecies, plus any other subject-level metadata (sex,genotype,strain, ...).sample_map: one row per sample, in long format. Always hassubject_id,assay,sample_id, androle. A new assay is a new row, never a new column.completeness_tbl: one row persubject_idandassaypair, with the sample count.
Further reading
Three articles ship with the package.
vignette("biocohort", package = "biocohort") walks through a manifest,
a cohort, and a sample sheet end to end.
vignette("glossary", package = "biocohort") defines the terms used
across the package.
vignette("naming-conventions", package = "biocohort") lists the
standard names for columns, objects, and files.
Author
Maintainer: Samuel Bharti samuelbharti.io@gmail.com (ORCID) [copyright holder]
Authors:
Samuel Bharti samuelbharti.io@gmail.com (ORCID) [copyright holder]
Other contributors:
Barret Schloerke barret@posit.co (ORCID) [thesis advisor]
Carson Sievert carson@posit.co (ORCID) [thesis advisor]
Posit Software, PBC (ROR) [copyright holder, funder]