cluster_test_by {CellaRepertorium} | R Documentation

## Test clusters for differential usage

### Description

Typically one will want to stratify by chain by calling `cluster_test_by`, as this will calculate the number of cell "trials" separately depending on the chain recovered.

### Usage

    cluster_test_by(ccdb, fields = "chain", tbl = "cluster_tbl", ...)

    cluster_logistic_test(
      formula,
      ccdb,
      filterset = cluster_filterset(),
      contig_filter_args = TRUE,
      tie_break_keys = c("umis", "reads"),
      add_cluster_tbl = FALSE,
      keep_fit = FALSE,
      fitter = glm_glmer,
      silent = FALSE
    )

### Arguments

`ccdb` | `ContigCellDB()`
`fields` | `character` naming fields in `tbl`
`tbl` | one of `contig_tbl`, `cell_tbl` or `cluster_tbl`
`...` | passed to `cluster_logistic_test`
`formula` | the right-hand side of a glmer or glm-style formula.
`filterset` | a call to `cluster_filterset()` that will be used to subset clusters.
`contig_filter_args` | an expression passed to `dplyr::filter()`. Unlike `filter`, multiple criteria must be `&` together, rather than using commas to separate. These act on `ccdb$contig_tbl`
`tie_break_keys` | (optional) `character` naming fields in `contig_tbl` that are used sort the contig table in descending order. Used to break ties if `contig_filter_args` does not return a unique contig for each cluster
`add_cluster_tbl` | `logical` should the output be joined to the `cluster_tbl`?
`keep_fit` | `logical` as to whether the fit objects should be returned as a list column
`fitter` | a function taking arguments `formula`, `data`, `is_mixed` and `keep_fit` that is run on each cluster. Should return a `tibble` or `data.frame`
`silent` | `logical`. Should warnings from fitting functions should be suppressed?

### Value

table with one row per cluster/term.

### Functions

- `cluster_test_by`: split `ccdb` and conduct tests within strata

### Examples

    library(dplyr)
    data(ccdb_ex)
    ccdb_ex = cluster_germline(ccdb_ex)
    trav1 = filter(ccdb_ex$cluster_tbl, v_gene == 'TRAV1')
    cluster_logistic_test(~pop + (1|sample), ccdb_ex,
    filterset = cluster_filterset(white_list= trav1))
    # Fixed effect analysis of each cluster, by chain
    prev4 = ccdb_ex$contig_tbl %>% group_by(cluster_idx) %>%
    summarize(n()) %>% filter(`n()`>= 4)
    cluster_test_by(ccdb = ccdb_ex, fields = 'chain',
    tbl = 'cluster_tbl', formula = ~ pop, filterset = cluster_filterset(white_list= prev4))

[Package CellaRepertorium version 1.2.0 Index]