biocohort biocohort hex logo

R-CMD-check r-universe DOI

biocohort keeps the subjects, samples, and analysis outputs of a study in one validated object. Species and assays are values in the data, not columns or classes, so the same functions work for any organism and any omics assay.

See the repository root README for the motivation behind this package.

Installation

pak::pak("samuelbharti/biocohort/pkg-r")

r-universe works too:

install.packages("biocohort", repos = "https://samuelbharti.r-universe.dev")

Quick start

A manifest is one long-format table, one row per sample. Four columns carry the shape of the study: subject_id, assay, sample_id, role. Every other column is metadata.

subject_id,species,genotype,assay,sample_id,role
R1,rat,WT,wes,T1,tumor
R1,rat,WT,wes,N1,normal
R2,rat,KO,wes,T2,tumor
R2,rat,KO,wes,N2,normal
library(biocohort)

parsed <- read_manifest("manifest.csv")
cohort <- cohort_new(parsed$subject_tbl, parsed$sample_map)
cohort
#> ── Cohort
#> • 2 subjects (2 rat)
#> • 4 samples (4 wes)

subjects(cohort)
samples(cohort, assay = "wes")
completeness(cohort, wide = TRUE)

Some studies keep one row per subject, with one id column per assay. manifest_from_wide() turns that into the long form first:

id_cols <- data.frame(
  column = c("wes_tumor_id", "wes_normal_id"),
  assay = c("wes", "wes"),
  role = c("tumor", "normal")
)
long <- manifest_from_wide(wide_table, id_cols)

What it does

Documentation

The package website includes:

To build the site locally, run from the repository root:

pkgdown::build_site("pkg-r")

Contributing

See CONTRIBUTING.md for the development workflow.

License

MIT