Skip to main content

Convert VCF files to MAF format — a Python reimplementation of mskcc/vcf2maf

Project description

vcf2maf-py

A Python reimplementation of mskcc/vcf2maf — convert VCF files to MAF (Mutation Annotation Format).

Attribution

This project is a Python port of the original Perl-based vcf2maf created by Cyriac Kandoth at Memorial Sloan Kettering Cancer Center. The original tool and its conversion logic, effect prioritization, and variant classification mappings are the foundation of this reimplementation.

Cyriac Kandoth. mskcc/vcf2maf: vcf2maf v1.6. (2020). doi:10.5281/zenodo.593251

The original repository is available at https://github.com/mskcc/vcf2maf and is licensed under the Apache 2.0 License.

Features

  • VCF → MAF conversion with support for VEP and SnpEff annotations
  • MAF → VCF conversion (reverse direction)
  • Pure Python — no Perl, no C dependencies; installs with pip
  • Parses VEP CSQ and SnpEff ANN annotation fields automatically
  • Handles multi-allelic sites (splits into separate MAF rows)
  • Extracts genotype depths from 7+ variant caller FORMAT conventions (GATK, FreeBayes, Strelka, VarScan, Delly, and more)
  • Effect prioritization matching the original vcf2maf cascade (biotype → severity → canonical → transcript length)
  • Maps 130+ Sequence Ontology terms to MAF Variant_Classification
  • Supports custom isoform overrides (MSKCC, MANE, or your own)
  • Outputs MAF v2.4 compatible with cBioPortal, maftools, and GDC pipelines
  • VCF inspection command to check annotation status before conversion
  • Reads gzipped VCF/MAF files transparently

Installation

pip install vcf2maf-py

With optional reference FASTA support for MAF → VCF conversion:

pip install 'vcf2maf-py[pysam]'

Quick start

VCF → MAF

# Basic conversion (auto-detects annotations, samples, and genome build)
vcf2maf-py vcf2maf somatic.vcf -o somatic.maf

# With explicit options
vcf2maf-py vcf2maf somatic.vcf.gz \
    -o somatic.maf \
    --tumor-id TUMOR_SAMPLE \
    --normal-id NORMAL_SAMPLE \
    --ncbi-build GRCh38 \
    --center MSKCC

# Output only core 34 MAF columns
vcf2maf-py vcf2maf somatic.vcf -o somatic.maf --output-columns core

# With custom isoform overrides
vcf2maf-py vcf2maf somatic.vcf -o somatic.maf --isoform-overrides overrides.tsv

MAF → VCF

# Basic reverse conversion
vcf2maf-py maf2vcf mutations.maf -o mutations.vcf

# With reference FASTA for correct indel padding (requires pysam)
vcf2maf-py maf2vcf mutations.maf -o mutations.vcf --ref-fasta GRCh38.fa

Inspect a VCF

# Check annotation status, sample names, and variant summary
vcf2maf-py inspect somatic.vcf

Python API

from vcf2maf_py import convert_vcf_to_maf, convert_maf_to_vcf

# VCF → MAF
rows = convert_vcf_to_maf(
    "somatic.vcf",
    output_maf="somatic.maf",
    tumor_id="TUMOR",
    normal_id="NORMAL",
)

# MAF → VCF
convert_maf_to_vcf("mutations.maf", "mutations.vcf")

Annotation support

vcf2maf-py works best with annotated VCF files. It auto-detects:

Annotation tool INFO field Status
Ensembl VEP CSQ Fully supported
SnpEff ANN Fully supported
None Converts coordinates and depths; warns about missing annotations

If your VCF is not annotated, you can annotate it with Ensembl VEP:

vep --input_file input.vcf --output_file annotated.vcf \
    --vcf --offline --cache \
    --symbol --canonical --biotype --sift b --polyphen b \
    --fields "Allele,Consequence,IMPACT,SYMBOL,Gene,Feature_type,Feature,BIOTYPE,EXON,INTRON,HGVSc,HGVSp,cDNA_position,CDS_position,Protein_position,Amino_acids,Codons,Existing_variation,DISTANCE,STRAND,CANONICAL,SIFT,PolyPhen,ALLELE_NUM"

How it works

For each variant in the VCF:

  1. Parse alleles — trim shared prefix/suffix bases, convert VCF-padded indels to MAF coordinate conventions
  2. Detect annotations — auto-detect VEP CSQ or SnpEff ANN in the VCF header
  3. Parse all transcript effects — extract every annotated transcript for the variant
  4. Select the best effect using a priority cascade:
    • Biotype priority (protein_coding > IG/TR genes > ncRNA > pseudogene)
    • Effect severity (~130 SO terms ranked from transcript_ablation to intergenic_variant)
    • Canonical transcript preference
    • Custom isoform overrides
  5. Map SO terms to MAF classifications (missense_variant → Missense_Mutation, stop_gained → Nonsense_Mutation, etc.)
  6. Extract genotype depths from FORMAT fields (AD, RO/AO, DP4, Strelka tiers, NR/NV, DV, etc.)
  7. Write MAF with #version 2.4 header

Differences from the original Perl version

Feature Original (Perl) This version (Python)
Language Perl 5 Python 3.9+
VEP dependency Runs VEP as part of conversion Expects pre-annotated VCF (warns if not)
Installation Manual / Docker pip install vcf2maf-py
SnpEff support VEP field mapping only Native ANN field parsing
Reference validation Via samtools faidx Optional (via pysam)
liftOver Built-in Not yet (planned)
Python API None Full programmatic access

Development

git clone https://github.com/viktorlj/vcf2maf-py
cd vcf2maf-py
uv venv && source .venv/bin/activate
uv pip install -e '.[dev]'
pytest

License

Apache 2.0 — same as the original vcf2maf.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcf2maf_py-0.1.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcf2maf_py-0.1.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file vcf2maf_py-0.1.0.tar.gz.

File metadata

  • Download URL: vcf2maf_py-0.1.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for vcf2maf_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 030f25a8267070abef66af677c7e1003071bf999466a85a0b7cd3d4102c8d1cd
MD5 b9f8a482e966726428712fc4b14e7b54
BLAKE2b-256 e01b1efa3e7bc0cf213587fbe48dfbf507351a12936ce5bb14ac6066dde02734

See more details on using hashes here.

File details

Details for the file vcf2maf_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vcf2maf_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for vcf2maf_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1679629d2260020e63258cadd97b391c1764df622a4aafc0849e63aae730addf
MD5 306cd86077b468b5a2b1e6d8e98cc304
BLAKE2b-256 8b449c0391e07b91f4b19e4913c27f84e64f09fdfd5113e24674e0ae73b855ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page