The high variability in envelope regions of some viruses such as HIV allow the virus to establish infection and to escape subsequent immune surveillance. This variability, as well as increasing incorporation of N-linked glycosylation sites, is fundamental to this evasion. It also creates difficulties for multiple sequence alignment methods (MSA) that provide the first step in their analysis. Existing MSA tools often fail to properly align highly variable HIV envelope sequences requiring extensive manual editing that is impractical with even a moderate number of these variable sequences.We developed an automated library building tool NGlyAlign, that organizes similar N-linked glycosylation sites as block constraints and statistically conserved global sites as single site constraints to automatically enforce partial columns in consistency-based MSA methods such as Dialign. This combined method accurately aligns variable HIV-1 envelope sequences. We tested the method on two datasets: a set of 156 founder and chronic gp160 HIV-1 subtype B sequences as well as a set of reference sequences of gp120 in the highly variable region 1. On measures such as entropy scores, sum of pair scores, column score, and similarity heat maps, NGlyAlign+Dialign proved superior against methods such as T-Coffee, ClustalOmega, ClustalW, Praline, HIValign and Muscle. The method is scalable to large sequence sets producing accurate alignments without requiring manual editing. As well as this application to HIV, our method can be used for other highly variable glycoproteins such as hepatitis C virus envelope.https://github.com/UNSW-Mathematical-Biology/NGlyAlign_v1.0 .NGlyAlign is an automated tool for mapping and building glycosylation motif libraries to accurately align highly variable regions in HIV sequences. It can provide the basis for many studies reliant on single robust alignments. NGlyAlign has been developed as an open-source tool and is freely available at  Generating an automated and functionally optimal multiple sequence alignment (MSA) is a challenging task in HIV or in any sequence data analysis , 2. The When determining relationships between sequences, the foundation is usually a phylogenetic tree based on a number of bootstrapped alignments of sequences, where mutational dynamics provide a basis for their evolution and relatedness. By itself this approach can lead to considerable uncertainty for investigations of the highly variable regions of HIV envelope. These regions are so variable that alignments are highly variable themselves and fail to provide a robust foundation for some analyses. Of particular concern are those investigations where a single alignment is required, rather than a statistical relationship between sequences as reflected in a bootstrapped phylogenetic tree. For example, protein structure studies using covariation of observed residues at different positions among a set of aligned sequences require a single alignment upon which to base their calculations –9. In thNXT/S], where X represents any amino acid except proline. Some of these glycans are conserved due to their functional importance, while others are highly variable, representing genetic diversity and evolution away from neutralizing antibodies against envelope glycoproteins [In a functionally correct alignment, residues with the same function should be aligned optimally, irrespective of their similarities from convergent evolution . Functioproteins . Our appA common and accepted practice in MSA is to manually enforce additional structural and functional information through expert domain knowledge. Considerable effort must be expended in manual editing these alignments, which becomes impractical for even moderate numbers of sequences when variability is high. Our central motivation is to design an automated approach that would necessitate no or limited manual editing. The approach developed here, builds an automated library of functional constraints by organizing similar glycosylation sites as block constraints and statistically conserved global sites as single site constraints. This library automatically enforces partial columns in a consistency-based method such as Dialign  and the We describe the method (NGlyAlign) and compare its performance using two HIV-1 envelope datasets, one containing gp160 sequences from both the founding infection and from an equivalent number of sequences from chronically infected individuals, and the other a reference set of HIV gp120 sequences. Compared to a number of MSA methods, our method showed better alignment of variable regions and less misalignment, that can be instrumental for coevolution and other studies.The non-variable regions of Env are sufficiently conserved that most MSA perform to a similar standard. Where they differ is in the almost arbitrary alignment in the five variable regions. Addressing this problem is our main aim. Hence we assume a suitable MSA, such as HMMER , 14 or PNGlyAlign accepts the sequences restricted to each variable region, removes the gaps inserted by the global alignment and then realigns them with the N-linked glycan constraints extracted as part of the library building procedure. To identify structural constraints, the percentage of identical residues in each global MSA column is computed. Columns with residue conservation score ≥ 99% are automatically selected as constraints. This conservation threshold can be varied to ≥95% as an option. The percentage identity is especially applicable when the sequence similarities are unknown (or highly divergent) and BLOSUM scoring cannot be applied. As an additional function, the deep scoring matrix BLOSUM50 is included and, based on the entropy in each MSA column, a structurally conserved site with entropy less than 0.85 can be selected as a constraint. An option to vary this entropy threshold is incorporated as a function for expert users. The method operates in the following three phases  can be described as an equal length (l = 3) segment over a pair of sequences s1, s2 with corresponding glycosylation starting positions α1 and α2, and priority score w  are assigned with priority score w2 otherwise, w1(<w2) for 0 < d < l. To avoid introducing too many gaps, the default search radius d is set with respect to the glycosylation motif length (d = l − 1). The resulting set of all glycosylation constraints can be viewed as a network of vertices, described by all the positions connected by block constraints, as well as the edges formed by the constraints  for which there is no alternate path from u to v and produces a minimal equivalent set of constraints  HIV-1 type subtype B , 18, gp1A second test set consisted of 91 HIV-1 subtype B sequences from the first variable region of gp120 with diverse levels of cross-reactive neutralization activity . This beWe applied the following widely used standard scores to measure quality of the alignment –28.T be a test alignment of N sequences with M columns, Tij, 1 ≤ i ≤ N, 1 ≤ j ≤ M, being compared to a reference alignment R with residues Rij, 1 ≤ i ≤ N, 1 ≤ j ≤ MR. For the j th column, if a pair of nongap residues Tij and Tkj are in the same column of the reference alignment R, then the score Pjik = 1, otherwise, Pjik = 0. The score Sj for the j th column in T isThis score measures the number of residue pairs correctly aligned in the reference alignment. Let j′ th column score SRj′ (=x(x − 1)/2 where x is the number of nongap residues in the column) isThe SPS for the full alignment with respect to the reference alignment with the T with respect to the reference alignment R divided by the total number of aligned residues in the alignment TThis is the reverse sum of pairs score and computed as the total number of residue pairs correctly aligned in j th column in the test alignment T, the column score CSj = 1, if all the residues are matched to the reference alignment R, otherwise, CSj = 0. The total column score for the full alignmentThis score is the percentage of columns where both alignments agree completely. For the mi denotes the i th column of an alignment m and pia is the probability the residue a appears in column i. Maximal entropy occurs when all residue types are represented evenly whereas zero entropy indicates invariant columns. A better alignment will tend to match residues at each position and so will minimise the sum of entropy scores over all the columns.Shannon’s information theoretic entropy is a widely used measure to assess MSA column quality –31. Entrhttp://alignstat.science.latrobe.edu.au//) and Jalview [Each program was tested with its default settings. The AlignStat R package  *100 / total number of sequences (N). Given the focus on glycosylations sites, our method performed as well or better in all glycosylation sites except for four positions and was the unique maximum at four other positions , HivAlign, Clustal Omega, and T-Coffee.NGlyAlign processed the input set and generated 426 block anchors from 396 N-linked glycosylation sites. Structurally conserved anchors were automatically identified from the global alignment by HivAlign for six fully conserved positions . Altogether, 972 anchors were used for the final alignment.For each multi-alignment tool, parameters such as alignment length, percentage of gaps and conservation score , 1.8% higher than HIVAlign, 6.3% higher than Clustal Omega and 1.4% higher than T-Coffee  also exhibits highly variable regions and is heavily glycosylated . As withNGlyAlign is an automated tool that builds glycosylation motif libraries and accurately aligns highly variable regions in HIV sequences by creating partial columns in consistency-based MSA methods such as Dialign. We propose that NGlyAlign can provide essential basis for many studies reliant on single robust alignments.Additional file 1. NGlyAlign tool in matlab along with a test file and manual is included as additional files.


AlignmentViewer is a web-based tool to view and analyze multiple sequence alignments of protein families. The particular strengths of AlignmentViewer include flexible visualization at different scales as well as analysis of conservation patterns and of the distribution of proteins in sequence space. The tool is directly accessible in web browsers without the need for software installation. It can handle protein families with tens of thousands of sequences and is particularly suitable for evolutionary coupling analysis, e.g. via EVcouplings.org. Multiple sequence alignment (MSA) analysis  and visualization allows researchers to extract information and gain a better understanding of protein families. MSA is a basic step in many protein analysis workflows, including 3D structure prediction  in-browser and serverless execution, (ii) visualization of very large MSAs, (iii) visualization of conservation patterns, (iv) sequence filtering, (v) logo display, (vi) pairwise sequence identity map, (vii) sequence space exploration by UMAP dimensionality reduction, and (viii) display of top-ranked evolutionary couplings (https://doi.org/10.1101/269720); additional features have been implemented since the earlier version.An earlier version of this article can be found on bioRxiv  to produce dynamic and interactive data visualizations, with performance (speed) for large alignments a major consideration. The tool is entirely client-based, running inside a web browser without the need for server-side computation.https://alignmentviewer.org/?url=https://alignmentviewer.org/example/1bkr_A.1-108.msa.txt), enabling seamless integration from external web services via a simple link . Thepixel view gives an overview display of the alignment to enable a coarse view of the alignment for better visualization and pattern identification. The all versus all sequence identity sub-figure instats view) displays allows users to identify possible clusters in the alignment based on sequence identity. The bottom right sub-figure ofSequence space) highlighted by user-provided annotations to aid in interpretation of the clusters.Alignment details. Themsa view page has summary information: number of sequences, conservation and gap counts for each position, a sequence logo, and the residues in one letter code. By default, columns with gaps in the reference sequence (first row) are omitted in order to facilitate visual focus on sequence patterns relative to a protein of interest and to avoid extremely gapped alignment views typical of many MSA presentations. The amino acids are colored using a conventional coloring scheme, adopted from Mview, based on amino acid properties.Sequence attributes and sorting. Sequences in the alignment can be sorted using one of four different methods: (i) the original order provided by the user, (ii–iii) by % sequence identity between a particular sequence and the reference (top) sequence, relative to the first or the second (gaps not counted), and (iv) by user-provided (upload annotations tab) sequence weights or other attributes, such as alignment profile scores . Sequences can be filtered by sequence identity relative to a reference sequence or by percentage of gaps.pixel view (image view website tab) leads to an overview of the entire depth and breadth of an MSA. The amino acid letters are represented by small rectangles of pixels, retaining the amino acid type coloring (image view tab). This striking visual impression can reveal patterns of conservation and variation, especially for large alignments. This is very useful to gain an intuitive view of sequence properties, noise at the uncertain edges of a protein family, as well as subfamily distributions. The coloring scheme can be by (1) amino acid properties, (2) hydrophobicity (red to blue) or (3) mutational difference (stronger color) in a sequence relative to the reference (first row) sequence.Thestats view tab leads to plots of statistical properties of the set of sequences in the alignment, including (i) sequence identity relative to the reference sequence, and (ii) min, max, and average of (i); and (iii) a pairwise sequence identity matrix in which each pixel represents the degree of similarity between two sequences, such that a block-diagonal structure of the matrix is indicative of distinct subfamilies, given, e.g., a tree-derived sequence order as user input. The ordering of sequences by phylogeny is (currently) not part of the tool and can be performed using external tools, e.g., Wasabi (Theupload annotations) or evolutionary couplings between residue positions (load couplings). Adding these attributes allows users to use sequence weights, compare different measures of sequence fitness  or visualize evolutionary coupling constraints for pairs of positions.Users can upload custom numerical attributes or labels for the sequences in the MSA (umap-js library (https://github.com/PAIR-code/umap-js). The alignmentviewer.org implementation uses the number of amino acid differences between pairs of sequences (the Hamming distance) as the distance metric parameter. The algorithm then iteratively calculates an embedding in two- or three-dimensional space, which is displayed in real time for the end users. UMAP hyperparameters are set to reasonable defaults, but can also be configured via the settings panel. Sequences can be colored by user provided annotations ("upload annotations" tab).Users can view representations of the MSA sequences in two- or three-dimensional space under the “sequence space” tab. These representations are generated using the Uniform Manifold Approximation and Projection (UMAP) dimensionality reduction algorithm  provided to allow replication of the software development and its use by others?PartlyIs sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?YesReviewer Expertise:Computational biology with specialism in biological databases and analysis of protein families.I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Overall there is a need for Javascript based alignment viewers which can handle large numbers of sequences. So this software is rather timely. However, I think the current implementation seems to still contain significant bugs and the web page requires a round of user experience testing to make it easier to use and interpret the results. Once these improvements are made then I think this has the potential to be a very useful tool.Manuscript changes: Please fix capitalisation of PFAM to PfamSoftware/Website changes: The computing conservation box is annoyingly placed. It does not go away and covers the UMAP view significantly. I really need an estimate of how long it will take for the pairwise identity to load. Some time passes…I didn’t realise I had to click on calculate to get the pairwise identity to show. Please UX test this page to make it easier/clearer for the user to understand what to do.   For the top graph on the stats view the three colours used for max/average and min identity are hard to distinguish. Please use a broader colour palette. Please add axis legends for this graph and make it clearer what the title of this graph is. The title is very clear for the bottom plot. Please add alternative colouring schemes for viewing the alignments. It makes a surprisingly big difference for experienced users ability to interpret an alignment. I personally like the ClustalX colouring scheme that is widely adopted, but there are other popular schemes it would be nice to incorporate as options. “Based on this and other small tests we can safely state that any computer that is able to run any modern web browser will be able to run any alignment that requires visualization”. This is overstating the case. Needs to be toned down. Try testing the software on the ABC transporter family (PF00005) alignment in Pfam. The NCBI alignment contains 2.6 million sequences. If it works seamlessly for that then you can safely state. I tried to hook the viewer up to a Pfam alignment which is not very large (840 sequences). I got a box that said Fetching file…and no response beyond that. https://alignmentviewer.org/?url=http://pfam.xfam.org/family/PF00571/alignment/seed/format?format=fasta&alnType=seed&order=t&case=l&gaps=default&download=0 also tried Stockholm format with no luck. https://alignmentviewer.org/?url=http://pfam.xfam.org/family/PF00571/alignment/seed/format?format=stockholm&alnType=seed&order=t&case=l&gaps=default&download=0 I also tried with a Pfam family with just 3 sequences. Still with no luck. I got the viewer to work by uploading a Pfam alignment in fasta format with 3 sequences. Then I tried uploading the seed alignment for the CBS domain downloaded from Pfam in fasta format. I then got the following error: Parsing error: sequence #3 has different length. The first few lines of the alignment are included below and the third sequence appears to be the same length as all the others. >Q8EHI4_SHEON/79-134 I........H.Q...V........MTR........NP.........V.......TVAPY. ...VS.LDVAS....RT..L.....L....E.....HN..I.....G..CL.P.V.L... .........ENG....D......LV.GIVTWKDLLRAYCA >Q97V95_SULSO/193-248 V........L.D...A.......G.TK........NP.........I.......TINRY. ...YS.ILNAA....KL..M.....I....E.....KR..I.....G..TL.L.V.M... .......E..NQ....K......LV.GIVTERDLMYAYIN >Q6M020_METMP/269-321 V........K.E...I.........MS........PP.........V.......MVSPE. ...AA.LNELI....KG..M.....A....N.........T.....D..RV.Y.V.V... .........DNG....N......IL.GIISKTDIVRTLSI >Q72KI1_THET2/367-424 V........E.G...F.........LA........RA.........V.......VLPPS. ...TP.LSQVE....PR..L..........R.....EA..G.....G..RV.L.V.GE.. .......RAGEG...WR......LL.GIYTRTDLYRSAPK >Q8TX96_METKA/244-298 A........R.N...Y.......L..Q........EM.........V.......VVPPE. ...TP.LHEAL....WE..V.........ID.....KM..S.....D..RI.Y.V.M... ..........DG.....R....KLT.GVVPLIDAVYTLAK >Q836T2_ENTFA/77-132 V........Q.E...I........MSP........PL.................MVAQD. ...TS.IRDAI....TN..L................FMYDV.....G..SL.Y.V.M... ........DEAK....E......LL.GVLSRKDLLRASLN >Q8XIV1_CLOPE/77-131 V........K.D...I.........MS........KP.........V.......TVCEE. ...TM.LHDAI....VH.LF.....L...ND.........V.....G..TM.F.VEN... ..........GG....V......LT.GAVSRKDFLKVAIG If I delete the third sequence and re-upload I get exactly the same error. For info I carried out tests with Firefox for Mac version 74.0 and Safari Version 13.1Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?PartlyIs the rationale for developing the new software tool clearly explained?YesIs the description of the software tool technically sound?YesAre sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?PartlyIs sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?YesReviewer Expertise:Computational biology with specialism in biological databases and analysis of protein families.I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above. Manuscript changes:Please fix capitalisation of PFAM to PfamResponse: The manuscript has been updated to Pfam.Software/Website changes:The computing conservation box is annoyingly placed. It does not go away and covers the UMAP view significantly.Response: This bug has now been fixed - the pop-up will disappear after the alignment has been loaded.I really need an estimate of how long it will take for the pairwise identity to load. Some time passes…I didn’t realise I had to click on calculate to get the pairwise identity to show. Please UX test this page to make it easier/clearer for the user to understand what to do.  Response: We have added a button into the middle of the plot to indicate that an action needs to be taken by the user to begin calculating pairwise sequence identity.For the top graph on the stats view the three colours used for max/average and min identity are hard to distinguish. Please use a broader colour palette. Please add axis legends for this graph and make it clearer what the title of this graph is. The title is very clear for the bottom plot.Response: We have updated the color palette to increase the contrast, added axis labels and added a clear title. Please add alternative colouring schemes for viewing the alignments. It makes a surprisingly big difference for experienced users ability to interpret an alignment. I personally like the ClustalX colouring scheme that is widely adopted, but there are other popular schemes it would be nice to incorporate as options.Response: We agree alternative coloring schemes are useful and have added the clustal colors as a drop-down option on the main page as well as in the image view.“Based on this and other small tests we can safely state that any computer that is able to run any modern web browser will be able to run any alignment that requires visualization”. This is overstating the case. Needs to be toned down. Try testing the software on the ABC transporter family (PF00005) alignment in Pfam. The NCBI alignment contains 2.6 million sequences. If it works seamlessly for that then you can safely state.Response: We agree with the reviewer that the phrasing was optimistic and have removed the sentence from the main manuscript.I tried to hook the viewer up to a Pfam alignment which is not very large (840 sequences). I got a box that said Fetching file…and no response beyond that.https://alignmentviewer.org/?url=http://pfam.xfam.org/family/PF00571/alignment/seed/format?format=fasta&alnType=seed&order=t&case=l&gaps=default&download=0also tried Stockholm format with no luck.https://alignmentviewer.org/?url=http://pfam.xfam.org/family/PF00571/alignment/seed/format?format=stockholm&alnType=seed&order=t&case=l&gaps=default&download=0Response: There are two technical limitations inherent to how requests happen in the browser. We take as an example your suggested URL:https://alignmentviewer.org/?url=http://pfam.xfam.org/family/PF00571/alignment/seed/format?format=stockholm&alnType=seed&order=t&case=l&gaps=default&download=0https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) is not allowed.Limitation 1: The alignmentviewer.org website is hosted as a secure site under https. However, the location of the requested alignment (from Pfam) is passed via an insecure connection (http). For security reasons mixing different protocols  needs to be sanitized before being served. More information about this can be found here:http://pfam.xfam.org/family/PF00571/alignment/seed/format?format=stockholm&alnType=seed&order=t&case=l&gaps=default&download=0". Passing the string as-is will confuse the browser that will interpret e.g. "&gaps=" as query for alignmentviewer rather than forpfam.xfam.org . Many languages offer built-in functions to sanitize strings to be passed to URL queries . By doing so, the string proposed for the alignment would result in: "http%3A%2F%2Fpfam.xfam.org%2Ffamily%2FPF00571%2Falignment%2Fseed%2Fformat%3Fformat%3Dstockholm%26alnType%3Dseed%26order%3Dt%26case%3Dl%26gaps%3Ddefault%26download%3D0".In your example, the alignment lives at "Conclusion: considering the two inherit browser limitations mentioned above, your requests can be sanitized and fixed as follows:https://alignmentviewer.org/?url=https%3A%2F%2Fpfam.xfam.org%2Ffamily%2FPF00571%2Falignment%2Fseed%2Fformat%3Fformat%3Dfasta%26alnType%3Dseed%26order%3Dt%26case%3Dl%26gaps%3Ddefault%26download%3D0Again, note that for both URLs the protocol has been changed to "https" instead of "http", and that the string that follows "&url=" has been sanitized using Chrome's built-in console and the "window.encodeURIComponent(x)" function, where x is the string to be sanitized. We have added some text to the manuscript to highlight these requirements.I also tried with a Pfam family with just 3 sequences. Still with no luck.I got the viewer to work by uploading a Pfam alignment in fasta format with 3 sequences. Then I tried uploading the seed alignment for the CBS domain downloaded from Pfam in fasta format. I then got the following error:Parsing error: sequence #3 has different length.The first few lines of the alignment are included below and the third sequence appears to be the same length as all the others.>Q8EHI4_SHEON/79-134I........H.Q...V........MTR........NP.........V.......TVAPY....VS.LDVAS....RT..L.....L....E.....HN..I.....G..CL.P.V.L............ENG....D......LV.GIVTWKDLLRAYCA>Q97V95_SULSO/193-248V........L.D...A.......G.TK........NP.........I.......TINRY....YS.ILNAA....KL..M.....I....E.....KR..I.....G..TL.L.V.M..........E..NQ....K......LV.GIVTERDLMYAYIN>Q6M020_METMP/269-321V........K.E...I.........MS........PP.........V.......MVSPE....AA.LNELI....KG..M.....A....N.........T.....D..RV.Y.V.V............DNG....N......IL.GIISKTDIVRTLSI>Q72KI1_THET2/367-424V........E.G...F.........LA........RA.........V.......VLPPS....TP.LSQVE....PR..L..........R.....EA..G.....G..RV.L.V.GE.........RAGEG...WR......LL.GIYTRTDLYRSAPK>Q8TX96_METKA/244-298A........R.N...Y.......L..Q........EM.........V.......VVPPE....TP.LHEAL....WE..V.........ID.....KM..S.....D..RI.Y.V.M.............DG.....R....KLT.GVVPLIDAVYTLAK>Q836T2_ENTFA/77-132V........Q.E...I........MSP........PL.................MVAQD....TS.IRDAI....TN..L................FMYDV.....G..SL.Y.V.M...........DEAK....E......LL.GVLSRKDLLRASLN>Q8XIV1_CLOPE/77-131V........K.D...I.........MS........KP.........V.......TVCEE....TM.LHDAI....VH.LF.....L...ND.........V.....G..TM.F.VEN.............GG....V......LT.GAVSRKDFLKVAIGIf I delete the third sequence and re-upload I get exactly the same error.For info I carried out tests with Firefox for Mac version 74.0 and Safari Version 13.1Response: Thank you for pointing out this issue. This bug occurred when refreshing an internal variable, and has now been fixed. This Software Tool article, describing a web-based sequence alignment viewer (AlignmentViewer), is well-written and very clearly presented. The introduction nicely motivates the need for this tool, given the many other available alternatives. The main features of the software are clearly explained in the article. The tool in itself seems useful and ran quickly and efficiently when tested on sample data. I have only a few minor comments that may be considered by the authors:Minor:A little bit of detail may be added to the “Sequence space” section. “Two- or three-dimensional sequence space” is at first a bit confusing, as no information has been given at that stage as to what it means. How is UMAP applied to the Hamming distances? Is each sequence first represented by a vector of Hamming distances, with each element corresponding to one of the included sequences? Maybe this can be clarified with a few additional words.Figure 1 shows the main functionalities from AlignmentViewer  explained in more detail in the next subsections.”The following sentence is somewhat confusing: ""This view lets the user examine in depth the alignment.” - should it be “examine the alignment in depth"?When loading an alignment using a somewhat older version of Safari (12.1.2), the “computing conservation” window does not disappear after the operation finishes. This problem was absent in Chrome.Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?YesIs the rationale for developing the new software tool clearly explained?YesIs the description of the software tool technically sound?YesAre sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?YesIs sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?YesReviewer Expertise:Genomics, bioinformaticsI confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Thank you for your comments and suggestions - they are spot on.We will work on taking these into account on the web site and in the next version of the manuscript.Chris Sander - DFCI and HMS A little bit of detail may be added to the “Sequence space” section. “Two- or three-dimensional sequence space” is at first a bit confusing, as no information has been given at that stage as to what it means. How is UMAP applied to the Hamming distances? Is each sequence first represented by a vector of Hamming distances, with each element corresponding to one of the included sequences? Maybe this can be clarified with a few additional words. Response: We agree that a bit more detail is warranted and have updated the manuscript that describes using the hamming distance between individual sequences as the distance metric (parameter) for UMAP. The following sentence is somewhat confusing: "Figure 1 shows the main functionalities from AlignmentViewer  explained in more detail in the next subsections.”Response: We have updated the manuscript to make it more understandable. The citation to Reguant 2020 was also confusing (it points to the codebase) so we moved that codebase DOI to a single instance at the end of the manuscript. "This view lets the user examine in depth the alignment.” - should it be “examine the alignment in depth"?Response: The manuscript has been corrected. When loading an alignment using a somewhat older version of Safari (12.1.2), the “computing conservation” window does not disappear after the operation finishes. This problem was absent in Chrome.Response: Thank you for noticing this bug. We have now corrected the issue and the dialog disappears when using Safari.


Genome graphs can represent genetic variation and sequence uncertainty. Aligning sequences to genome graphs is key to many applications, including error correction, genome assembly, and genotyping of variants in a pangenome graph. Yet, so far, this step is often prohibitively slow. We present GraphAligner, a tool for aligning long reads to genome graphs. Compared to the state-of-the-art tools, GraphAligner is 13x faster and uses 3x less memory. When employing GraphAligner for error correction, we find it to be more than twice as accurate and over 12x faster than extant tools.Availability: Package manager: https://anaconda.org/bioconda/graphalignerand source code: https://github.com/maickrau/GraphAligner Graphs provide a natural way of expressing variation or uncertainty in a genome , 2. TheySequence alignment is one of the most fundamental operations in bioinformatics and necessary for a wide range of analyses. Aligning a sequence to a sequence is a well-studied problem with many highly optimized tools –15. In cpartial order alignment +o. Then, chaining algorithms for linear sequence alignment can be used for chaining the seed hits. We use the seed clustering algorithm from minimap [r in the read and a linearized position b in the chain of superbubbles, define the diagonal position of the seed hit as d=r−b. Then, two seeds in the same chain of superbubbles whose diagonal positions d1 and d2 are within a cutoff c=100, that is, |d1−d2|≤c, are connected together. The transitive closure of the connected seeds is the cluster.Given a chain of superbubbles, we can assign all seed hits in the chain a linear position. A position at offset  minimap , not to  minimap , to assix times in the graph, and a maximum occurrence m, the unclustered score of the seed hit i is C, we calculate the number of base pairs in the read covered by at least one seed cC. The score of a seed hit that belongs in cluster C will then be si=si′+cC.Then, seed hits are scored according to their cluster size and uniqueness, with matches that occur fewer times in the graph weighted higher. Given a seed hit whose sequence occurs The seed hits are ordered based on their clustered scores and extended from best scoring to worst scoring. Since the seed hits are not clustered arbitrarily across the graph, but only in simple subgraphs, the seed hit clustering is not used for limiting the paths explored or deciding when to end the alignment. The alignment algorithm used for the extension step instead decides which paths to explore and when to end the alignment  algorithm to extend the seeds. The starting point of the DP is the well known Needleman-Wunsch algorithm for sequence alignment . This alDP matrix whose scores describe the edit distance of an alignment ending at a specific position in the read and a specific position in the graph. The calculation proceeds in a sliced manner, first calculating a horizontal slice of the topmost 64 rows, then calculating the next topmost slice and so on. For details on how to calculate the DP matrix for graphs in a bit-parallel manner, we refer the reader to [banded alignment [In short, the algorithm calculates a eader to . In the lignment  to graphO(logw) algorithm for merging two w-bit sized bitvectors. We have refined this operation further and created an algorithm which is much faster in practice but with a theoretically slower runtime of O(w). In practice, the O(w) algorithm takes on average around 50 instructions per merge, while the O(logw) algorithm takes on average around 300 instructions per merge for 64-bit bitvectors. The code and detailed explanation of the merging algorithm is Additional file The DP extension algorithm requires merging bitvectors at nodes with an in-degree of at least two. In our previous work , we descb and a start column p, a cell at row x and column y is calculated if |x+y−p|≤b. The width of the parallelogram is 2b, and the optimal alignment is guaranteed to be found if it has at most b errors. The runtime of the alignment is now O(nb) where n is the length of the query sequence. The runtime no longer depends on the size of the reference, leading to a large speedup.In sequence-to-sequence alignment, banded alignment , 62 is aThe parallelogram technique cannot be used in graphs due to the non-linear structure. At each fork, the parallelogram should continue to both paths. This would mean that the size of the band could grow very large, and the bookkeeping involved in tracking the band would introduce heavy overhead, possibly exponential to the size of the graph.Recently, a dynamic banding approach was proposed for linear sequence alignment . The appm and define a cell to be inside the band if its score is at most m+b. This handles arbitrary graph topologies with very little bookkeeping and no special cases. Figure m+b, at which point the cell is out of band.Instead, we introduce a novel dynamic banding approach based on the scores in the DP matrix. The principle is that for each row, we find the minimum score Figure The dynamic banding introduced here is not symmetric between the query and the reference. That is, when aligning two linear sequences, the band will be different depending on which sequence is the query and which is the reference. However, the sequence-to-graph mapping algorithm already introduces an asymmetry since the graph must be the reference.m is found. Then, a block in the DP matrix is inside the band if the score of any cell in the block is at most m+b.Due to the bitvector-based calculation, the implementation is slightly different from the theoretical description above. The band is defined over blocks in the DP matrix see Fig.  instead b represents a score difference, the score guarantee is now stronger than in the linear case. The optimal alignment is found as long as the optimal alignment’s score at any row is within b of the minimum score of that row. This trivially includes the case that the optimal alignment has b errors.Since b. This means that the score-based banding can lead to an impractically large band in certain cases. In an unrealistic extreme case, a fully connected graph will be entirely included in the band even with b=1 and regardless of the graph size. But also in practice, human whole genome de Bruijn graphs contain highly complex subgraphs  reads to either the correct or the wrong genomic position, using the assumption that the errors of reads to be processed are at most as high as for these ONT reads. The probabilities of the correct and wrong states and their predecessor states are calculated for each slice during alignment. After calculating slice n+1, we define slice n as guaranteed correct if the predecessor of the wrong state in slice n+1 is the correct state in slice n. The intuition behind this is that any alignment in slices n+1 and later, correct or wrong, must backtrace through the correct state at slice n, so the read is correctly aligned at least until that point. We also similarly define a slice n as guaranteed wrong when predecessor for the correct state in slice n+1 is the wrong state in slice n. Figure During alignment, we use Viterbi’s algorithm  to estimb and a ramp banding parameter B>b. Once the probability of the wrongly aligned state is higher than the probability of the correctly aligned state, we backtrace to the last guaranteed correct slice, switch to the higher ramp banding parameter, and re-align until we have reached the original slice. Note that this is a looser condition than reaching a guaranteed wrong slice.We use the correctness estimate to vary the banding parameters. We use two parameters, an initial banding parameter We also use the Viterbi estimate to end the alignment. Once we have reached a guaranteed wrong slice, the extension can no longer produce anything useful. In this case, we backtrace to the last correct slice and return the partial alignment of the read up to that position.After extending the seed hits, we are left with a list of partial alignments. We then select a non-overlapping subset of primary and supplementary alignments in a heuristic manner. We greedily pick alignments from longest to shortest and include an alignment as long as it does not overlap with a previously picked alignment. The primary and supplementary alignments are then written as output. The overlapping alignments are considered secondary and discarded by default, with an optional switch to output secondary alignments as well.All experiments were ran on a computing server with 48 Intel(R) Xeon(R) E7-8857 v2 CPUs and 1.5Tb of RAM. Every program was given 40 threads in the command line invocation. Runtime and memory use was measured with “/usr/bin/time -v” in all experiments.In the linear comparison experiment, we ran minimap2 with the command “minimap2 -x map-pb -a -t 40,” corresponding to the recommended parameters for PacBio reads and 40 threads. We ran GraphAligner with “GraphAligner -t 40 -x vg,” using 40 threads and our recommended parameters for variation graphs. We used minimap2 version 2.17-r941 and GraphAligner version 1.0.11. Reads were considered to be correctly aligned if the position of their longest alignment overlapped at least 10% with the genomic position from where the read was simulated.In the variant graph experiment, we constructed the graph with the command “vg construct -a -r chr22.fa -v chr22.vcf -p -t 40 -m 3000000.” We ran GraphAligner with the command “GraphAligner -t 40 -x vg,” using 40 threads and our recommended parameters for variation graphs. We used GraphAligner version 1.0.11. The genomic interval of the alignment was calculated only from the parts of the alignment which covered a reference node. That is, parts of the alignment path which corresponded to a non-reference variant were ignored, and the reference interval was taken as the minimum and maximum of the reference positions covered by the alignment. Reads were considered to be correctly aligned if the position of their longest alignment’s genomic interval overlapped at least 10% with the genomic position from where the read was simulated.To evaluate the alignment accuracy of the reads simulated from de novo assembled contigs, we lifted over their coordinates to the GRCh37 reference chromosome 22 using minimap2 . We firsIn the vg comparison experiment, we used the graph from the variant graph experiment. We ran GraphAligner with the command “GraphAligner -t 40 -x vg,” using 40 threads and our recommended parameters for variation graphs. For vg, we first preprocessed the graph as suggested by vg documentation with the commands “vg mod -X 256” and “vg prune.” The runtime of the preprocessing was not included in the results. We indexed the graph with the command “vg index -t 40 -x chr22.xg -g chr22.gcsa” using 40 threads to construct the indices required for mapping. We mapped the reads with the command “vg map -t 40 -m long,” using 40 threads and parameters for long read alignment. We used vg version 1.23.0. Read alignment accuracy was evaluated the same way as in the variation graph experiment. Note that the evaluation method only distinguished whether the read alignment overlapped with the correct genomic interval and does not evaluate the correctness otherwise. In particular, alignments whose path in the graph is not consistent with graph topology, such as aligning to both branches of a SNP  of the variant set from Lowy-Gallego et al. [Additional file 1 Supplementary information to GraphAligner: rapid and versatile sequence-to-graph alignment. Details and pseudocode of the O(w) bitvector merging algorithm and additional figures.Additional file 2 Review history.


Ancestral sequence reconstruction (ASR) uses an alignment of extant protein sequences, a phylogeny describing the history of the protein family and a model of the molecular-evolutionary process to infer the sequences of ancient proteins, allowing researchers to directly investigate the impact of sequence evolution on protein structure and function. Like all statistical inferences, ASR can be sensitive to violations of its underlying assumptions. Previous studies have shown that, whereas phylogenetic uncertainty has only a very weak impact on ASR accuracy, uncertainty in the protein sequence alignment can more strongly affect inferred ancestral sequences. Here, we show that errors in sequence alignment can produce errors in ASR across a range of realistic and simplified evolutionary scenarios. Importantly, sequence reconstruction errors can lead to errors in estimates of structural and functional properties of ancestral proteins, potentially undermining the reliability of analyses relying on ASR. We introduce an alignment-integrated ASR approach that combines information from many different sequence alignments. We show that integrating alignment uncertainty improves ASR accuracy and the accuracy of downstream structural and functional inferences, often performing as well as highly accurate structure-guided alignment. Given the growing evidence that sequence alignment errors can impact the reliability of ASR studies, we recommend that future studies incorporate approaches to mitigate the impact of alignment uncertainty. Probabilistic modeling of insertion and deletion events has the potential to radically improve ASR accuracy when the model reflects the true underlying evolutionary history, but further studies are required to thoroughly evaluate the reliability of these approaches under realistic conditions. Ancestral sequence reconstruction is a powerful technique for directly investigating the sequence, structure and function of ancient molecules to better understand molecular-evolutionary processes. However, ancestral reconstruction may not always be accurate under challenging conditions that make it difficult to correctly align protein sequences. We found that integrating information from many different alignment methods can produce reliable ancestral sequence reconstructions, even when the individual protein alignments have many errors. Our study suggests alignment-integrated methods may be an important approach for improving ancestral sequence reconstruction accuracy under challenging conditions.Aside from happening upon a piece of preserved ancient DNA  or reverSome studies have suggested that there may be a trade-off between sequence reconstruction accuracy and the accuracy with which some structural and functional properties of the sequence can be inferred . SpecifiOne recent study found that the alignment of extant protein sequences forming the basis for phylogenetic inference and ASR can have a potentially strong affect on ASR accuracy . That ASHere, we develop and evaluate a novel ASR approach that combines information from many different sequence alignments to infer “alignment-integrated” ancestral sequences. Although this approach does not completely eliminate the impact of alignment errors on ASR accuracy, we found that integrating sequence alignments reduces both ASR errors and errors in the structural and functional properties of inferred ancestral sequences, often performing as well as structure-guided sequence alignment. Our study suggests that, particularly for cases in which diverse structures of different protein family members are not available to guide the alignment process, integrating different alignments can be a reliable approach for mitigating the impact of alignment errors on ASR accuracy.To assess the impact of alignment errors on ASR accuracy, we used structural alignments of individual protein domains to simulate sequence data along empirical domain-family phylogenies see  online, t-test P = 6.41e−4), and the number of gaps by 1.2-fold (P = 1.69e−3). The proportion of variable sites was overestimated by 1.8-fold (P = 4.97e−19), and the proportion of parsimony-informative sites was overestimated by 1.9-fold (P = 2.28e−13). Structure-guided alignments were no different from sequence-alignment methods in any of the calculated alignment attributes (t-test P > 0.10), suggesting structure-guided and sequence-alignment methods tend to make similar errors in alignment length and the numbers of variable and parsimony-informative sites.In general, both sequence-alignments and structure-guided alignments underestimated the correct alignment length by placing fewer gaps in the alignment, resulting in overestimation of the proportion of variable and parsimony-informative positions  online. t-test P < 0.034). Across all alignment methods, the caspase activation and recruitment domain (CARD) protein domain family’s correct alignment length was underestimated to a greater degree (1.9-fold) than the other protein domain families . In contrast to this general trend of alignment length underestimation, mafft, probalign and tcoffee tended to overestimate the lengths of the correct DSRM1 and DSRM2 protein domain family alignments . These results suggest different alignment methods produce different types of alignment errors for different protein domain families. However, variation in alignment accuracy across replicate data sets of the same protein domain family was low, with the standard deviation (SD) never exceeding 11% of the inferred mean value of each alignment attribute . Across protein domains, structure-guided alignments were >1.25-fold closer to the correct alignment than any of the sequence-alignment methods (t-test P < 0.033). There were no detectable systematic differences in alignment distances among sequence-alignment methods, which produced average distances between 0.24 (msaprobs and probcons) and 0.43 .We quantified the distance of each inferred alignment from the correct simulated alignment using a position-wise distance metric, which estimates the probability that a randomly selected residue from a randomly selected sequence was aligned to an incorrect residue from another randomly selected sequence . In geneOverall, these results suggest the test cases used in this study cover a range of alignment difficulties that do not strongly favor particular sequence-alignment algorithms over others and represent a reasonable test suite for assessing the impact of alignment errors on ASR under realistic conditions. Structure-guided alignment methods have been shown to out-perform sequence-alignment in previous studies , which hEach set of empirical simulation conditions  was used to generate replicate correctly aligned extant protein sequences at the tips of the phylogeny and correct ancestral sequences at every internal node. We assessed ASR error rates at each node on the phylogeny by comparing the ancestral sequence inferred using only an alignment of the extant protein sequences to the correct simulated ancestral sequence at that node. Three types of ASR errors were considered: 1) residue errors, in which both the inferred and correct ancestral sequences have an amino-acid residue at the given alignment position, but the residues differ; 2) insertion errors, in which the inferred ancestral sequence has a residue at the given alignment position, but the correct ancestral sequence has a gap character (“−”), and 3) deletion errors, in which the inferred ancestral sequence has a gap character, but the correct ancestral sequence has an amino-acid residue. The ASR error rate for an inferred ancestral sequence was calculated as the number of ASR errors, divided by the length of the pairwise alignment of the correct to the inferred ancestral sequence (i.e. errors/site). The expected ASR error rate for a given ancestral node was calculated as the mean error rate over replicates.Given a sequence alignment, phylogenetic tree and statistical model of the molecular-evolutionary process, reconstruction of the most likely residue at each position in the alignment and node on the phylogeny has been well-described, as has the assessment of statistical confidence in the residue reconstruction . However−3 errors/site) was slightly worse than the rate of erroneous insertions (8.49e−4 errors/site) or deletions . This pattern was generally observed across all the protein domain families (−3) slightly lower than the rate of erroneously inferred insertions (3.55e−3) or deletions (3.44e−3), and these differences were not statistically significant (t-test P > 0.31). For all other domain families, residue reconstruction error rates were slightly higher than indel reconstruction error rates (P < 0.039). These results suggest site-wise MAP reconstruction of ancestral gap states—although failing to accurately model statistical dependencies among contiguous gaps . Even when structure-guided alignments were used to infer ancestral sequences, total ASR error rates were 4.4-fold higher than when the correct alignment was known in advance (t-test P < 6.84e−3). These results were generally consistent across ASR error types and protein domain families (t-test P < 0.013), and indel errors increased by 12.3- and 12.7-fold, respectively (t-test P < 4.37e−3). In all cases, structure-guided alignments produced ancestral sequences that had >1.5-fold fewer errors than sequence-alignment methods (t-test P < 8.43e−3).When the alignment is not known in advance and must be inferred from the sequence data, we found errors in ASR were higher overall and increased with increasing distance from the correct alignment  online. families  online. r2 > 0.78, mean r2 = 0.88). Similarly high correlations were observed for rates of insertion and deletion errors . However, residue errors were less strongly correlated with the distance from the correct alignment (mean r2 = 0.55), largely because muscle and probcons residue-errors were only very weakly correlated with alignment distance (r2 < 0.23). Interestingly, whereas error rate increased with alignment distance at roughly the same rate for alignment algorithms other than ClustalW , ClustalW’s total ASR error rate increased much more rapidly as the alignment diverged from the correct alignment . ClustalW’s ASR error rates were generally higher than the other alignment methods, even at comparable alignment distances . Although alignment-integrated ASR always generated fewer errors in residue and deletion reconstructions, improvements in these types of ASR errors were generally small and not always statistically significant. The fold-improvement in residue reconstruction error rates ranged from 1.1  to 1.8 , whereas the improvement in deletion error rates ranged from 1.1-fold  to 2.1-fold . The most dramatic reduction in ASR error rate was observed for insertion errors, for which alignment–integration improved error rates by >2.9-fold, compared with single sequence-alignment methods (t-test P < 7.04e−3).We found that integrating information from many sequence-alignment algorithms reduced ASR error rates, compared with relying on any single sequence-alignment method  online. t-test P < 0.022). In the case of the DSRM3 and RNA recognition domain (RD) families, the improvement in total ASR error rate was not always statistically significant, compared with some of the sequence-alignment methods. In both cases, mafft, msaprobs, muscle, and probcons were statistically equivalent to alignment–integration (t-test P > 0.057), and probalign was equivalent to alignment–integration for the RD family (t-test P = 0.063).The same general pattern was consistently observed across all of the protein domain families examined in this study  online: These results suggest integrating over different sequence-alignment methods generally improves the accuracy of ASR, compared with choosing a single sequence-alignment method, primarily by reducing the rate of erroneously inferred insertions. The improvement in total ASR accuracy may be small for highly conserved protein families or other scenarios in which sequence-based alignments are generally accurate.t-test P = 0.035), even though each of the individual sequence-alignments was farther away from the correct alignment than was the structure-guided alignment (see t-test P = 0.059), the same number of deletion errors (t-test P = 0.088), and 3.0-fold fewer insertion errors (t-test P = 7.68e−3). This improvement in insertion error rate was observed for all domain families except the RD . These results suggest alignment–integration is a promising technique for reducing ASR error rates, even for protein families for which diverse structural data are not available to generate structure-guided alignments.Interestingly, integrating over many sequence-alignments slightly improved ASR error rates, even compared with the highly accurate structure-guided alignment approach. Overall, total ASR error rates were reduced by 1.2-fold using alignment–integration, compared with structure-guided alignment , whereas PRANK alignments generated using a similar indel model (but without conditioning on the correct phylogenetic tree topology) resulted in among the least accurate ancestral sequences . Interestingly, this strong similarity between the alignment-integrated approach and the correct alignment was primarily confined to residue errors, for which alignment–integration produced an average PP of 0.59, and the correct alignment’s mean PP was 0.57 (P = 0.093). In the case of insertion or deletion errors, the correct alignment produced low average PPs for erroneously inferred ancestral states (<0.43), whereas alignment–integration’s PPs were much higher . Even in these cases, however, alignment–integration produced much more weakly supported errors than any single sequence-alignment or structure-guided alignment, whose mean PPs for erroneously inferred ancestral states were always >0.9 (t-test P < 8.15e−3).We found that integrating many sequence-alignment methods, in addition to reducing ASR error rates, also reduced the PPs of erroneous ancestral states, when they were inferred fig. 3 online. t-test P < 8.42e−3). However, alignment–integration further increased the mean PP of the correct ancestral state by 2.4-fold, compared with the correct alignment (P = 5.78e−3). Importantly, alignment–integration increased the PP of the correct state to 0.33, on average, which is higher than the cutoff of 0.2–0.3 commonly used to identify plausible alternative ancestral reconstructions (t-test P < 0.021) and >3.1-fold higher support than any other alignment method (P < 4.78e−3).When ASR errors were made, alignment–integration also generated much stronger support for the correct ancestral state than any of the other alignment strategies, including the correct alignment fig. 3 online. ructions . This laAlthough alignment–integration is obviously not a panacea, these results suggest, in addition to improving ASR accuracy, alignment–integration might be an important approach for “exposing” some potential errors to downstream robustness analysis by reducing the statistical support for erroneously inferred ancestral states and increasing the PP of the correct ancestral state when it is not inferred as the MAP state.t-test P < 4.07e−3). All of the ASR methods exhibited stronger statistical support for correctly inferred ancestral gap states versus correctly inferred amino-acid residues (t-test P < 0.011). However, this difference was more pronounced for alignment–integration, compared with the other ASR methods. When using alignment–integration, the mean PP of correctly inferred residues was 0.84 (>0.94 for the other methods), whereas the mean PP was 0.98 for gap states correctly inferred by alignment-integrated ASR. These results suggest the reduced susceptibility to ASR error enjoyed by alignment–integration is also associated with increased ambiguity in reconstructed amino-acid residues, even when they are correctly inferred. This increased ASR ambiguity could potentially increase the operational costs of evaluating robustness to uncertainty as part of a typical ASR study.The generally favorable increase in statistical ambiguity when ASR errors are made by alignment–integration does come at the cost of increased ambiguity for correctly inferred ancestral states  online. In many ASR studies, the actual ancestral sequences are only of secondary interest, being commonly used to better understand how the protein’s structural and functional properties evolved . In somet-test P < 0.048), performing similarly to structure-guided alignment (t-test P = 0.19). In this case, alignment–integration and probcons produced equivalent errors in structural stability estimates (t-test P = 0.12). We observed similar results for estimated dsRNA-binding affinity (t-test P < 0.041). Binding affinity errors were equivalent, on average, among alignment-integrated, structure-guided, and msaprobs alignments (t-test P > 0.055).We found alignment-integrated ASR generally improved computational estimates of structural stability and RNA-binding affinity, compared with relying on a single sequence-alignment method fig. 4; online. affinity  online. t-test P < 0.017) but did not completely alleviate errors in structural stability or binding affinity estimates. On average, stability and affinity estimates deviated by >25% from the values inferred using the correct ancestral sequences (G) of correct ancestral DSRM1 domains was 0.087 cal/(mol × K) per residue , and structural stability estimates were typically 29.7% away from the correct values. Similarly, dsRNA-affinity estimates were, on average, 26.7% away from the values inferred using the correct ancestral sequences.As expected, having the correct sequence alignment improved inferences of ancestral structural and functional properties in all cases  and 29% of the variation in binding affinity error (r2 < 0.64). The mean slope of the best-fit regression line across all alignment methods was 0.44 for structural stability and 4.25 for binding affinity, and all slopes were significantly greater than zero (t-test P < 2.50e−3). There were some differences in both correlation and slope across alignment methods. For example, ClustalW, mafft, probalign and tcoffee showed weaker correlations between ASR error rates and structural stability errors (r2 < 0.29), while the remaining alignments had generally higher correlations (r2 > 0.41). Similarly, the slope of the best-fit regression line varied from a minimum of 0.17  to a maximum of 0.74 . Similar results were observed for the correlation between ASR error rate and binding affinity errors: correlation varied between r2 = 0.021  and r2 = 0.64 , and slope varied from 1.07  to 7.00 . Even when the optimal sequence-alignment strategy was chosen for each set of simulation conditions, alignment–integration improved ASR accuracy by 1.03-fold (t-test P = 3.33e−4). Although the improvement in alignment-integrated ASR accuracy was typically small in this case , it was consistent across the vast majority of simulation conditions. Only under 5/64 conditions was the best sequence-alignment method as accurate or more accurate than alignment–integration, and most of these conditions had short branch lengths and low indel rates, leading to very low ASR errors across all methods.Results from this three-taxon simulation were largely consistent with those obtained using larger, more realistic phylogenies  online. r2 > 0.85, t-test P < 1.09e−3; r2 > 0.68, t-test P < 0.012; t-test P > 0.044).As expected, ASR error rates increased with increasing branch lengths for all methods . We did observe slightly lower insertion error rates using alignment–integration, compared with the correct alignment (t-test P = 9.56e−3). Residue errors were more frequent for alignment–integration (t-test P = 4.85e−8), and there was no overall difference in deletion error rates between the two methods (t-test P = 0.25).Interestingly, alignment–integration appeared slightly more accurate than using the correct sequence alignment under some conditions, improving ASR error rates by ∼0.6%, on average, compared with the correct alignment ; howeverThese results suggest alignment–integration can consistently improve ASR error rates, compared with single sequence-alignment methods, even under an extremely simplified three-taxon model system with random indels. Under some of these simplified conditions, alignment–integration can produce error rates comparable with those obtained when the correct alignment is known in advance.z-test P = 9.17e−32). Insertion errors had the strongest majority in favor of the correct ancestral state, with, 82.5% of alternative alignments recovering the correct gap state when one alignment erroneously inferred an insertion at that position (z-test P < 1.75e−48).Results from three-taxon simulations suggest that simple “majority-rule” is sufficient to explain most of the cases in which alignment–integration improves ASR accuracy . On averWhen alignment–integration was able to “repair” an ASR error made by a single sequence-alignment method, 78.4% of these repairs were explainable by majority-rule . Howeverz-test P < 1.0e−20). Similarly, the proportion of correct ancestral states with PP <0.05 fell from 0.48 when alignment–integration did not repair the error to 0.21 when it did (z-test P < 1.0e−20).For cases in which majority-rule could not explain alignment–integration repair of the ASR error, we observed an upward shift in the PP of the correct ancestral state, compared with similar scenarios that were not repaired by alignment–integration . The proWhen alignment–integration was able to repair an ASR error by mechanisms other than majority-rule, we observed a large peak in frequency at the PP making the ancestral reconstruction maximally ambiguous , which oOverall, these results suggest majority-rule accounts for ∼80% of cases in which alignment–integration is able to “repair” an ancestral reconstruction error generated by a single sequence-alignment method, but more subtle effects of integrating PP distributions also contribute to improved ASR accuracy by alignment–integration. When the correct ancestral state does not have very low PP across all sequence alignments, alignment–integration can sometimes repair ASR errors, even when the majority of sequence alignments reconstruct the wrong ancestral state.For future ASR studies, our results add to the emerging evidence that alignment errors cannot always be ignored when evaluating the accuracy of ASR , and in The empirically derived simulation conditions used in this study represent realistic but highly challenging ASR problems, with generally long branches and large phylogenies see  online, Alignment–integration is computationally costly, as many different alignments need to be inferred, and phylogenetic model parameters and ancestral sequences need to be computed using each alignment before being combined. Alignments that are very similar to one another may be at best redundant and at worst could bias the ASR toward a “false consensus.” Similarly, wildly inaccurate alignments could introduce statistical noise or generate biased results when included in the integration process. The identification of a set of alignment algorithms that tend to produce highly accurate but different alignments is expected to be important for reducing the computational demands of alignment-integrated ASR while maintaining its useful statistical properties and low error rates.In many of our analyses, specific sequence-alignment algorithms are able to generate ancestral sequences that are nearly as accurate as those generated by alignment integration or structure-guided alignment, suggesting that using a single sequence-alignment method may be adequate, even in some challenging cases. However, the specific alignment algorithm that will perform well for a specific ASR study may be difficult to determine in practice and would likely require comparisons with other alignment algorithms, which would be nearly as computationally costly as alignment-integrated ASR. Because there is no known alignment method that performs optimally in all cases, we recommend that, at minimum, future ASR studies that rely on a single sequence alignment strongly justify the specific approach chosen as the most appropriate for the study.Our cursory analysis of probabilistic alignment methods suggests Bayesian co-estimation of the alignment and phylogenetic tree has the potential to provide exceptionally accurate ASRs, at least under some conditions. However, we remain cautious about recommending this approach for a number of reasons. First, our analyses were conditioned on the correct phylogenetic tree, which is hardly ever known with certainty, and the accuracy of ASR under the more realistic case of joint alignment–phylogeny co-estimation has not been investigated. Second, the existing implementation of this approach is extraordinarily computationally intensive, which might necessitate trade-offs in practice that could partially undermine the method’s high accuracy. Finally, a recent study of alignment accuracy found that BAli-Phy’s co-estimation approach was accurate only when sequence data was simulated and not when biological benchmark data sets were used to evaluate alignment accuracy , suggesthttps://github.com/bryankolaczkowski/airasAll analyses presented in this study were performed using objective, transparent, reproducible algorithms documented in readable source code. All input data and analysis/visualization scripts are freely available under the General Public License as open-access documentation associated with this publication at: Empirical structures of diverse CARD, double-stranded RNA-binding motif (DSRM), and RDs were obtained from the protein data bank  and editSequence data sets and consensus phylogenies for each domain family were curated from previous studies of DSRM , RIG-likα = 1.75  be the probability of ancestral state j at sequence position k and node m on the phylogeny, assuming alignment method i. Then, the heuristic “alignment-integrated posterior probability” of ancestral state j at position k and node m is given by:Alignment-integrated ASRs were produced by respectively combining sequence-reconstruction PPs and presence–absence PPs across all sequence-alignment methods , assuming equal prior weights over sequence alignments. Let iP = 1/n, where n is the number of alignment methods.Here, we set the prior weight of each alignment method Alignment–integration requires mapping all sequence alignments to one another, so that homologous columns from different alignments can be integrated. This was done using the −merge option in mafft ginsi.After respective integration of sequence- and presence–absence reconstructions, the MAP ancestral sequence was generated as described above for single sequence-alignments.t-test, assuming unequal variances. Gaussian kernel density estimates were generated using least squares cross validation to estimate the smoothing parameter  residue errors, in which both correct and inferred sequences have amino-acid residues at the same alignment position, but the inferred residue is different from the correct residue; 2) insertion errors, in which the correct ancestral sequence has a gap character, but the inferred sequence has a residue at that position, and 3) deletion errors, in which the correct sequence has a residue, but the inferred sequence has a gap. For each ancestral node on the phylogeny, we calculated the expected ASR error rate as the mean over 10 replicate data sets. Differences in error rates among methods across all replicates and nodes on the phylogeny were assessed using the two-tailed independent two-sample arameter .Probabilistic sequence alignments were inferred using PRANK v170427 , with deStructural homology models of DSRM1 domains were generated using MODELLER v9.19 . We usedThe structural stability of each protein structural model was inferred using DeltaGREM 2009, which estimates the change in free-energy/sequence-length of a given protein structure, compared with a statistical model of misfolded or unfolded protein ensembles, using a contact-based energy function . We calcKd = −log10(Kd) was estimated using a support-vector machine trained on a large ensemble of protein–RNA and protein–DNA complexes with associated empirically determined binding affinities. Errors in affinity predictions were calculated as the absolute value of the difference in estimated affinities between the correct ancestral sequence’s protein–RNA structural model and that of the inferred ancestral sequence, with expected errors calculated as the mean over 10 replicates.DSRM1–dsRNA-binding affinities were inferred using a previously developed statistical machine learning approach . For eacα = 1.75) was used to simulate 100 replicate data sets along three-taxon phylogenies with branch lengths ranging from 0.1 to 0.8 substitutions/site (see The JTT+G model (four-category discrete gamma approximation with shape parameter site see  online. site see . Insertisite see . Indel lGenome Biology and Evolution online.evaa164_Supplementary_DataClick here for additional data file.


Implied Alignment (IA) was proposed by  as an adIA was originally described in the context of parsimony-based phylogenetic analysis and was later extended to probabilistic model-based approaches by  and its In a broader context, IA is a heuristic solution to the NP-hard Tree Alignment Problem (TAP) defined by . As suchcontexts to produce the median sequences and the full alignment.The IA algorithm presented in this paper takes a different intellectual approach to deriving alignments than earlier versions of IA. Previous algorithmic approaches relied on DO assigning median sequences to the graph vertices. These sequences were then consumed by IA to produce the full alignment. Here, we describe IA as assigning “preliminary contexts” to the graph vertices, and later consuming these The algorithm uses the repeated application of a pairwise string alignment function to perform an efficient MSA for a given binary tree whose leaves are labeled by strings, i.e. the tree describes the relationship of those strings. The more similar the initial leaf labelings the better the algorithm performs. Thus, while this algorithm has general use for performing an MSA, it is especially well-suited for the alignment of biological sequences where the strings are highly similar and a binary tree describing the strings’ relationships can be provided. Below, we provide an example of the IA algorithm’s performance on biological data.In order for an MSA to be inferred, there are constraints on the heuristic alignment function used to decorate the tree prior to performing the IA algorithm. As long as these constraints are satisfied, the implementation details of the function are agnostic to the IA algorithm presented here.Σ be a finite alphabet of symbols such that |Σ|≥3. Let (−)∈Σ be a gap symbol, which will have a special meaning in the context of an alignment. Let ΣΓ be the alphabet of the following symbols:Let ΣΓ contains all pairs of elements of ΣΓ extends the original alphabet Σ to preserve alignment information in the algorithms presented below. Note that if |Σ|=x then |ΣΓ|=2x2. This follows from the fact that Σ, due to That is, ΣΓ. Let Let Σ∗ be the set of all finite strings over the alphabet It is worth noting the motivation of the constructions defined above. Most pairwise string alignment functions take two finite strings of symbols from the original alphabet and supply a new finite string of symbols from the original alphabet. We can represent this class of pairwise string alignment functions by letting n leaves, each leaf containing a string with symbols in Σ and length at most k. To generate this alignment, we will traverse The IA algorithm provides an MSA for a binary tree Using a binary string alignment function (like ⊗) to produce an MSA efficiently relies on the output of binary operations combined across the “global scope” of vx with information that notates on which subtree of vx that element originated. We can lift each symbol in Σ into ΣΓ through the alignment process. Upon completion of the post-order traversal, each node in As noted above, the time complexity of the IA algorithm’s pre-order traversal in previous work was This tag on each element provides contextual information that allows for an efficient processing of the elements in the pre-order traversal. During the pre-order traversal, a node’s preliminary context is “zipped” with the parent’s alignment in order to derive its final alignment. We will show that this tagging and “zipping” process is a substantial improvement over previous work, reducing the time complexity from quadratic to linear in the length of the strings. It is worth noting that this tagging can be represented as a succinct data structure per , requiriWe will provide an example definition of ⊗ in Algorithm 1 sufficient for the IA algorithm, though there are other sufficient definitions of ⊗. The candidate function fitting the description of ⊗ we present will be defined as a extension of the Needleman-Wunsch  algorithFirst, we decide deterministically which of the two input strings is assigned to the top (columns) of the alignment matrix and which string is assigned to the left side (rows). We assign the input strings based on the data they contain. The longer string is assigned to the columns of the alignment matrix, the shorter string to the rows. If the strings are the same length, we take the first string under the lexical ordering of their elements and assign it to the columns and assign the second string to the rows of the alignment matrix. In the case that the strings are identical, the alignment is trivial. If the first string supplied to ⊗ was not assigned to the rows of the matrix, then we must swap the LEFT and RIGHT tags of the resulting string alignment before returning the result. This consistency in assignment ensures the commutativity of ⊗, which is necessary to enforce consistency of the IA algorithm. Commutativity of ⊗ ensures that the IA algorithm provides the same alignment results for isomorphic tree labeling (i.e. ensures label invariance).We now apply a memoized update procedure , a commoΘ(k2) complexity in both time and space, where k is the length of the longer string. For clarity, while this example function is presented as a modification of the well understood Needleman-Wunsch algorithm (without explicit memoization), this tagging approach can be incorporated into more sophisticated pairwise string alignment algorithms. For instance, by using the method described by 32] respek and n. We took the binary logarithm, log2, of both input dimensions as well as the output. From there, we calculated the coefficients of each input in this equation: log2(runtime)=β0+β1 log2(n)+β2 log2(k)+ε, where ε represents the estimation error. Note that, because the logarithm of the inputs was taken, we would expect β1 to be close to 1 for linear performance with respect to that input variable and close to 2 for quadratic performance. See Table After running the algorithm on each data set, we constructed an Ordinary Least Square (OLS) model with the running time in milliseconds as a function of dimensions https://github.com/recursion-ninja/efficient-implied-alignment/replicate-results.sh script in the aforementioned code repository to conduct their own analysis of both the pre-order and post-order traversals.A direct runtime comparison between the Ω(n∗k) and worst case The pathological data sets shows the stark difference between the best case entclass1pt{minimaThe OLS model also anecdotally supports the supposition that time complexity scales well for the biological data sets. The fungal and metazoan sequence data sets demonstrate a near-linear time complexities with respect to the number of input strings and linear complexity with respect to string length. The fungal data sets lend support to the argument that some of “real world” use cases can perform close to the theoretical best case complexity  complexity of time and space. The more similar the input strings are, the closer the performance will be to the best case. When the algorithm is applied to “real world” biological sequences, the performance tends strongly towards the best case. The improved algorithm presented in this paper offers immediate and significant gains to applications related to the TAP and MSA.The IA algorithm can be improved to run with implied by the tree. In short, it is the requirement of commutativity and the lack of associativity.The algorithm originally described by  was giveA,B,C,D∈Σ∗ then the ancestral state of the root node defined by the heuristic function ⊕ would be ((A⊕B)⊕(C⊕D)). In fact, the ancestral state of any internal node defined by ⊕ can be calculated by applying ⊕ recursively to the subtree of the internal node. The binary structure of the tree directly implies the precedence of each application of ⊕ in the final result. Since ⊕ need not be associative, the tree ),D) evaluated as ((A⊕(B⊕C))⊕D), is likely to yield different results. However, since ⊕ is commutative, transposing any child nodes between the left and right positions of their parent will result in a tree that yields the same internal values. For example consider a transposed tree For the purposes of this analysis we will ignore the cost returned from the ⊗ and consider only the resulting alignment context. Therefore let and associative using the algorithm described in this paper would yield the same alignment on all trees for a given leaf-set.This commutative property and lack of an associative property precisely determines that the alignment is implied by the tree on the leaf-set under ⊕ and not the unique alignment on all trees for the leaf-set under ⊕. Clearly, a ⊕ that is both commutative


Sequencing of full-length RNAs using long reads reveals the true complexity of processing. However, the relatively high error rates of long-read sequencing technologies can reduce the accuracy of intron identification. Here we apply alignment metrics and machine-learning-derived sequence information to filter spurious splice junctions from long-read alignments and use the remaining junctions to guide realignment in a two-pass approach. This method, available in the software package 2passtools (The online version contains supplementary material available at 10.1186/s13059-021-02296-0. Understanding eukaryotic genomes requires knowing not only the DNA sequence but also which RNAs are transcribed from it. Eukaryotic transcription by DNA-dependent RNA polymerase II is associated with multiple alternative RNA processing events that diversify the coding and regulatory potential of the genome. Alternative processing choices include distinct transcription start sites, the alternative splicing of different intron and exon combinations, alternative sites of cleavage and polyadenylation, and base modifications such as methylation of adenosines. Patterns of alternative processing can be extensive. For example, more than 90% of human protein-coding genes have at least two splice isoforms . ChangesThe sequencing of RNAs (RNAseq) can reveal gene expression patterns in specific cells, tissues, or whole organisms. The success of this approach depends upon sequencing methodology and the computational analyses used in interpreting the sequence data. High-throughput sequencing of RNA rarely involves direct RNA sequencing (DRS): instead, copies of complementary DNA (cDNA) produced by reverse transcription of RNA molecules are sequenced . HoweverThe development of technologies for sequencing full-length RNA molecules makes the identification of authentic processing events possible in principle, but software tools are also needed to interpret the RNA processing complexity. PacBio and ONT sequencing reads have a higher error rate than Illumina –14. ConsSoftware tools for long and short RNAseq data analysis incorporate several approaches to address the challenges presented by pre-mRNA splicing. Biologically relevant information can aid the alignment of transcriptomic sequences to the genome. For example, the vast majority of eukaryotic splicing events occur at introns bordered by GU and AG motifs. Making RNAseq read aligners aware of these sequence features  model to identify the biological sequence signatures of genuine splice junctions. We found that integrating the alignment and sequence information extracted in this manner produced the largest improvement in splice junction alignment and subsequent genome-guided annotation. As a result, we can improve the utility of long-read sequencing technologies in revealing the complexity of RNA processing and annotating newly sequenced organisms.For sequencing experiments designed to interpret RNA from model organisms, a set of reference splice junctions will already be available . We therefore asked how providing these reference splice junctions to minimap2 to guide alignment performed compared with post-alignment correction of junctions with FLAIR . For thiFLM , the majority of sequencing errors occur stochastically . In cont introns . Overallons Fig. a. In allWithout guidance from a reference annotation, we found that a median of 73.2% of Arabidopsis reads and 44.4% of human reads mapped correctly to the splice junctions of the transcript they were simulated from  is defined as the minimum distance to the first mismatch, insertion or deletion on either overhang of a read alignment splice junction. This metric is used by both finesplice and portcullis software tools , 22. Forρ = 0.776), suggesting that it does not provide more information. The presence/absence of a canonical intron motif  had a very high recall, as 99.96% of annotated introns in the simulated alignments were canonical  to prevent overfitting. A five-node tree using the JAD, primary donor/acceptor, and canonical intron motif metrics Fig. c was besGenuine splice junctions have sequence biases which are defined by their interactions with spliceosomal uridylate-rich small nuclear RNAs . We nextAt a prediction threshold of 0.5, the LR model overclassified positive splice junctions. False positives may be sequences which could in principle act as splice junctions but do not in reality due to effects that the model cannot capture. One such effect could be the presence of alternative splice junctions which are preferentially processed. This is thought to occur under the “first-come-first-served” model of co-transcriptional splicing , 29. TheWe next tested whether the information from the junction metrics and reference sequence model was complementary, i.e., if a combination of the two approaches could produce an improvement in splice junction prediction over each individual approach. Use of a second decision tree model, this time including the JAD metric, primary donor/acceptor metrics, and new LR prediction scores Fig. b, furtheFLM  for estimated versus known transcript level read counts for the simulated data . Intron-containing genes are generally more highly expressed  than intronless genes [When we applied the same approach to the yeast ent Fig. e. In thititutive . This less genes . This maFinally, we considered whether filtered two-pass alignment could improve genome-guided annotation of nanopore DRS reads derived from sequencing cDNA copies and from PacBio IsoSeq data Fig. SA-D. To aWe have shown that a two-pass approach can improve the accuracy of spliced alignment in the absence of a reference annotation. However, even the most well-studied genomes are likely to be incompletely annotated, and so novel splice-junction discovery which builds upon existing annotations is also desirable. We therefore developed an alternative two-pass method which allows users to provide reference annotations. The annotation is used to train random forest models which can then predict novel splice junctions. These models replace the pre-trained decision trees used in the annotation-independent method. We refer to this method hereafter as annotation-aided two-pass alignment.If a reference annotation for a species is truly complete—i.e., there are no new splice-junctions to be discovered, then two-pass alignment can only reduce the accuracy of alignment by introducing false-positive introns into the guide splice junction set. We therefore hypothesize that two-pass alignment will be useful when many genuine splice junctions are missing from the annotation, because genuine novel splice junctions added to the guide junction set will outweigh false positives that are introduced. We refer to the percentage of genuine splice junctions that are unannotated as the level of annotation “missingness”. To test our hypothesis, we performed random subsampling of transcript isoforms in the Arabidopsis reference annotation to simulate an incomplete reference at a range of missingness levels, from 0.1 to 90% missing. We then performed annotation-aided two-pass alignment of the nanopore DRS dataset and assessed the predictive performance on splice junctions which were absent from the subsampled annotation. We found that the annotation-aided method performed best for medium missingness levels. For example, in Arabidopsis DRS data, when between 25 and 66% of reference isoforms were missing, the true positive rate/recall was high (minimum of 0.86), for a low false-positive rate (maximum 0.15) and a high precision (minimum 0.85) Fig. a, b. Thihen2-2 mutant. HEN2 functions as an accessory protein to the nuclear RNA exosome and is required for the processing and degradation of specific classes of mRNAs and non-coding RNAs [hen2-2 mutant compared to wild-type. Many of these transcripts are unannotated because exosome-mediated decay means that they are effectively “hidden” in wild-type plants. We have previously performed Illumina RNAseq of hen2-2 mutants at relatively high depth [AT1G19396, where use of an alternative donor site in a large intron results in a novel exonic region . Mouse DRS and cDNA datasets in FASTQ format [http://datasets.pacb.com.s3.amazonaws.com/2014/Iso-seq_Human_Tissues/list.html). Arabidopsis IsoSeq data in FASTQ format [Four replicates of nanopore DRS reads derived from Arabidopsis Col-0 RNA were used . These dQ format  were dowQ format  were dowQ format  was downhen2-2 seeds were sown on MS10 medium plates, stratified at 4 °C for 2 days, germinated in a controlled environment at 22 °C under 16 h light/8 h dark conditions, and harvested 14 days after transfer to 22 °C. RNA isolation and nanopore direct RNA sequencing were performed as described previously [For newly sequenced nanopore DRS data, eviously .Pipelines for processing of data were written using snakemake version 5.10.0 . FAST5 dTo provide a ground truth with a complete set of known splice sites, sequences were simulated from the reference transcriptomes, with length and error profiles matching those of real DRS reads. This was done by modeling the length, homopolymer error, and other error profiles of real reads. Only primary alignments were considered. The cs tags of reads aligned to the reference transcriptome were used to recreate pairwise alignments between each read and the reference, ignoring refskips. Alignments were inverted to match the 3′ → 5′ sequencing direction of nanopore DRS. Aligned basecalls at reference homopolymers of ≥ 5 nt in length were used to build a probability model of homopolymer calls given the reference homopolymer. To prevent these error profiles being modeled multiple times, the reference homopolymer was then replaced with the aligned basecall in the pairwise alignment. Next, the altered alignment was used to create a Markov chain model of basecalled sequence given the reference sequence. For each base in the reference sequence in the alignment, the aligned portion of the query sequence was identified. The “state” of the alignment  was also identified. The probability of seeing a query sequence was calculated, given the current and previous four bases of the reference and the previous four states of the alignment.The reference transcriptome was also used to simulate data using these models. The number of primary alignments in the real data for each reference transcript was used as the number of simulated reads per transcript. To simulate basecall errors, sequences were inverted to the 3′ → 5′ direction and reads were generated using Markov chain Monte Carlo simulations with the basecall model. The reference sequences were prepended with a 10 nt oligo(A) sequence to mimic a short poly(A) tail so that the initial state of the Markov chain was always “AAAAA” and “====” . Homopolymers in the simulated read were identified and replaced with randomly selected sequences from the homopolymer model. The read was then reverted to the 5′ → 3′ direction for mapping. Because we wanted to assess the alignment of full-length reads, we did not model or simulate the 3′ bias, which is inherent to nanopore DRS data. However, 10 nt of simulated read was subtracted from the 5′ end of reads to simulate loss of signal at the end of sequencing.BAM files were converted to the BED12 format using bedtools . BED12 fSplice junctions and junction metrics were extracted from aligned reads using the long form cs tag produced by minimap2 version 2.17  using pySplice junctions obtained from a first-pass alignment were separated into lists of unique donor sites and unique acceptor sites. These were labeled as positive training examples if they participated in at least one donor/acceptor pair which passed the first decision tree function. Sequences of 128 nt for each splice junction (centered on the donor or acceptor site) were extracted from the reference genome using pysam version 0.15.4 and one hot encoded into four binary variables to create a 512-feature training dataset. LR models were trained using 6-fold cross-validation with scikit-learn version 0.22.1 . For eacFor use cases where high-quality annotations are already available, we developed an annotation-aided two-pass approach. Here, annotated junctions are provided along with read alignments. Annotated junctions are labeled as genuine. Unannotated junctions discovered in alignments are assumed to be mainly spurious. These labels are then used to train an extremely random forest model on junction metrics. Out-of-bag predictions for each junction are used as refined labels for LR models to detect splice junction sequence. A final extremely random forest model is trained on refined labels, using junction metrics and splice junction sequence scores determined by LR models. Positive examples which are not in the annotation will be a mixture of false positives and genuine novel splice-junctions. Any false negatives from the annotation are  retained.Performance of the metrics and models was evaluated at splice junction level using the reference annotation as a ground truth. For simulated datasets, annotation is the absolute ground truth because all reads are simulated using only splice junctions in the annotation. For real datasets, some “false positives” are likely to be genuine splice junctions and some junctions in the reference, which appear as false negatives, are actually incorrectly annotated or not expressed. Precision is defined as the number of true positives divided by the total number of positive predictions by the model, i.e., true positives ÷ . Recall is defined as the number of true positives divided by the total number of real positive examples in the dataset, i.e., true positives ÷ . The F1 score is the harmonic mean of the precision and recall.To evaluate alignments, we used the intron chain of reference transcripts as a ground truth. The intron chain is the pattern of linked splicing in a transcript, disregarding the transcription start and termination sites. Alignments of simulated reads were considered correct if they mapped correctly to the intron chain of the reference transcript they were simulated from, with no mistakes. Simulated reads that were mapped using intron chains not included in the reference or as being intron-less when they should have splicing were considered novel spurious alignments. Simulated reads that were mapped using the intron chain of a reference transcript other than the transcript they were simulated from were considered to be misassigned. For measures of quantification accuracy, alignment counts for transcripts were generated using the number of simulated reads that aligned with the same splice junctions as the reference transcript. Spearman’s correlation coefficients were then calculated against the known input transcript counts for simulation.Reference-guided transcriptome assemblies were produced using StringTie2  version Reference-guided transcriptome assemblies were evaluated using the precision and recall of intron chains calculated using gffcompare with default settings . The inpTo simulate incomplete references, transcript isoforms were removed from the Araport11 (Arabidopsis) and GRCh38 (human) reference annotations at rates from 0.1 to 90%. These incomplete references were then used to perform reference guided alignment of reads simulated using the full reference annotation. Splice junctions from read alignments were then filtered using the annotation-aided method, and reads were realigned using filtered junctions as a guide. Performance on splice-junctions was measured on junctions which were not present in the annotation  only. Performance at read-alignment level was measured as the change in the percentage of correctly aligned reads compared to using only the incomplete reference annotation to guide alignment.hen2-2 Illumina RNAseq data was downloaded from PRJEB32782. Reads were mapped to the TAIR10 genome using STAR, with a splice junction database built from the Araport11 annotation. Splice junction set intersections were identified in Python using pysam, and the visualized using upset plots.Additional file 1: Fig. S1. Simulation of nanopore DRS read alignments. Fig. S2. Annotation-guided alignment improves spliced alignment of simulated reads. Fig. S3. Junction metrics can identify genuine splice junctions. Fig. S4. Machine-learned sequence information can identify genuine splice junctions. Fig. S5. Filtered two-pass alignment improves the identification and quantification of correct transcripts without a reference annotation. Fig. S6. Filtered two-pass alignment improves genome-guided annotation. Additional file 2. Review History.