Skip to content

Filters¤

Filters are composable variant predicates. Use them with Dataset.read, Dataset.iter_blocks, or Dataset.iter_regions to keep matrix columns and returned variant metadata aligned.

genoio.FilterExpr ¤

Serializable variant filter expression.

Filter expressions can be combined with & and | and negated with ~. They are converted to a JSON-compatible intermediate representation before being evaluated in Rust. Expressions are declarative: Python callbacks are not supported, and a valid expression may retain zero variants.

to_ir(self)-> dict[str, JsonValue] ¤

Return the JSON-compatible filter representation consumed by Rust.

Treat this representation as an inspection aid. Rust validates and may simplify the expression before readers evaluate it.

Returns:

Dictionary containing only JSON-compatible values.

genoio.chrom(value: str)-> FilterExpr ¤

Keep variants on chromosome value.

Arguments:

  • value: non-empty chromosome label.

Returns:

FilterExpr predicate.

genoio.region(value: str)-> FilterExpr ¤

Keep variants in a 1-based inclusive "chrom:start-end" region.

Arguments:

  • value: region string with 1-based inclusive coordinates.

Returns:

FilterExpr predicate.

genoio.snp()-> FilterExpr ¤

Keep single-nucleotide variants with one REF and one ALT base.

Returns:

FilterExpr predicate.

genoio.biallelic()-> FilterExpr ¤

Keep variants with exactly one ALT allele.

Returns:

FilterExpr predicate.

genoio.qual(*, min: float | None = None, max: float | None = None)-> FilterExpr ¤

Keep variants by source QUAL value.

Arguments:

  • min: optional inclusive lower QUAL threshold.
  • max: optional inclusive upper QUAL threshold.

Returns:

FilterExpr predicate.

genoio.maf(*, min: float | None = None, max: float | None = None)-> FilterExpr ¤

Keep variants by minor allele frequency over called genotypes.

Arguments:

  • min: optional inclusive lower MAF threshold.
  • max: optional inclusive upper MAF threshold.

Returns:

FilterExpr predicate.

genoio.mac(*, min: int | None = None, max: int | None = None)-> FilterExpr ¤

Keep variants by minor allele count over called genotypes.

Arguments:

  • min: optional inclusive lower MAC threshold.
  • max: optional inclusive upper MAC threshold.

Returns:

FilterExpr predicate.

genoio.missing_rate(max: float)-> FilterExpr ¤

Keep variants with missing-call rate at or below max.

Arguments:

  • max: inclusive upper missing-call-rate threshold.

Returns:

FilterExpr predicate.

genoio.polymorphic()-> FilterExpr ¤

Keep variants with nonzero minor allele count.

Returns:

FilterExpr predicate.

genoio.id_in(values: Iterable[str])-> FilterExpr ¤

Keep variants whose source ID is in values.

Sets are accepted for convenience and are sorted before serialization so the generated filter IR is deterministic.

Arguments:

  • values: iterable of unique variant ID strings.

Returns:

FilterExpr predicate.