equalize_ccdb {CellaRepertorium} | R Documentation

## Take the intersection of keys in tables in `x`

### Description

The cells in `cell_tbl`, and clusters in `cluster_tbl` can potentially be a superset of the `contig_tbl`.

### Usage

    equalize_ccdb(x, cell = TRUE, contig = TRUE, cluster = TRUE, sort = FALSE)

### Arguments

`x` | `ContigCellDB()`
`cell` | `logical` equalize cells
`contig` | `logical` equalize contigs
`cluster` | `logical` equalize clusters
`sort` | `logical` should equalized fields also be `order()`ed by their primary keys?

### Details

- `equalize_ccdb(x, cell = TRUE)` trims cells that aren't in `contig_tbl` or `cluster_tbl`.

- `equalize_ccdb(x, cluster = TRUE)` trims clusters that aren't in `contig_tbl`.

- `equalize_ccdb(x, contig = TRUE)` trims contigs that aren't `cell_tbl` or `cluster_tbl`.

### Value

`ContigCellDB()`

### Default equalization

Modification to `contig_tbl` (with `$`) always equalizes contigs and clusters. Modification to `cell_tbl` equalizes only contigs. Modification to `cluster_tbl` equalizes contigs and clusters.

### Examples

    library(dplyr)
    tbl = tibble(clust_idx = gl(3, 2), cell_idx = rep(1:3, times = 2), contig_idx = 1:6)
    ccdb = ContigCellDB(tbl, contig_pk = c('cell_idx', 'contig_idx'),
    cell_pk = 'cell_idx', cluster_pk = 'clust_idx')
    # 3 cells
    ccdb
    ccdb$cell_tbl = bind_rows(ccdb$cell_tbl, tibble(cell_idx = 0))
    # 4 cells now
    ccdb
    # 3 cells again
    equalize_ccdb(ccdb)
    # remove all contigs from cell 1, and one contig from cell 2
    ccdb$contig_tbl = ccdb$contig_tbl[-c(1, 2, 4),]
    # no changes to cell_tbl yet
    ccdb
    # trim cell_tbl to 2 cells, keep all clusters
    equalize_ccdb(ccdb, cluster = FALSE)
    # trim both cells and clusters
    equalize_ccdb(ccdb, cluster = TRUE)

[Package CellaRepertorium version 1.4.0 Index]