Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/dandelion/base/preprocessing/_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,7 @@ def check_contigs(
adata: AnnData | None = None,
productive_only: bool = True,
library_type: Literal["ig", "tr-ab", "tr-gd"] | None = None,
min_umi: int = 1,
umi_foldchange_cutoff: int = 2,
consensus_foldchange_cutoff: int = 5,
ntop_vdj: int = 1,
Expand Down Expand Up @@ -2921,6 +2922,8 @@ def check_contigs(
TRA, TRB
`tr-gd`:
TRG, TRD
min_umi : int, optional
Minimum UMI count for a contig to be considered.
umi_foldchange_cutoff : int, optional
related to minimum fold change of UMI count, required to rescue contigs/barcode otherwise they will be marked as extra/ambiguous.
consensus_foldchange_cutoff : int, optional
Expand Down Expand Up @@ -2986,6 +2989,9 @@ def check_contigs(
else:
dat = dat_.copy()

# filter based on umi
dat = dat[dat["umi_count"].astype(int) >= min_umi].copy()

if acceptable is not None:
dat = dat[dat.locus.isin(acceptable)].copy()

Expand Down
10 changes: 8 additions & 2 deletions src/dandelion/polars/preprocessing/_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4213,6 +4213,7 @@ def check_contigs(
adata: AnnData | None = None,
productive_only: bool = True,
library_type: Literal["ig", "tr-ab", "tr-gd"] | None = None,
min_umi: int = 1,
umi_foldchange_cutoff: float = 2.0,
consensus_foldchange_cutoff: float = 5.0,
ntop_vdj: int = 1,
Expand Down Expand Up @@ -4247,6 +4248,8 @@ def check_contigs(
- `ig`: IGH, IGK, IGL
- `tr-ab`: TRA, TRB
- `tr-gd`: TRG, TRD
min_umi : int, optional
Minimum UMI count for a contig to be considered.
umi_foldchange_cutoff : float, default=2.0
Minimum UMI fold-change threshold for dominance test.
consensus_foldchange_cutoff : float, default=5.0
Expand Down Expand Up @@ -4323,8 +4326,6 @@ def check_contigs(
mark_ambiguous_contigs_vec : Core vectorized function for marking contigs
check_chimeric_genes_vec : Detects chimeric gene calls
"""
from pathlib import Path
import os

if verbose:
print("Filtering contigs...")
Expand Down Expand Up @@ -4384,6 +4385,11 @@ def check_contigs(
else:
dat = dat_

# filter by minimum UMI count (lazy)
dat = dat.filter(
pl.col("umi_count").cast(pl.Int64) >= min_umi
) # if the row has no umi_count, it will be filtered out since it will be null and null >= min_umi is false

# Filter by library type (lazy)
if acceptable is not None:
dat = dat.filter(pl.col("locus").is_in(acceptable))
Expand Down
Loading