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

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.

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
#> ContigCellDB of 6 contigs; 3 cells; and 3 clusters.
#> Contigs keyed by cell_idx, contig_idx; cells keyed by cell_idx.
ccdb$cell_tbl = bind_rows(ccdb$cell_tbl, tibble(cell_idx = 0))
# 4 cells now
ccdb
#> ContigCellDB of 6 contigs; 4 cells; and 3 clusters.
#> Contigs keyed by cell_idx, contig_idx; cells keyed by cell_idx.
# 3 cells again
equalize_ccdb(ccdb)
#> ContigCellDB of 6 contigs; 3 cells; and 3 clusters.
#> Contigs keyed by cell_idx, contig_idx; cells keyed by cell_idx.
# 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
#> ContigCellDB of 3 contigs; 4 cells; and 2 clusters.
#> Contigs keyed by cell_idx, contig_idx; cells keyed by cell_idx.
# trim cell_tbl to 2 cells, keep all clusters
equalize_ccdb(ccdb, cluster = FALSE)
#> ContigCellDB of 3 contigs; 2 cells; and 2 clusters.
#> Contigs keyed by cell_idx, contig_idx; cells keyed by cell_idx.
# trim both cells and clusters
equalize_ccdb(ccdb, cluster = TRUE)
#> ContigCellDB of 3 contigs; 2 cells; and 2 clusters.
#> Contigs keyed by cell_idx, contig_idx; cells keyed by cell_idx.