Skip to content

Zero-coverage control genes silently corrupt output with inf/NaN #11

Closed

Description

@dlopez-bioinfo

Bug

When a BAM file has no reads covering one or more of the 20 housekeeping/control genes, the tool silently produces inf/NaN values in the output CSV with no warning.

Root cause

In sma.py, when H_ik[i,k] == 0 for any control gene, a chain of silent NumPy floating-point errors occurs:

H_ik[i,k] == 0.0
  → z_ik[i,k] = inf           (line 124: c_ix_sum / 0.0)
  → zmean_k[k] = inf          (line 127: sum of inf / n_bam)
  → theta_i[i] = nan           (line 128-129: inf/inf = nan)
  → pi_ij[i,j] = nan           (line 130-131: nan * anything = nan)

A single zero-coverage gene in a single sample corrupts all results for that sample. Furthermore, the inf values in z_ik leak into zmean_k, which is shared across all samples — so a single bad sample can degrade the statistics for every other sample in the batch.

Impact

  • The user gets no error or warning — just silent NaN in the CSV output
  • A single problematic BAM file can silently affect results for the entire batch
  • This is especially likely with downsampled or targeted sequencing data where some control gene regions may have no coverage

Expected behavior

  • Warn the user (to stderr) which samples have zero-coverage control genes and which genes are affected
  • Set results to NaN explicitly for affected samples
  • Exclude affected samples from shared statistics (zmean_k) so healthy samples are not corrupted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions