agglovar.expr.variant
Polars expressions used by variant calling routines.
Attributes
Expression for generating variant IDs including alias "id" for the result (ideal for with_column()). |
|
Expression for generating variant IDs. |
|
Expression for generating non-SNV IDs. |
|
Expression for generating SNV IDs. |
|
Sort columns for variant tables. |
Functions
|
Get a variant ID expression for a single variant-type table. |
|
Extract the lead source entry from a merged callset. |
Module Contents
- agglovar.expr.variant.id_expr_for_table(table: str, alias: str | None = 'id') polars.Expr
Get a variant ID expression for a single variant-type table.
Single-type tables carry only the columns listed for their type in
agglovar.schema.STANDARD_FIELDS, soid_exprcannot be applied to them (see its documentation). This routine returns the one branch that matches the table’s columns.- Parameters:
table – Table name from
agglovar.schema.STANDARD_FIELDS(e.g. “snv”, “insdel”).alias – Output column name for the resulting IDs, or None to leave it unaliased.
- Returns:
An expression yielding variant IDs for table.
- Raises:
ValueError – If table is not a known variant-type table.
- agglovar.expr.variant.lead_src_expr(mg_src_col: str = 'mg_src', mg_src_lead_col: str = 'mg_src_lead', alias: str | None = 'lead_src') polars.Expr
Extract the lead source entry from a merged callset.
A merge produces an
mg_srclist column with one struct per contributing source and anmg_src_leadcolumn holding the integer position within that list of the lead (representative) source. This routine gathers that lead entry back out as a struct, so an API user can read the lead source directly instead of manually indexing the list withpl.col('mg_src').list.get(pl.col('mg_src_lead')).Agglovar does not use this internally; the merge stores only the index to avoid duplicating the entry. It is provided as a convenience for downstream API users.
- Parameters:
mg_src_col – Name of the
mg_srclist column.mg_src_lead_col – Name of the
mg_src_leadindex column.alias – Output column name for the resulting struct, or None to leave it unaliased.
- Returns:
An expression yielding the lead source struct, carrying the same fields as an
mg_srcentry (“src_index”, “src_name”, “src_meta”, “var_index”, “var_id”).
- agglovar.expr.variant.id_expr
Expression for generating variant IDs including alias “id” for the result (ideal for with_column()).
Requires both the SNV columns (
ref,alt) and the non-SNV column (varlen) to be present: Polars resolves both branches of the expression regardless of which one a row selects. Useid_expr_for_table()for single-type tables, which carry only the columns listed inagglovar.schema.STANDARD_FIELDSfor their type.
- agglovar.expr.variant.id_expr_noalias
Expression for generating variant IDs.
- agglovar.expr.variant.id_nonsnv_expr
Expression for generating non-SNV IDs.
- agglovar.expr.variant.id_snv_expr
Expression for generating SNV IDs.
- agglovar.expr.variant.sort_cols
Sort columns for variant tables.