-
Notifications
You must be signed in to change notification settings - Fork 51
Running SQANTI3 rescue
As of SQANTI3 v5.1, a new module has been added to the SQANTI3 workflow for transcriptome characterization and quality control: SQANTI3 rescue.
The SQANTI3 rescue algorithm is designed to be run after transcriptome filtering and uses the long read-based evidence provided by discarded isoforms (i.e. artifacts) to recover transcripts in the associated reference transcriptome. The idea behind this strategy is to avoid losing transcripts/genes that are detected as expressed by long read sequencing, but whose start/end/junctions could not be confidently validated using orthogonal data, resulting in the removal of those genes/transcripts from the transriptome. More details about this can be found in the Motivation section below.
In particular, during the rescue, SQANTI3 will try to confidently assign each discarded artifact to the best matching reference transcript. As a result, SQANTI3 rescue will generate an expanded transcriptome GTF including a set of reference transcripts as well as the long read-defined isoforms that passed the filter.
To be completed: explain why transcript rescue is required after filtering.
The SQANTI3 rescue algorithm consists in the following steps:
As explained above, the rescue strategy in SQ3 was conceived to recover transcriptome diversity lost during filtering. This, among other things, means verifying that mone of the reference-supported junction chains that were initially detected by long-reads are lost due to stringent artifact removal.
To achieve this during automatic rescue, all reference transcripts that were represented by at least one FSM in the original post-QC transcriptome are first retrieved -note that this information is available in the associated_transcript
column of the *_classification.txt
file. Then, those reference transcripts for which all FSM representatives were removed by the filter are rescued.
The previous analytic decision is justified because, in practice, any case where all FSMs with the same associated_transcript
are removed can be interpreted as follows: 1) the TSS and/or TTS of the long read-defined transcript is different from that of the matching reference transcript, however, it could not be validated by SQ3 QC-supplied orthogonal data; and 2) the junctions are identical to those found in the reference, which can be interpreted as evidence that this isoform is real. As a result, SQ3 will not rescue any of the discarded FSMs, but the associated_transcript
from the reference.
In spite of its potential to achieve the goals that we set for the rescue, the previous strategy does not consider ISM, NIC or NNC artifacts. These will be included in the rescue candidate group, i.e. transcripts classified as artifacts for which SQANTI3 will try to find a matching reference transcript to include in the final, curated transcriptome.
-
For ISM artifact transcripts, there are two possible situations:
-
There will be cases where the same discarded reference transcript is supported by FSM and ISM. ISM artifacts with an FSM artifact counterpart will therefore be "collapsed" into the rescued reference transcript during the automatic rescue step.
-
Conversely, there will be
associated_transcript
references that are only supported by one or more ISM. Those ISM artifacts that constituted evidence of a non-FSM supported reference will therefore be included in the rescue candidate list.
-
-
For novel transcripts from the NIC and NNC categories, since there is no associated transcript information, all transcripts classified as artifacts will be included in the rescue candidate list.
As a result, we consider all reference or long read-defined transcripts from genes that have at least one rescue candidate to be rescue targets.
SQ3 rescue next tries to find matches between each rescue target and its same-gene candidates based on sequence similarity. To achieve this, we perform an internal mapping step using minimap2. In it, rescue candidates are considered to be "reads" and rescue targets are used as a "reference genome" in which each transcript sequence constitutes a different "chromosome".
To map candidates, we use the map-hifi
option in minimap2 and the -a -x
parameters:
minimap2 --secondary=yes -ax map-hifi rescue_targets.fasta rescue_candidates.fasta > mapped_rescue.sam
Finally, all candidate-target pairs obtained during mapping -referred to as mapping hits- are obtained from the output SAM file regardless of whether they are primary or secondary alignments.
Validation of transcripts using orthogonal sources of data is an important part of the SQANTI3 philosophy. In consequence, the rescue strategy in SQ3 includes a validation step for all reference rescue targets before considering them for inclusion in the transcriptome, since no QC information is available for them (in contrast to long read-defined targets).
This requires users to run SQANTI3 quality control on the reference transcriptome and supply the output *_classification.txt
file to SQANTI3 rescue using the --refClassif
(-k
) flag. This must be done using the same orthogonal data files that were used when running SQANTI3 QC for the long read-transcriptome, since the rescue is based on the assumption that the same evidence is required to validate all rescue targets.
Using the supplied reference classification file, SQ3 rescue will next apply SQ3 filter to the reference transcriptome. The filter to be applied will be specified by the rules
or ml
flags used when running the rescue. This means that, if you run SQ3 machine learning-based filter, you should also run the rescue using the ml
option (and the same is true for the rules filter).
In the final rescue step, hereby referred to as rescue-by-mapping, mapping hits (i.e. candidate-target pairs obtained during mapping) and reference transcriptome filter results are combined to generate a final list of reference transcripts to be rescued.
This part of the rescue can be divided into the following tasks/criteria:
-
SQ3 filtering of targets: first, candidate-target pairs are removed if the rescue target did not pass the filter (ML or rules). If the user is working with the rules filter, this will mean that the reference (or long-read) target transcript did not pass the rules defined in the JSON file. If the user is working with the ML filter, this will mean that the target transcript did not pass the specified ML probability threshold. In the case of the ML filter, however, only the target transcript(s) with maximum ML probability are selected to continue in the rescue.
-
Select reference targets: as explained above, both long read-defined and reference target transcripts are considering during mapping. As a result, rescue candidates (i.e. artifacts) can match to either of these transcripts. From this step onwards, however, only targets selected from the reference transcriptome are considered. This is done to avoid introducing redundancy in the final transcriptome: if a rescue candidate's perfect match was another long read-defined counterpart from the same gene, there is no need to include another transcript as a rescued representative, since the best matching transcript is already part of the transcriptome.
-
Remove redundant reference transcripts: during rescue, there is a chance that some of the reference transcripts that we wish to include in our transcriptome is already represented by an FSM from the same gene (or that it has been already retrieved during automatic rescue). In this situation, target reference transcripts that are already represented by a long read-defined isoform are not to be included in the transcriptome in order to avoid increasing redundancy. In other words -and similarly to what was previously stated-, these are cases in which the artifact's (i.e. rescue candidate) best matching transcript is already represented by an isoform in the transcriptome.
After performing this last filter of the rescue target list, SQ3 rescue outputs a list of rescued reference transcripts, which are then added to the long-read transcriptome GTF.
Similarly to the SQANTI3 filter, the SQANTI3 rescue is designed as a
dual implementation, depending on whether the rules or the machine learning filter was previously run. Therefore, the sqanti3_rescue.py
script requires a flag to be provided to activate either the ml
or rules
specific rescue.
usage: sqanti3_rescue.py [-h] {ml,rules} ...
Rescue artifacts discarded by the SQANTI3 filter, i.e. find closest match for
the artifacts in the reference transcriptome and add them to the
transcriptome.
positional arguments:
{ml,rules}
optional arguments:
-h, --help show this help message and exit
Regardless of the rescue mode that is selected, SQ3 has the following common arguments, all of which are mandatory:
-
Long read-defined isoforms: should be the FASTA file generated by SQANTI3 QC (
*_corrected.fasta
). The isoform sequences will be used to extract rescue candidates and targets for mapping, and must be supplied via the--isoforms
argument. -
Long read-defined transcriptome annotation (filtered): should be the GTF file output by SQANTI3 filter (
*.filtered.gtf
). Rescued transcripts will be appended to this GTF file to generate the final curated transcriptome. This file must be supplied via the--gtf
argument. -
Reference transcriptome annotation: reference GTF used to run SQANTI3 QC. This file will be used to extract rescue targets for mapping, and must be supplied via the
--refGTF
(or-g
) argument. -
Reference transcriptome classification file generated after running SQANTI3 QC on the reference transcriptome, which must be done previously to running the rescue and using the same orthogonal data as for long read-defined transcriptome QC. This file must be supplied via the
--refClassif
(or-k
) argument and will be used to evaluate reference rescue target support (see details above).
Additionally, the following parameters can be set to modify the behavior of the rescue algorithm:
-
Define rescue for mono-exon transcripts: the
-e
flag can be used to determine whether (and how) to perform the rescue on mono-exonic transcripts. The following options can be supplied:-
all
(default): all mono-exon transcripts classified as artifacts will be considered as rescue candidates, regardless of the category that they are classified into. -
fsm
: mono-exonic transcripts will only be considered for the rescue if they belong to the full-splice match (FSM) category. In this case, mono-exons will be rescued via the automatic rescue strategy. -
none
: do not consider mono-exonic transcripts for the rescue (all mono-exons classified as artifacts will be discarded and no reference representatives included in the final transcriptome).
-
-
Output directory and outfile prefix: the output directory can be set via the
-d
flag (default: current directory). Output files will be named using the prefix provided using the-o
argument (default: SQANTI3). -
Skip report creation: when the
--skip_report
is supplied, no summary rescue report will be generated.
In addition to the common arguments, the rules rescue requires the following specific files:
-
Rules JSON file: using the
-j
flag, the user must provide the JSON file used for running SQANTI3 rules filter on the long read-defined transcriptome. This same set of rules will be applied to the reference transcriptome to evaluate the reliability of reference rescue targets. Note that, to achieve this, SQANTI3 rescue requires the classification file output after running SQANTI3 QC on the reference to be provided via the--refClassif
argument.
All in all, these are the arguments accepted by sqanti3_rescue.py rules
:
usage: sqanti3_rescue.py rules [-h] [--isoforms ISOFORMS] [--gtf GTF] [-g REFGTF]
[-f REFGENOME] [-k REFCLASSIF]
[-e {all,fsm,none}] [-o OUTPUT] [-d DIR]
[--skip_report] [-v] [-j JSON]
sqanti_filter_classif
Rescue for rules-filtered transcriptomes.
positional arguments:
sqanti_filter_classif
SQANTI filter (ML or rules) output classification file.
optional arguments:
-h, --help show this help message and exit
--isoforms ISOFORMS FASTA file output by SQANTI3 QC (*_corrected.fasta),
i.e. the full long read transcriptome.
--gtf GTF GTF file output by SQANTI3 filter (*.filtered.gtf).
-g REFGTF, --refGTF REFGTF
Full path to reference transcriptome GTF used when
running SQANTI3 QC.
-f REFGENOME, --refGenome REFGENOME
Full path to reference genome FASTA used when
running SQANTI3 QC.
-k REFCLASSIF, --refClassif REFCLASSIF
Full path to the classification file obtained when
running SQANTI3 QC on the reference transcriptome.
-e {all,fsm,none}, --rescue_mono_exonic {all,fsm,none}
Whether or not to include mono-exonic artifacts in
the rescue. Options include: none, fsm and all (default).
-o OUTPUT, --output OUTPUT
Prefix for output files.
-d DIR, --dir DIR Directory for output files. Default: Directory where
the script was run.
--skip_report Skip creation of a report about the filtering
-v, --version Display program version number.
-j JSON, --json JSON Full path to the JSON file including the rules used when
running the SQANTI3 rules filter.
In addition to the common arguments, the machine learning rescue requires the following specific files:
-
Pre-trained random forest classifier: using the
-r
flag, users must provide therandomforest.RData
object that was obtained when running the machine learning filter on the long read-defined transcriptome. This classifier will be used to run the ML filter on reference transcriptome isoforms, i.e. obtain an ML probability value for reference rescue targets and evaluate their likelihood to be a true isoform based on orthogonal data supplied to SQANTI3 QC. Note that, to achieve this, SQANTI3 rescue requires the classification file output after running SQANTI3 QC on the reference to be provided via the--refClassif
argument. -
ML probability threshold: minimum probability value that is required in order to consider a transcript to be a true isoform. It should be set using the
-j
flag (default: 0.7). We recommend setting the same threshold that was used when running SQANTI3 filter.
All in all, these are the arguments accepted by sqanti3_rescue.py ml
:
usage: sqanti3_rescue.py ml [-h] [--isoforms ISOFORMS] [--gtf GTF] [-g REFGTF]
[-f REFGENOME] [-k REFCLASSIF]
[-e {all,fsm,none}] [-o OUTPUT] [-d DIR]
[--skip_report] [-v] [-r RANDOMFOREST] [-j THRESHOLD]
sqanti_filter_classif
Rescue for ML-filtered transcriptomes.
positional arguments:
sqanti_filter_classif
SQANTI filter (ML or rules) output classification file.
optional arguments:
-h, --help show this help message and exit
--isoforms ISOFORMS FASTA file output by SQANTI3 QC (*_corrected.fasta),
i.e. the full long read transcriptome.
--gtf GTF GTF file output by SQANTI3 filter (*.filtered.gtf).
-g REFGTF, --refGTF REFGTF
Full path to reference transcriptome GTF used when
running SQANTI3 QC.
-f REFGENOME, --refGenome REFGENOME
Full path to reference genome FASTA used when
running SQANTI3 QC.
-k REFCLASSIF, --refClassif REFCLASSIF
Full path to the classification file obtained when
running SQANTI3 QC on the reference transcriptome.
-e {all,fsm,none}, --rescue_mono_exonic {all,fsm,none}
Whether or not to include mono-exonic artifacts in
the rescue. Options include: none, fsm and all (default).
-o OUTPUT, --output OUTPUT
Prefix for output files.
-d DIR, --dir DIR Directory for output files. Default: Directory where
the script was run.
--skip_report Skip creation of a report about the filtering
-v, --version Display program version number.
-r RANDOMFOREST, --randomforest RANDOMFOREST
Full path to the randomforest.RData object obtained when
running the SQANTI3 ML filter.
-j THRESHOLD, --threshold THRESHOLD
Default: 0.7. Machine learning probability threshold to
filter elegible rescue targets (mapping hits).
Wiki index
- Introduction to SQANTI3
- Dependencies and installation
- Version history
- Isoform classification: categories and subcategories
- Running SQANTI3 quality control
- Understanding the output of SQANTI3 QC
- IsoAnnotLite
- Running SQANTI3 filter
- Running SQANTI3 rescue
- Tutorial: running SQANTI3 on an example dataset
- Running SQANTI-reads
- Memory requirements to use parallelization