Troubleshooting Guide

This guide helps you diagnose and solve common issues when using biallelic_py.

Installation Issues

ModuleNotFoundError: No module named ‘biallelic’

Problem: Python cannot find the biallelic_py package

Solutions:

  1. Ensure package is installed:

    # Install in development mode
    pip install -e .
    
  2. Check Python path:

    # Verify biallelic is installed
    python -c "import biallelic; print(biallelic.__file__)"
    
  3. Check virtual environment:

    # Ensure you're in the right virtual environment
    which python
    python --version
    
  4. Reinstall package:

    pip uninstall biallelic_py
    pip install -e .
    

ImportError: cannot import name ‘X’ from ‘biallelic’

Problem: Module import failed for a specific class or function

Causes and solutions:

  1. Check class/function exists:

    # Verify the name exists
    from biallelic import models
    print(dir(models))
    
  2. Check spelling - Common mistakes:

    • Abberations (wrong) → Aberrations (correct)

    • SimpleLoger (wrong) → SimpleLogger (correct)

    • Gender.MALE (wrong) → Gender.Male (correct)

  3. Update your code to match actual names from API Reference

Manifest Issues

“sample_donors reference not found”

Problem: Analysis fails with error about missing sample_donors

Causes:

  1. Missing sample_donors in ref section of manifest

  2. File path to sample_donors is incorrect

  3. File doesn’t contain required columns

Solution:

Ensure manifest has valid ref section:

ref:
  genes:
    path: path/to/genes.bed.gz
    format_driver: bed
  sample_donors:                    # ← MUST BE PRESENT
    path: path/to/samples.txt
    format_driver: maf              # Must match file format

Verification:

# Check file exists
ls -la path/to/samples.txt

# Verify it's readable
zcat path/to/samples.txt | head -5

“genes reference not found”

Problem: Gene annotations cannot be loaded

Causes:

  1. genes entry missing from ref section

  2. File path is incorrect

  3. File doesn’t exist or isn’t readable

  4. File format doesn’t match specified driver

Solution:

Check ref section has genes entry:

ref:
  genes:                            # ← MUST BE PRESENT
    path: path/to/genes.bed.gz
    format_driver: bed              # Must match file format
  sample_donors:
    path: path/to/samples.txt
    format_driver: maf

Verification:

# Check file exists and is readable
ls -lah path/to/genes.bed.gz

# Verify format (should be BED: chrom, start, end, name, ...)
zcat path/to/genes.bed.gz | head -3

“Driver XXX doesn’t implement YYY”

Problem: Unknown data format driver or missing method

Causes:

  1. Driver name misspelled

  2. Driver doesn’t support requested data type

  3. Driver module not found

Example error:

Driver vcf doesn't implement snv

Solution:

Check the manifest specifies a supported driver:

input:
  - path: variants.maf.gz
    type: snv
    format_driver: maf              # ← Correct driver
    extra_driver_args: {}

List available drivers:

from biallelic.misc import get_modules_names
import biallelic.drivers
drivers = get_modules_names(biallelic.drivers)
print("Available drivers:", drivers)

Check what a driver supports:

# Look at driver source code
grep "^def " biallelic/drivers/maf.py

File Path Issues

“File not found” error

Problem: Input or reference file cannot be found

Common causes:

  1. File path is incorrect

  2. Relative path is wrong (should be relative to manifest directory)

  3. File doesn’t exist

  4. File is in a different location than expected

Solution:

  1. Use absolute paths for testing:

    input:
      - path: /absolute/path/to/file.maf.gz
        type: snv
        format_driver: maf
    
  2. Check relative paths - they’re relative to manifest directory:

    # Manifest structure
    project/
    ├── manifest.yaml
    ├── data/
    │   └── variants.maf.gz
    └── ref/
        └── genes.bed.gz
    
    # manifest.yaml uses relative paths
    input:
      - path: data/variants.maf.gz    # ← Relative to manifest
        type: snv
        format_driver: maf
    
  3. Verify file exists:

    ls -lah /path/to/file
    
  4. Check file permissions:

    # File should be readable
    test -r /path/to/file && echo "readable"
    
  5. Check path separators on Windows:

    # Windows paths should use forward slashes or double backslashes
    path: data\variants.maf.gz        # Wrong
    path: data/variants.maf.gz        # Correct
    path: "data\\variants.maf.gz"     # Also correct
    

“Permission denied” error

Problem: Cannot read file due to permissions

Solution:

# Check file permissions
ls -l /path/to/file

# Add read permission if needed
chmod +r /path/to/file

# Or for directory
chmod +rx /path/to/directory

Data Format Issues

“Empty reference_map”

Problem: Reference data loaded but appears empty

Causes:

  1. Reference file doesn’t have expected data

  2. Driver isn’t parsing file correctly

  3. File format doesn’t match specified driver

Solution:

Test the driver directly:

from biallelic.drivers.bed import genes
from biallelic.logging import SimpleLogger

logger = SimpleLogger("test", "/tmp/logs")

# Try loading genes file
genes_df = genes("path/to/genes.bed.gz", logger)
print(f"Loaded {len(genes_df)} genes")
print(genes_df.head())

Invalid data format in file

Problem: Driver can’t parse file due to format issues

Example error:

ValueError: invalid literal for int(): 'not_a_number'

Causes:

  1. File format doesn’t match driver expectations

  2. File is corrupted

  3. Wrong file type specified in manifest

Solution:

  1. Inspect file manually:

    # View first few lines
    zcat file.txt.gz | head -5
    
    # Check delimiter
    zcat file.txt.gz | head -1 | od -c
    
  2. Compare with example:

    Check test data files for correct format:

    ls test/data/
    
  3. Use correct driver:

    # Verify driver matches file type
    input:
      - path: file.maf.gz
        type: snv
        format_driver: maf          # ← Matches file type
    

Analysis Issues

“Analysis module not found”

Problem: Unknown discovery analysis name

Causes:

  1. Analysis name misspelled

  2. Analysis module doesn’t exist

  3. Module is in wrong location

Solution:

List available analyses:

from biallelic.misc import get_modules_names
import biallelic.discovery
analyses = get_modules_names(biallelic.discovery)
print("Available analyses:", analyses)

Correct manifest to use existing analysis:

analyses:
  - name: annotate_snv            # ← Must exist
  - name: summary_biallelic

Memory Issues

“MemoryError” or “Killed” during analysis

Problem: Analysis runs out of memory

Causes:

  1. Dataset is very large

  2. All aberrations loaded into memory at once

  3. Large DataFrame operations

Solutions:

  1. Process subset of data:

    # Test with single chromosome first
    input:
      - path: variants_chr1.maf.gz
        type: snv
        format_driver: maf
    
  2. Check available memory:

    # macOS
    vm_stat | grep "Pages free"
    
    # Linux
    free -h
    
  3. Process by chromosome:

    Create separate manifests for each chromosome

  4. Filter input data:

    Pre-filter large files to essential samples/regions

Performance Issues

“Analysis takes too long”

Problem: Analysis runs slowly

Causes:

  1. Large input files

  2. Complex discovery algorithms

  3. Inefficient file format (uncompressed vs compressed)

Solutions:

  1. Use compressed files:

    # Good - compressed
    path: variants.maf.gz
    
    # Slow - uncompressed
    path: variants.maf
    
  2. Check file I/O:

    Monitor disk usage during analysis:

    # macOS
    iostat -w 1
    
    # Linux
    iotop
    
  3. Profile analysis:

    See Development Guide for profiling instructions

  4. Reduce data size:

    Test with subset before full analysis:

    # Sample 10% of lines
    zcat variants.maf.gz | head -10000 | gzip > sample.maf.gz
    

Logging and Debugging

“ERROR: Analysis failed”

Problem: Error message is generic and unhelpful

Solution:

  1. Check log files:

    cat logs/bi.log
    tail -f logs/bi.log  # Watch logs in real-time
    
  2. Enable debug logging:

    import logging
    from biallelic.logging import SimpleLogger
    
    # Create logger with DEBUG level
    logger = SimpleLogger("debug_analysis", "/path/to/logs", level=logging.DEBUG)
    logger.log.debug("Detailed information now in logs")
    
  3. Run with minimal input:

    Test with small subset to isolate issue:

    # Run with single sample
    biallelic_inactivation manifest_single_sample.yaml
    

Getting More Help

If you can’t find a solution here:

  1. Check the source code:

    • Read docstrings: API Reference

    • Check examples in test data: test/data/

  2. Review documentation:

  3. Inspect error logs:

    # Full error with traceback
    cat logs/bi.log | grep -A 10 "ERROR"
    
  4. Create minimal test case:

    Try to reproduce error with simplest possible input

  5. Check Python version:

    python --version
    # Should be 3.9 or higher
    

Common Mistakes

  1. YAML syntax errors:

    # Wrong - colon followed by no space
    title:Test
    # Correct
    title: Test
    
    # Wrong - inconsistent indentation
    ref:
    genes:
        path: file.bed
    # Correct
    ref:
      genes:
        path: file.bed
    
  2. Missing required fields:

    # Wrong - missing format_driver
    input:
      - path: file.maf
        type: snv
    # Correct
    input:
      - path: file.maf.gz
        type: snv
        format_driver: maf
    
  3. Wrong data type:

    # Wrong - type unknown
    input:
      - path: file.maf
        type: mutation              # Wrong - use 'snv'
    # Correct
    input:
      - path: file.maf.gz
        type: snv
    
  4. Not providing absolute or relative path:

    All file paths must be either absolute or relative to manifest directory

  5. Using spaces in paths:

    # Works but safer to quote
    path: my file.maf.gz            # Risky
    path: "my file.maf.gz"          # Better
    path: my_file.maf.gz            # Best
    

See Also