konradjk / loftee

MIT License
174 stars 55 forks source link

LOFTEE (Loss-Of-Function Transcript Effect Estimator)

Loss-of-function pipeline (inspired by MacArthur et al., 2012, published in Karczewski et al., 2020).

A VEP plugin to identify LoF (loss-of-function) variation.

Currently assesses variants that are:

Note: the master branch does not work with GRCh38. Please use the grch38 branch.

Filters

LOFTEE implements a set of filters to deem a LoF as "low-confidence" (LC). Variants that pass these filters are labeled as "high-confidence" (HC).

For stop-gained and frameshift variants, LOFTEE removes:

For splice-site variants, LOFTEE removes:

For all variants, LOFTEE removes:

Flags

LOFTEE implements a series of flags in addition to the above filters. Flagged variants should be treated with caution, particularly when doing genome-wide scans of LoF variation. However, they largely relate to the properties of individual transcripts or exons, so domain knowledge of a given gene will typically outperform these flags.

For stop-gained and frameshift variants, LOFTEE flags:

For splice-site variants, LOFTEE flags:

Predictions of splice-altering variants

LOFTEE also makes predictions of other splice (OS) variants that may cause LoF by disrupting normal splicing patterns.

For variants that occur in the extended (but not essential) splice sites, LOFTEE uses logistic regression models to predict whether the splice site is significantly disrupted.

LOFTEE also uses an SVM model to predict variants that cause LoF by creating de novo donor splice sites leading to a frameshift.

Requirements

Usage

LOFTEE is easiest run when cloned from Github and passed to VEP using --dir_plugins (or move all files in the directory into ~/.vep/Plugins/).

Basic usage:

perl variant_effect_predictor.pl [--other options to VEP] --plugin LoF,loftee_path:/path/to/loftee --dir_plugins /path/to/loftee

Pass additional options to LOFTEE by:

perl variant_effect_predictor.pl [--other options to VEP] --plugin LoF,loftee_path:/path/to/loftee,human_ancestor_fa:/path/to/human_ancestor.fa.gz

Options:

Path to loftee directory. Default is the current working directory. Note: Your PERL5LIB should also contain this path.

Minimum intron size, below which a variant should be filtered.

The Ensembl API can be used to calculate transcript length in two different methods: one approximate (fast; usually within 3 bp of correct length) and one perfect (slow). Default: fast.

Location of human_ancestor.fa file (need associated tabix index file), available for download here (for samtools 0.1.19 and older): http://www.broadinstitute.org/~konradk/loftee/human_ancestor.fa.rz and http://www.broadinstitute.org/~konradk/loftee/human_ancestor.fa.rz.fai. Courtesy of Javier Herrero and the 1000 Genomes Project (source: ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/phase1/analysis_results/supporting/ancestral_alignments/). samtools 1.x uses bgzipped inputs for samtools faidx and downloads are available here: https://s3.amazonaws.com/bcbio_nextgen/human_ancestor.fa.gz, https://s3.amazonaws.com/bcbio_nextgen/human_ancestor.fa.gz.fai, https://s3.amazonaws.com/bcbio_nextgen/human_ancestor.fa.gz.gzi. If this flag is set to 'false', the ancestral allele will not be checked and filtered.

The required SQL database (gzip) can be downloaded here. Alternatively, this can be loaded into MySQL by downloading the source file here and loaded into MySQL with the schema available here. This route requires an additional load of the GERP base and exon files into the same database of gerp_bases and gerp_exons repsectively. You will then need to create a [loftee] entry in your ~/.my.cnf (creating one if it does not exist) that looks like:

[loftee]
host=your_mysql_host
user=your_mysql_user
password=your_mysql_pass
database=your_mysql_db

The Ensembl API contains a "Complete CDS" annotation that indicates that a start and stop codon has been identified for this transcript. This flag unfortunately requires Ensembl database access, and thus, severely decreases performance and is disabled by default.

Flag indicating whether or not to write splice prediction features to LoF_info field. Default: 1.

The minimum cutoff on DONOR_DISRUPTION_PROB (computed from logistic regression model) used to predict a DONOR_DISRUPTION LoF. Default: 0.98.

The minimum cutoff on ACCEPTOR_DISRUPTION_PROB (computed from logistic regression model) used to predict a ACCEPTOR_DISRUPTION LoF. Default: 0.99.

If no conservation_file is specified, then LOFTEE cannot use the logistic regression model to compute DONOR_DISRUPTION_PROB. Instead, it will predict donor disruption using only the impact of the variant on the splice site’s MES score. In this case, donor_disruption_mes_cutoff is the minimum cutoff used to predict DONOR_DISRUPTION. Default: 6 (i.e. the variant must lower the MES score of the splice site by at least 6 to activate DONOR_DISRUPTION).

Ditto for variants affecting the acceptor site. Default: 7.

The maximum distance (in bp) from the disrupted donor or acceptor splice site where LOFTEE will look for "rescue" splice sites. Default: 15.

The minimum cutoff on RESCUE_DONOR_MES (i.e. the highest MES score out of all in-frame donor splice sites within max_scan_distance bp of the original splice site) used to activate the RESUCE_DONOR filter. Default: 8.5.

The minimum cutoff on RESCUE_ACCEPTOR_MES used to activate the RESCUE_ACCEPTOR filter. Default: 8.5.

If this flag is set to true, LOFTEE will only look for de novo donor splice sites occuring in the exon. Default: 1.

Minimum MES of the annotated donor site for LOFTEE to consider any potential de novo donor alternatives. This is necessary because instances of annotated sites with very low MES scores lead to the false prediction of many de novo donor-creating variants. Default: -4.

The maximum distance from the original donor splice site where LOFTEE will look for de novo donor splice sites. Default: 200.

The minimum cutoff on DE_NOVO_DONOR_PROB (computed from SVM model) used to predict a DE_NOVO_DONOR LoF. Default: 0.995.

Output

The output is the standard VEP output, or standard VEP VCF if --vcf is passed to VEP. For those unfamiliar with VEP's VCF output, the annotations are written to the CSQ attribute of the INFO field. Here, a comma-separated list of consequences, corresponding to each transcript-(alternate)allele pair, is written with each entry as a pipe-delimited set of annotations. With more alleles and transcripts (and especially with the --everything flag), this will inevitably make for some very long INFO fields that are difficult to parse by eye.

See src/read_vep_vcf.py for a barebones example of a parsing script, or the section below on Parsing the VEP/LoF VCF for some tips and tricks.

From VEP, a VCF line may look like:

1       1178848 rs115005664     G       A       1000.0   PASS   AC=1;AF=0.5;AN=2;CSQ=A|ENSG00000184163|ENST00000468365|Transcript|non_coding_exon_variant&nc_transcript_variant|445|||||||-1|||,A|ENSG00000184163|ENST00000462849|Transcript|upstream_gene_variant|||||||5|-1|||,A|ENSG00000184163|ENST00000486627|Transcript|downstream_gene_variant|||||||513|-1|||,A|ENSG00000184163|ENST00000330388|Transcript|stop_gained|648|616|206|Q/*|Cag/Tag|||-1|||HC,A|ENSG00000184163|ENST00000478606|Transcript|upstream_gene_variant|||||||310|-1|||`

This is comprehensive, but the crucial information is in the CSQ= part, so here we have the line split up by allele-transcript pair:

A|ENSG00000184163|ENST00000468365|Transcript|non_coding_exon_variant&nc_transcript_variant|445|||||||-1|||,
A|ENSG00000184163|ENST00000462849|Transcript|upstream_gene_variant|||||||5|-1|||,
A|ENSG00000184163|ENST00000486627|Transcript|downstream_gene_variant|||||||513|-1|||,
A|ENSG00000184163|ENST00000330388|Transcript|stop_gained|648|616|206|Q/*|Cag/Tag|||-1|||HC,
A|ENSG00000184163|ENST00000478606|Transcript|upstream_gene_variant|||||||310|-1|||

The overall format of a VCF is described on the VCF Specification Page. The key to parsing this section is in the header line added by VEP.

##INFO=<ID=CSQ,Number=.,Type=String,Description="Consequence type as predicted by VEP. Format: Allele|Gene|Feature|Feature_type|Consequence|cDNA_position|CDS_position|Protein_position|Amino_acids|Codons|Existing_variation|DISTANCE|STRAND|LoF_flags|LoF_filter|LoF">

This line contains the corresponding mappings to these fields after Format::

Allele|Gene|Feature|Feature_type|Consequence|cDNA_position|CDS_position|Protein_position|Amino_acids|Codons|Existing_variation|DISTANCE|STRAND|LoF_flags|LoF_filter|LoF

Parsing the VEP/LoF VCF

One approach that simplifies extracting data from the INFO column is to convert the text representation to a dictionary, where each annotation entry is a key-value pair. Since CSQ entries in the INFO field can contain multiple allele-transcript pairs, we will need to make a list of these dictionaries -- one dictionary per pair.

In Python, the header line line can be read with:

vep_field_names = line.split('Format: ')[-1].strip('">').split('|')

To access the annotations, the VCF record can then be read with:

# Split VCF line
fields = vcf_line.split('\t')

# Split INFO field by semicolons (using lookahead regular expressions due to VEP introducing semi-colons into the INFO field in some scenarios)
# This creates a dictionary with key-value pairs of info field.
info_field = dict([(x.split('=', 1)) for x in re.split(';(?=\w)', fields[7]) if x.find('=') > -1])

# For instance, info_field['AF'] would return the allele frequency of that variant.

# Pull together the VEP field names from before with CSQ attribute from INFO field (which are pipe-delimited).
annotations = [dict(zip(vep_field_names, x.split('|'))) for x in info_field['CSQ'].split(',')]

annotations is now a list of dictionaries like so:

[{'Allele': 'A',
  'Amino_acids': '',
  'CDS_position': '',
  'Codons': '',
  'Consequence': 'non_coding_exon_variant&nc_transcript_variant',
  'DISTANCE': '',
  'Existing_variation': '',
  'Feature': 'ENST00000468365',
  'Feature_type': 'Transcript',
  'Gene': 'ENSG00000184163',
  'LoF': '',
  'LoF_filter': '',
  'LoF_flags': '',
  'Protein_position': '',
  'STRAND': '-1',
  'cDNA_position': '445'},
  ...
  {'Allele': 'A',
  'Amino_acids': 'Q/*',
  'CDS_position': '616',
  'Codons': 'Cag/Tag',
  'Consequence': 'stop_gained',
  'DISTANCE': '',
  'Existing_variation': '',
  'Feature': 'ENST00000330388',
  'Feature_type': 'Transcript',
  'Gene': 'ENSG00000184163',
  'LoF': 'HC',
  'LoF_filter': '',
  'LoF_flags': '',
  'Protein_position': '206',
  'STRAND': '-1',
  'cDNA_position': '648'}, ...]

CSQ entries in the INFO field for a given variant can now be accessed easily. For example, to get the LoF_filter field for the first allele transcript pair use: annotations[0]['LoF_filter'].

LoF annotations can be extracted as:

lof_annotations = [x for x in annotations if x['LoF'] == 'HC']

HC refers to high-confidence LoF variants (i.e. does not fail any filters). LC denotes low-confidence, failing at least one filter, which are written to the LoF_filter field.

Possible values for the LoF_filter field are:

Possible values for the Lof_flags field are:

Special thanks to Monkol Lek for the initial implementation of the software and developing many of these filters.

Citing LOFTEE

To cite loftee, please use the citation: Karczewski et al., 2020.