agglovar.merge.base
Base class for callset intersects.
Attributes
Alias for acceptable input types. |
Classes
Callset definition. |
|
Base class for callset intersects. |
Module Contents
- class agglovar.merge.base.CallsetDef
Bases:
NamedTupleCallset definition.
- Variables:
table – The callset table to be merged.
name – The name of the callset within a collection of callsets.
metadata – The metadata of the callset or None if no metadata is provided.
- table: polars.LazyFrame
- class agglovar.merge.base.MergeBase
Bases:
abc.ABCBase class for callset intersects.
- abstractmethod __call__(callsets: collections.abc.Iterable[CallsetDefInputType], retain_index: bool = False, pre_filter: collections.abc.Iterable[polars.Expr] | None = None, temp_dir: bool | str | pathlib.Path = False) polars.LazyFrame
Intersect callsets.
- Parameters:
callsets – Callsets to intersect.
retain_index – If True, do not drop an existing “_index” column if it exists.
pre_filter – If set, filter each table with these expressions. Filter is applied last (after “_index” is set).
temp_dir – How the underlying pairwise intersect materialises prepared tables before its chunked loop.
False(default) keeps tables in memory;Truewrites them to the system temp directory as parquet; astr/Pathwrites them to that directory. Temp files are always removed on exit.
- Returns:
A merged callset table.
- static get_intersect_tuples(callsets: collections.abc.Iterable[CallsetDefInputType], retain_index: bool = False, pre_filter: collections.abc.Iterable[polars.Expr] | polars.Expr | None = None) list[CallsetDef]
Transform input callset definitions into a normalized list of
CallsetDef.Each returned
CallsetDef(a named tuple) has three fields:table: A lazy frame.name: A name for the source.metadata: A metadata string for this source, orNoneif none was given.
The source index is not stored on the definition; it is implicitly the position of the element in the returned list (0 for the first source, incrementing by 1).
If a source name is given, the given name is used. If it is not, then a default name is generated from the source index (e.g. “source_1” for the first source). Names are de-duplicated against names already seen.
Lazy frames are transformed to add a source index (“_mg_src_index” column) and to ensure a variant ID is present (“id” column), filling missing IDs from the index.
- Parameters:
callsets – Callsets parameter. May be an iterable of DataFrames, LazyFrames,
(table, name)tuples,(table, name, metadata)tuples, orCallsetDefobjects.retain_index – If True, do not drop an existing “_index” column if it exists.
pre_filter – If set, filter each table with these expressions. Filter is applied last (after “_index” is set).
- Returns:
A list of
CallsetDef, one per input source, in input order.