Enumerates every pairwise combination of the groups in x, so a caller
can turn each pair into a comparison (for example, filtering a cohort down
to one side and diffing an analysis table against the other).
Arguments
- x
Either a Cohort (then
byis required, andcohort_groups()runs internally) or the tibblecohort_groups()already returned (thenbymust not be given).- by
Character vector of
subject_tblcolumns to group by. Only used whenxis a Cohort.
Value
A tibble with one row per pair: group_a, group_b (the two
groups' labels), subject_ids_a, subject_ids_b (list-columns of
subject ids), and n_a, n_b (their sizes).
Details
This is deliberately minimal: it does not repeat the raw by values on
each row. Join back to cohort_groups()'s output on group_label for
those.
Examples
data(example_cohort)
contrasts <- cohort_contrasts(example_cohort, by = "species")
contrasts
#> # A tibble: 1 × 6
#> group_a group_b subject_ids_a subject_ids_b n_a n_b
#> <chr> <chr> <list> <list> <int> <int>
#> 1 mouse rat <chr [2]> <chr [2]> 2 2
cohort_filter(example_cohort, subject_ids = contrasts$subject_ids_a[[1]])
#>
#> ── Cohort: Cross-species genomics comparison
#> • 2 subjects (2 mouse)
#> • 6 samples (4 wes, 2 scrna)
#> ℹ Extra sample columns: fastq_1, fastq_2