INNER CODE UNIT · Python
pool
antigenomics/vdjtools · python/vdjtools/cli/__init__.py:432
def pool(
samples: list[Path] = typer.Argument(..., help="Two or more clonotype sample files."),
fmt: str = _FMT, out: Optional[Path] = _OUT,
key: str = typer.Option("aa", "--key", help="Match key: strict | nt | ntV | ntVJ | aa | aaV | aaVJ."),
join: bool = typer.Option(False, "--join", help="Incidence join (clonotypes shared across samples) instead of a flat pool."),
min_samples: int = typer.Option(2, "--min-samples", help="With --join: keep clonotypes seen in >= this many samples."),
) -> None:
"""Pool (sum counts) or join (incidence) clonotypes across several samples."""
from vdjtools import preprocess
from vdjtools.io.batch import read
if len(samples) < 2:
_err("pool needs at least two samples")
frames = [read(s, fmt=fmt) for s in samples]
try:
res = (preprocess.join_samples(frames, key=key, min_samples=min_samples) if join
else preprocess.pool_samples(frames, key=key))
except ValueError as e: # unknown key