Analyze Variants Module

The analyze_variants module provides variant-level analysis and gene burden testing.

Variant analysis module for gene burden and other statistics.

Modular design: - Basic and comprehensive stats computations moved to stats.py. - Gene burden analysis moved to gene_burden.py. - Helper functions moved to helpers.py.

This module now: - Reads a TSV of variants and their annotations (including a GT column listing sample genotypes). - Classifies samples into case/control sets based on user input (sample lists or phenotype terms). - If no case/control criteria are provided, defaults to making all samples controls. - Invokes external modules (stats.py, gene_burden.py) for computations. - Orchestrates flow and writes or yields output lines.

Maintains previous functionality, CLI interface, and output format.

variantcentrifuge.analyze_variants.analyze_variants(lines, cfg)[source]

Analyze variants and optionally perform gene burden analysis.

Steps

  1. Parse input TSV into a DataFrame.

  2. Compute counts and stats via analyze_variants_df.

  3. If requested, perform gene burden (Fisher’s exact test + correction).

param lines:

Input lines representing a TSV with variant data.

type lines:

Iterator[str]

param cfg:

Configuration dictionary.

type cfg:

dict[str, Any]

Yields:

str – Processed lines of output TSV or gene-level burden results.

variantcentrifuge.analyze_variants.analyze_variants_df(df, cfg)[source]

Analyze variants DataFrame and compute allele frequencies, counts, and statistics.

Parameters:
  • df (DataFrame) – Input DataFrame with variant data.

  • cfg (dict[str, Any]) – Configuration dictionary with sample lists, case/control assignments, stats settings.

Returns:

Updated DataFrame with variant counts and statistics columns.

Return type:

DataFrame