% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ContigCellDB-methods.R
\name{equalize_ccdb}
\alias{equalize_ccdb}
\title{Take the intersection of keys in tables in \code{x}}
\usage{
equalize_ccdb(x, cell = TRUE, contig = TRUE, cluster = TRUE, sort = FALSE)
}
\arguments{
\item{x}{\code{\link[=ContigCellDB]{ContigCellDB()}}}

\item{cell}{\code{logical} equalize cells}

\item{contig}{\code{logical} equalize contigs}

\item{cluster}{\code{logical} equalize clusters}

\item{sort}{\code{logical} should equalized fields also be \code{\link[=order]{order()}}ed by their primary keys?}
}
\value{
\code{\link[=ContigCellDB]{ContigCellDB()}}
}
\description{
The cells in \code{cell_tbl}, and clusters in \code{cluster_tbl} can potentially be a superset of the \code{contig_tbl}.
}
\details{
\itemize{
\item \code{equalize_ccdb(x, cell = TRUE)} trims cells that aren't in \code{contig_tbl} or  \code{cluster_tbl}.
\item \code{equalize_ccdb(x, cluster = TRUE)} trims clusters that aren't in \code{contig_tbl}.
\item \code{equalize_ccdb(x, contig = TRUE)} trims contigs that aren't \code{cell_tbl} or \code{cluster_tbl}.
}
}
\section{Default equalization}{

Modification to \code{contig_tbl} (with \code{$}) always equalizes contigs and clusters.
Modification to \code{cell_tbl} equalizes only contigs.
Modification to \code{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)
}
