Registers an AnalysisSpec in a Cohort's registry, enabling standardized access and discovery of analysis specifications. Returns a new Cohort object with the spec added (immutable update pattern).
Value
A new Cohort object with the spec added to the registry. If a spec with the same name already exists, it is replaced. Note that this follows the immutable S7 pattern: the original cohort is not modified.
See also
analysis_spec_new() for creating specs,
analysis_list() for listing registered specs,
analysis_spec() for retrieving a spec from registry
Examples
# Create a cohort
study <- study_new(study_id = "STUDY001", title = "My Study")
manifest <- data.frame(
subject_id = c("S1", "S1", "S2", "S2"),
species = c("rat", "rat", "rat", "rat"),
assay = c("wes", "wes", "wes", "wes"),
sample_id = c("WES_T1", "WES_N1", "WES_T2", "WES_N2"),
role = c("tumor", "normal", "tumor", "normal")
)
parsed <- validate_manifest(manifest)
cohort <- cohort_new(
subject_tbl = parsed$subject_tbl,
sample_map = parsed$sample_map,
study = study
)
# Create and register an analysis spec
spec <- analysis_spec_new(
name = "somatic_vars",
assay = "wes",
level = "pair",
format = "tsv",
reader = "read_tsv",
key_cols = c("pair_id")
)
cohort_with_spec <- analysis_register(cohort, spec)
print(analysis_list(cohort_with_spec))
#> # A tibble: 1 × 6
#> name assay level format reader root_key
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 somatic_vars wes pair tsv read_tsv NA