Skip to content

Docker samtools bug #297

Closed
Closed

Description

@brucemoran

Hi, firstly thanks for 2.3.0, fusions are a very welcome addition.

Minor bug I found implementing run via offline VM with downloaded Docker image.

Issue was found with the attached VCF (EGFR-E746_A750del; renamed as txt to allow upload)

pcgr1.txt

I tested with KRAS-G12D VCF which works fine without the detailed solution.

Solution is durable and possibly simple to implement.

Description

PCGR 2.3.0 fails during the vcf2maf stage when processing a GRCh37 VCF containing EGFR-E746_A750del in the official Docker image.

The workflow successfully completes input validation and VEP annotation, but stops immediately after invoking vcf2maf.pl.

Investigation indicates that the samtools executable bundled in the PCGR 2.3.0 Docker image is version 0.1.19-96b5f2294a. This version returns invalid sequence data when samtools faidx is used against the gzipped GRCh37 FASTA distributed with the PCGR reference bundle.

Replacing only the faidx call with a pysam.faidx wrapper returns the expected genomic sequence for the same FASTA and region.

PCGR version

PCGR 2.3.0
Docker image: sigven/pcgr:2.3.0

Genome build

grch37

Environment

Host OS: Ubuntu 22.04.3 LTS
Execution: Docker
PCGR image: sigven/pcgr:2.3.0
Reference bundle version: 20260620

Complete PCGR command

The PCGR command executed inside the container was:

pcgr \
    --input_vcf "/mnt/pcgr_inputs/pcgr.vcf" \
    --vep_dir "/mnt/.vep" \
    --refdata_dir "/mnt/bundle" \
    --output_dir "/mnt/pcgr_outputs" \
    --genome_assembly "grch37" \
    --sample_id "pcgr" \
    --tumor_dp_tag "TDP" \
    --tumor_af_tag "TVAF" \
    --assay "TARGETED" \
    --tumor_only \
    --tumor_site 15 \
    --force_overwrite \
    --no_html \
    --debug

The Docker container was run with the VEP cache, PCGR reference bundle, input directory, and output directory mounted into the container.

Observed behaviour

Input validation completes successfully.

VEP annotation also completes successfully:

PCGR - SNV/INDEL ANALYSIS SECTION - VEP: Variant annotation with Variant Effect Predictor 115, GENCODE release 19, genome assembly grch37
...
Finished pcgr-vep

PCGR then enters the vcf2maf stage:

PCGR - SNV/INDEL ANALYSIS SECTION - VCF2MAF: vcf2maf conversion of VEP-annotated VCF
Stamped VAR_ID on 1 variants -> pcgr.pcgr.grch37.varid.vcf
Converting VEP-annotated VCF to MAF with https://github.com/mskcc/vcf2maf

The generated vcf2maf command is:

vcf2maf.pl --retain-info VAR_ID,TDP,TVAF --inhibit-vep --input-vcf /mnt/pcgr_outputs/pcgr.pcgr.grch37.varid.vcf --tumor-id pcgr --output-maf /mnt/pcgr_outputs/pcgr.pcgr.grch37.tmp.maf --ref-fasta /mnt/bundle/data/grch37/misc/fasta/assembly/Homo_sapiens.GRCh37.dna.primary_assembly.fa.gz --ncbi-build GRCh37

The workflow then terminates.

Full error message

The separate vcf2maf log contains:

ERROR: You're either using an outdated samtools, or --ref-fasta is not the same genome build as your --input-vcf. at /opt/mambaforge/envs/pcgr/bin/vcf2maf.pl line 433.

Investigation

The samtools executable selected inside the PCGR image is:

/opt/mambaforge/envs/pcgr/bin/samtools

Running samtools reports:

Program: samtools (Tools for alignments in the SAM format)
Version: 0.1.19-96b5f2294a

The FASTA index contains the expected chromosome 7 entry:

7    159138663    2474890270    60    61

The VCF contains a GRCh37 chromosome 7 variant at:

CHROM: 7
POS:   55242464
REF:   AGGAATTAAGAGAAGC
ALT:   A

A direct faidx query using the bundled samtools was performed:

samtools faidx \
    Homo_sapiens.GRCh37.dna.primary_assembly.fa.gz \
    7:55242463-55242480

The command returned status 0, but the sequence output was invalid:

>7:55242463-55242480
>1dna:chromosomech

The same query was then performed using pysam.faidx from within the same PCGR image. This returned the expected genomic sequence:

>7:55242463-55242480
AAGGAATTAAGAGAAGCA

For testing, a wrapper named samtools was placed earlier in PATH. The wrapper redirects only samtools faidx to pysam.faidx, while all other subcommands are passed to the original executable:

#!/usr/bin/env bash

set -e

if [ "${1:-}" = "faidx" ]; then
    shift

    exec python - "$@" <<'PY'
import sys
import pysam

result = pysam.faidx(
    *sys.argv[1:],
    catch_stdout=True
)

sys.stdout.write(result)
PY

fi

exec /opt/mambaforge/envs/pcgr/bin/samtools "$@"

With this wrapper selected:

samtools selected:
/tmp/pcgr_bin/samtools

the same faidx test returns:

>7:55242463-55242480
AAGGAATTAAGAGAAGCA

Expected behaviour

The PCGR Docker image should provide a samtools faidx implementation that can correctly retrieve sequence from the gzipped reference FASTA supplied with the supported PCGR GRCh37 reference bundle.

The vcf2maf stage should therefore be able to validate the reference allele and complete VCF-to-MAF conversion without requiring an external wrapper.

Additional context

The failure appears specific to reference sequence retrieval by the bundled samtools 0.1.19, rather than to chromosome naming or the VCF genome build:

  1. The VCF uses chromosome 7.
  2. The FASTA index contains chromosome 7.
  3. The bundled samtools faidx returns status 0 but produces invalid sequence.
  4. pysam.faidx against the same FASTA, index, chromosome, and coordinates returns the expected DNA sequence.

Could the samtools dependency in the PCGR 2.3.0 environment be updated to a version compatible with the compressed reference FASTA, or could the vcf2maf stage use a newer faidx implementation?

Activity

  1. pdiakumis commented on Jul 7, 2026

    @pdiakumis
    Collaborator

    Dear Bruce,
    Thanks so much for the detailed report!
    This is so weird, the conda solver somehow picked up the ancient v0.1.19 instead of the newer v1.23.1.

    https://anaconda.org/channels/bioconda/packages/samtools/files

    I am assuming they're still releasing v0.1.19 for backwards compatibility, and you can see they're keeping lots of platforms satisfied. It shouldn't have made it through though so I'm not sure if there's a pesky dependency that is taking us all the way back to then. Let me try spinning up the GitHub Actions in the dev branch and see if it manages to bring in the newer version.


    The newer v0.1.19 came through April 25th.
    You can notice in the lock files for the PCGR development versions (X.X.X.900*) that the jump from samtools v1.21 to v0.1.19 occurs between PCGR versions 2.2.5.9011 and 2.2.5.9012:

  2. brucemoran commented on Jul 7, 2026

    @brucemoran
    Author

    Hi Peter,

    detailed report is thanks to our AI overlords=)

    Thought it might be an issue like that which you specify.

    Workaround is fine for me ongoing.

    [Processed ca. 300 VCFs with it so far without issues].

    Thought you would like to know in case others have same problem.

    Feel free to close whenever suits.

    Many thanks,

    Bruce.

  3. pdiakumis commented on Jul 7, 2026

    @pdiakumis
    Collaborator

    Ha, well that's good to know that your workaround.. works!

    This was driving me nuts though, so tracing how samtools is actually brought in (since it's not a core dependency of PCGR):

    • ensembl-vep requires perl-bioperl >=1.7.3
    • perl-bioperl requires perl-bio-samtools, and it doesn't actually pin a required version. And honestly, bioperl doesn't even have a samtools hard dependency so it should be dropped from the conda dependency list but that's another story.
    • perl-bio-samtools only has a single version v1.4.3 which is ancient (2016). And here is where the magic happens (and why this probably worked at some point): linux-64/perl-bio-samtools-1.43-pl5321he4a0461_4.tar.bz2 (that's the 4th linux-64 build) doesn't have a samtools dependency, so the more updated samtools came as vcf2maf's dependency (which doesn't pin a required samtools version). Other builds require the ancient samtools v0.1.19.

    I am thinking I can try to figure out how to pin to that perl-bio-samtools build, and then the newer samtools version will come via vcf2maf. I had honestly forgotten or never realised that samtools is used for purely faidx in vcf2maf.

    I'll keep this open for the time being - thanks again!

  4. pdiakumis commented on Jul 8, 2026

    @pdiakumis
    Collaborator

    Hi again Bruce,
    We've released a 'dev' Docker container v2.3.0.9001 which has a more recent samtools version (I just needed to explicitly add a samtools v1 dependency in the pcgr conda env), so feel free to test/use that if your workaround is painful. We'll make an official release with this patch probably later this month.
    Closing but please let us know if you have further issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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