PHMMs enable us to: fit the parameters to each kind of data, calculate the reliability of alignment parts and measure sequence similarity integrated over possible alignments.Sequence alignment remains fundamental in bioinformatics. Pair-wise alignment is traditionally based on This study shows how multiple models correspond to one set of scores. Scores can be converted to probabilities by partition functions with a ‘temperature’ parameter: for any temperature, this corresponds to some PHMM. There is a special class of models with balanced length probability, i.e. no bias toward either longer or shorter alignments. The best way to score alignments and assess their significance depends on the aim: judging whether whole sequences are related versus finding related parts. This clarifies the statistical basis of sequence alignment.Bioinformatics online. The probabilities can be fitted to each kind of comparison [e.g. error-prone deoxyribonucleic acid (DNA) reads versus a genome]. This is expected to make the comparisons more accurate.We can estimate the reliability of any alignment part, for example, each column . This isWe can measure similarity between two sequences integrated over possible alignments between them. This is expected to detect subtle relationships more powerfully than single optimal alignments .The main way of analyzing nucleotide and protein sequences is by comparing them to related sequences. This is usually done by defining scores for aligned monomers, insertions and deletions, then finding alignments with maximal total score. An alternative approach is to use a pair hidden Markov model (PHMM): a probability model with probabilities for aligned monomers, insertions and deletions probt is often called ‘temperature’ due to an analogy with physics. It has been argued that this approach should be distinguished from generative models such as PHMMs  Sometimes we seek an optimal global alignment , sometimes a local alignment .This describes h) to Da, Db and xyS: this also has no effect on alignment, because it simply adds h × m to the total score of any alignment. Second, we can add any constant to Ia, Ib and xyS. These freedoms can be used to set Some transformations of the score parameters have no effect on alignment. For local alignment, these transformations have one degree of freedom: if we multiply all the scores by any positive constant there is no effect on alignment. For global alignment, there are two further degrees of freedom. First, we can add any constant , iR aligned to a gap (ijY), or jQ aligned to a gap (ijZ):Algorithm I One variant calculates the optimal score for aligning the length-i, j) endpoint.This variant is asymmetric in that it considers insertions after deletions but not deletions after insertions. This is because those two configurations always have the same score, so we may as well only consider the former. The algorithm only returns the alignment score, but an actual alignment can be found by tracing back from a maximal scoring  most likely to have generated those sequences. Consider an alignment where the first μ, defined as:This can be simplified by factoring out a constant μ does not depend on the path, we can find a most-probable path by maximizing:Because Finally, because maximizing a value is equivalent to maximizing its logarithm, we can maximize:μ is the probability of a null alignment : so an alignment score is a log probability ratio relative to a null alignment.This reveals the connection between model-based and score-based alignment. If we define a substitution score matrix as follows:xyS and thus no effect on alignment. First, we can freely vary Dω, Iω and γ, provided that ψ and t, provided that we co-vary π and S, ψ and t; then π and The model in xyπ must sum to 1, we can infer that:Since π using Then we can calculate The letter probabilities in aligned and unaligned regions need not be the same, but we may wish to make them so . Starting from a given substitution score matrix S, t must have a value such that et al. showed that t has at most one such value that also yields π does have degrees of freedom, i.e. a linear space of values that yield the same S , the value of  given t . One conGμ is the probability of a null alignment :Let us now consider a simple gapped model . Just asDω and Iω, provided we co-vary γ, Dα and Iα so as to keep these values fixed:ψ and t, provided we co-vary π, This model has several degrees of freedom, meaning that we can vary the model probabilities with no effect on alignment scores. First, we can freely vary Dω and Iω are relatively low, but γ, Dα and Iα are high, the model has a bias toward longer alignments. Conversely, if Dω and Iω are high but γ, Dα and Iα are low, the model is biased toward shorter alignments. A natural balance occurs when:Dω and Iω arbitrarily close to 1, in which case Dω and Iω arbitrarily close to 1: they have an upper bound that occurs when There is a useful gapped generalization of gapless alignment with uniform length probability. If Balanced length probability can also be understood as conservation of probability ratio relative to a null alignment . Its simDβ), or two deletions of length one (traversing Dα twice). Using model B, on the other hand, it would have to be one deletion of length two. I believe model A is the most elegant possible model for local affine-gap alignment: it makes insertions and deletions symmetric, and produces simple equations.There is more than one PHMM topology corresponding to affine-gap alignment: Let us now relate model A probabilities to alignment scores. We must first decide whether ‘alignment’ means ‘path’ or ‘set of indistinguishable paths’: let us use the former definition here, and explore the latter in the Dω and Iω, provided we co-vary Dβ, Iβ, Dα, Iα and γ so as to keep these values fixed:ψ and t, similar to the gapless and linear-gap models.The affine-gap models have several degrees of freedom, meaning that we can vary the model probabilities with no effect on alignment scores. In model A we can freely vary Dω and Iω , balanced length probability implies ts. If they are weak (near zero), balanced length probability implies t.For gapped (unlike gapless) alignment, balanced length probability does not imply a unique value for i prefix of R with the length-j prefix of Q iR aligned to jQ iR aligned to a gap jQ aligned to a gap Algorithm IIIProbability models enable various useful calculations e.g. , which aThis algorithm uses four dynamic programming matrices, but Algorithm III is almost a mechanical transformation of Algorithm II. First, since it uses probabilities without log transformation, addition is replaced by multiplication, and the primitive terms are replaced by The Forward algorithm for model B, on the other hand, is very similar to Algorithm I . The impt and (ii) a model topology . Typically, any value of t is valid and corresponds to some PHMM.This study describes the many-to-one relationship between probability models and score parameters for sequence alignment. In order to perform alignment probability calculations with the Forward algorithm, we need not fully specify the probability model.  Starting from an alignment scoring scheme, we need only specify two further things: (i) a value for ad hoc gap costs, but a probability-based score matrix (like HoxD70 or BLOSUM62) with homogeneous letter probabilities and uniform (gapless) length probability. For such a score matrix, it seems reasonable to use the unique t that recovers the original letter probabilities (xyπ). For gapped alignment, however, this corresponds to a model without balanced length probability: weaker gap costs increasingly favor longer alignments. This suggests that such scoring schemes are ‘wrong’, and should be fixed by subtracting a value , which is fairly simple and should be more widely known. Although this formula is true by fiat in the partition function approach, it is true by derivation in the PHMM approach, provided we use the A, B and C, with scores As, Bs and Cs. The probability that A is correct is:An example of the formula’s utility arises in alignment of short DNA reads to a reference genome. Suppose one read aligns strongly to three loci, ancestral reference, without reference-specific deletions or duplications  and one in a short query (say chromosome Y), only the latter may be deemed significant. This is appropriate for judging whether each whole query has a significant match, but not for finding significant matches in a set of queries. For the latter aim, significance could be reported as, say, expected number of alignments per million query bases.A related issue is how to report the significance of sequence similarities. A BLAST database . This mebtz576_Supplementary_DataClick here for additional data file.


Network alignment (NA) is a popular research field that aims to develop algorithms for comparing networks. Applications of network alignment span many fields, from biology to social network analysis. NA comes in two forms: global network alignment (GNA), which aims to find a global similarity, and LNA, which aims to find local regions of similarity. Recently, there has been an increasing interest in introducing complex network models such as multilayer networks. Multilayer networks are common in many application scenarios, such as modelling of relations among people in a social network or representing the interplay of different molecules in a cell or different cells in the brain. Consequently, the need to introduce algorithms for the comparison of such multilayer networks, i.e., local network alignment, arises. Existing algorithms for LNA do not perform well on multilayer networks since they cannot consider inter-layer edges. Thus, we propose local alignment of multilayer networks (MultiLoAl), a novel algorithm for the local alignment of multilayer networks. We define the local alignment of multilayer networks and propose a heuristic for solving it. We present an extensive assessment indicating the strength of the algorithm. Furthermore, we implemented a synthetic multilayer network generator to build the data for the algorithm’s evaluation. Network theory is one of the most important frameworks for a meaningful description and an efficient analysis of many complex systems ,2,3. MosG. Edges of a multilayer graph can be intra-layer, i.e., connecting nodes of the same layer, and inter-layer, i.e., connecting nodes of two different layers [More recently, in many application fields, e.g., mobile and social networks and connectomics and metabolomics studies, the need for introducing models more complex than traditional networks arises ,8. In sut layers ,12.k, we have a graph k, h we have a set of edges Formally, a multilayer network graph may be described as a tuple  v and k .Examples of multilayer networks come from many different fields, from social network analysis to biological networks. For instance, While many efforts have been made to address challenges related to the analysis of a single network, i.e., community detection in multilayer graphs, there is a need for the formalization and introduction of algorithms to compare multilayer networks. A simple strategy is an adaption or the simple use of existing algorithms for LNA. Unfortunately, this strategy is unsuitable, as previously demonstrated also in heterogeneous networks  because Thus, we propose local alignment of multilayer networks (MultiLoAl), a novel algorithm for the local alignment of multilayer networks. We define the local alignment of multilayer networks and propose a heuristic for solving it. MultiLoAl is based on an extension of the previous L-HetNetAligner , so it iFor instance, considering biological networks, similarity relations are represented by orthologs. The user may find these relations in databases of orthologs . It produces a set of multilayer graphs representing single local regions of the alignment.k, the alignment graph features pairs of nodes of the input ones. After building each alignment graph for each layer separately, we analyse the two input graphs to add inter-layer edges of the multilayer alignment graph. Finally, the algorithm uses a community detection algorithm suitable for multilayer graphs to detect communities representing local regions of similarity, i.e., a single region of the alignment. The result of our algorithm is a list of mappings among a subset of nodes of two networks, i.e., a set of mapped regions among input graphs.The algorithm merges two input multilayer graphs into a single one, named the multilayer alignment graph, a multilayer graph with the same number of layers of the two inputs, and each layer represents an alignment graph of the same layer of the two input ones. For each node of a layer We also realized a preliminary implementation of our algorithm by using the R programming language. We here refined such an implementation even in a high performance computing (HPC) fashion and provided deeper experimentation on a larger dataset. The main contributions of this paper are: (i) the implementation of a novel algorithm for the local alignment of multilayer networks, (ii) the definition of the local alignment of multilayer networks, (iii) the solution of a heuristic for solving it, and (iv) the implementation of a synthetic multilayer network generator to build the data for the algorithm evaluation.The rest of this paper is organized as follows. The alignment of networks aims to compare two or more networks , and exiCommunity detection is one of the most popular research areas in various complex systems, such as biology, sociology, medicine, and transportation systems ,17,18. TDiscovering a community structure in multilayer networks has became a hot research topic due to the inability of classical community detection methods to deal with the complexity of the multilayer model.In fact, in multilayer networks, the communities represent groups of well-connected nodes in all layers. Thus, the detection algorithms should take into account the differences among layers. Unfortunately, traditional community detection methods are not able to deal with the complexity of the multilayer networks because (i) they do not enable analysing subsets of the layers and also (ii) they do not depict the diverse layers, and thus, they cannot distinguish between different types of multilayer communities . To overGenLouvain  is a mulABACUS  is an alMultilayer clique percolation  is a metMultidimensional label propagation (mdlp)  is an alInitially, the algorithm inputs two multilayer networks and a set of similarities among node pairs of the same layer into the input networks. Then, it builds the alignment by performing two main steps: (i) construction of the multilayer alignment graph and (ii) mining of the multilayer alignment graph.MultiLoAl analyses separately each corresponding pair of the corresponding layers of the input graphs. Each pair of a network of the same layer builds an alignment graph, as previously shown in L-HetNetAligner . Then, i(i) Construction of the multilayer alignment graph;(ii) Analysis of the alignment graph.MultiLoAl is a novel algorithm for the local alignment of multilayer networks. MultiLoAl builds the alignment on two main steps, as depicted in Step (i) may be subdivided into two substeps: (i.a) adding nodes and intra-layer edges; (i.b) adding inter-layer edges.Let us consider two multilayer input graphs Node colours are used to distinguish different types of nodes belonging to two different types of layers. For simplicity, two multilayer input networks have the same number of nodes.In the first step, the algorithm considers each pair of corresponding layers separately see At this stage, the algorithm, starting from an initial list of seed nodes, builds the alignment graph by initially constructing two intermediate alignment graphs, which we call alignment graph layer 1 and alignment graph layer 2, for two networks belonging to layer 1 and two networks belonging to layer 2. Therefore, we define the alignment graph match, which we call, for convenience, a homogeneous match, since the nodes of the two networks are of the same type ).In the current version of MultiLoAl, we applied the Infomap algorithm to mine the communities on the alignment graph. However, the user can choose which community detection algorithm to select among Generalized Louvain, ABACUS, clique percolation, and mdlp. The output consists of a file that contains the extracted communities as a list of nodes, the weight of the edge, and the string in which it is reported if there is a homogeneous/heterogeneous match, homogeneous/mismatch, or homogeneous gap  construction of the alignment graph; (ii) mining of the alignment graph. The building of the alignment graph is the first main difference among the two algorithms. In fact, MultiLoAl builds a multilayer alignment graph through two substeps: (i) by adding nodes and intra-layer edges, following the approach proposed in L-HetNetAligner adapted to the case of one-colour networks; (ii) by adding inter-layer edges. This last step represents the main novelty compared to L-HetNetAligner, because MultiLoAl analyses and adds the edges among different layers of input networks. Otherwise, L-HetNetAligner builds a heterogeneous alignment graph. Initially, L-HetNetAligner defines the nodes of the alignment graph as composite nodes representing pairs of nodes matched by the similarity considerations. The algorithm inserts and weights the edges in the alignment graph to the nodes for which the edge links have the same colour and according to their distance in the input network. Finally, once the alignment graph is built, both algorithms mine the alignment graph to discover modules that represent local alignment. MultiLoAl applies a community detection algorithm, Infomap, to mine the final alignment. The result consists of the extracted communities as a list of nodes, the weight of the edge, and the string in which it is reported if there is a homogeneous/heterogeneous match, homogeneous/mismatch, or homogeneous gap. Otherwise, L-HetNetAligner uses the Markov clustering (MCL) algorithm to cluster the graph. Each extracted module represents a single region of the alignment. The result of our algorithm is a list of mappings among a subset of nodes of two networks, i.e., a set of mapped regions among input graphs.The evaluation of the quality of the alignment of network is still a matter of debate for simple networks ,31,32. TM is the set of node pairs that are mapped under the true node mapping and N is the set of node pairs that are aligned under an alignment f.The correctness of an alignment is usually evaluated by means of the analysis of its topological quality, i.e., the ability to reconstruct the underlying true node mapping well (when such a mapping is known) and if it conserves many edges. For simple networks, multilayerWe here extended such a measure in the multilayer case. We first considered in a separate way each layer, and we calculated the NCV-G, which is a combination of two measures: high node coverage (NCV) and generalized Similarly, the edge correctness in the simple case can be measured by considering We used NCV-GFinally, we should consider the edge correctness for the inter-layer edges. Without loss of information, we considered all the inter-layer edges as a whole, and we calculated the correctness of all the inter-layer edges as https://github.com/mmilano87/MultiLoAl (accessed on 12 August 2022)).As a proof of principle, we present the use of the MultiLoAl dataset consisting of ten multilayer synthetic networks that we built with the graph generator, implemented ad hoc in the R code. An example of the multilayer network and R function are available on the web site of the project  by randomly removing edges from the network. The aim of the test was to demonstrate that the alignment algorithms are capable of producing high-quality alignments with an edge conservation of about 90%. Then, we implemented different versions of the MultiLoAl algorithm by varying the strategy applied to mine the community on the alignment graph. We executed the experiments on an Intel Core i5 Processor, 2.9 Ghz, with 4 Gbytes of main memory running the Ubuntu OS ver 18.04. MultiLoAl built 60 alignments, and it completed the whole process of alignment in ten seconds.To measure the performance of the alignments built with different versions of MultiLoAl, we evaluated the quality of the results by considering the topological aspects of alignments and the number of communities found. At first, the results were evaluated by the topological quality.We computed the NCV-GThe results show that the quality of the alignment was greater when Infomap was applied to mine the community. Furthermore, increasing the noise level from 5% to 25% in the original networks caused NCV-GRecently, the applications of multilayer networks in social network analysis, in finance, and in biology have been increasing. Multilayer networks can be seen as a set of networks (each network is a distinct layer) connected by inter-layer links. We here focused on the problem of comparing two multilayer networks, highlighting small local regions of similarity. Since existing algorithms for simple networks do not perform well on multilayer networks, we proposed Local Alignment of Multilayer Networks (MultiLoAl), a novel algorithm for the local alignment of multilayer networks. We proposed a heuristic for solving it. Furthermore, we performed an extensive evaluation to reveal the strength of the algorithm. Since we presented the use of MultiLoAl on multilayer synthetic networks, we plan to extend the application to real biological networks.


However, understanding where a k-mer is positioned along a binding site sequence depends on alignment. Here, we present Top-Down Crawl (TDC), an ultra-rapid tool designed for the alignment of k-mer level data in a rank-dependent and position weight matrix (PWM)-independent manner. As the framework only depends on the rank of the input, the method can accept input from many types of experiments  without the need for specialized parameterization. Measuring the performance of the alignment using multiple linear regression with 5-fold cross-validation, we find TDC to perform as well as or better than computationally expensive PWM-based methods.Several high-throughput protein–DNA binding methods currently available produce highly reproducible measurements of binding affinity at the level of the https://topdowncrawl.usc.edu or locally as a python package available through pip at https://pypi.org/project/TopDownCrawl.TDC can be run online at Bioinformatics online. Previously described approaches, such as MEME  and plays a significant role in protein–DNA binding for many TFs . All unaligned k-mers overlapping the reference by up to k−2 bp are then added to the alignment with a shift equal to that of the reference ±1 or 2 bp depending on if that sequence is overlapping on the 5′ or 3′ end of the reference (k-mer amongst those which have been aligned, excluding sequences already marked as complete. As before, the new reference is used as a starting point for the addition of more k-mers to the alignment, so long as they have not been added previously. This process is terminated when all sequences added to the alignment have been marked as ‘complete’. Detailed pseudocode of this process is made available in TDC was developed with one goal in mind: the usage of high-affinity sequences to describe the binding of similar, but lower-affinity sequences. Then, use those sequences to align other similar sequences. More specifically, the algorithm starts by assigning the eference . For exaTDC is provided through a freely accessible webserver and requires only a list of sequences with their corresponding binding measurements as input. After processing the upload, the user is given a summary of the alignment as well as a representative PWM, weighting each sequence by its associated binding metric. This is most appropriate for SELEX-seq data, for which the relative enrichment is expected to approximate the relative binding affinity (k-mers can be assigned to their most likely ‘shift’ relative to the reference, similar to TDC. This is done by padding a given PWM with neutral positions on the 5′ and 3′ ends, then sliding each k-mer along every window along the PWM to see which shift results in the highest score. The alignments generated by these methods can then be directly compared with those provided by TDC. A generalizable workflow for PWM-based k-mer alignment and evaluation is provided at https://github.com/bhcooper/TDC_evaluation.Given a PWM from a motif-generating method such as MEME, BEESEM or SelexGLM, k-mers with a log enrichment two standard deviations above the mean. The resulting PWM can then be used for the alignment of all k-mers as described above. Alternatively, BEESEM was made specifically for creating PWMs from SELEX-seq data but is computationally limited to producing motifs no longer than 10 bp and relies on subsampling for particularly large datasets (MEME is a well-established method for the alignment of sequences, but it does not take quantitative data as input. Therefore, every sequence is weighted equivalently in the construction of the PWM. For this reason, we run MEME using only datasets , and thek-mer length of 10 bp, which covers the known binding site for most of the TFs considered and contains more information about suboptimal binding sites compared to longer k-mers. Although the goal of TDC is alignment rather than PWM generation, we can generate a logo from each alignment, weighting each sequence by its relative enrichment (To compare TDC with alternate alignment methods, we include the analysis of 12 SELEX-seq datasets that have previously been published (richment . We founrichment .2R using 5-fold cross validation (k-mer. Since MEME was only used to align k-mers with a log enrichment two standard deviations above the means, its wall-clock time was dependent on the number of sequences passing this threshold. While the quickest batch, including 653 sequences, was aligned in about 5 s, the slowest batch, including just 4889 sequences took 18 min, demonstrating a 216-fold increase in wall-clock time for a 7.5-fold increase in the number of sequences aligned (k-mers aligned with TDC and found the optimal length to be 10 bp (For a more in-depth comparison, we determine what percent of significantly enriched 10-mers are assigned to the same shift, using TDC as the reference. TDC showed a high level of agreement with BEESEM, followed by MEME and SelexGLM . To evallidation . Comparilidation . SelexGLlidation . The pri aligned . Finallybe 10 bp .Although we demonstrate TDC’s speed and performance using SELEX-seq data, the alignment framework is highly flexible as it only depends on the rank of the sequences provided. This allows for the alignment of binding data from a variety of experimental approaches used today and those that are produced in the future.This work was supported by the National Institutes of Health [grant R35GM130376 to R.R.]; the Human Frontier Science Program [grant RGP0021/2018 to R.R.]; and a USC Provost Fellowship to B.H.C.Conflict of Interest: none declared.btac653_Supplementary_DataClick here for additional data file.


Evolutionary inference depends crucially on the quality of multiple sequence alignments (MSA), which is problematic for distantly related proteins. Since protein structure is more conserved than sequence, it seems natural to use structure alignments for distant homologs. However, structure alignments may not be suitable for inferring evolutionary relationships.de novo or modifying an input MSA, using a similarity matrix based on PC_sim. The program constructs a starting MSA based on the maximal cliques of the graph of these PAs and it refines it through progressive alignments along the tree reconstructed with PC_div. Compared with eight state-of-the-art multiple structure or sequence alignment tools, PC_ali achieves higher or equal aligned fraction and structural scores, sequence identity higher than structure aligners although lower than sequence aligners, highest score PC_sim, and highest similarity with the MSAs produced by other tools and with the reference MSA Balibase.Here we examined four protein similarity measures that depend on sequence and structure , finding that they are intimately correlated but none of them provides a complete and unbiased picture of conservation in proteins. Therefore, we propose the new hybrid protein sequence and structure similarity score PC_sim based on their main principal component. The corresponding divergence measure PC_div shows the strongest correlation with divergences obtained from individual similarities, suggesting that it infers accurate evolutionary divergences. We developed the program PC_ali that constructs protein MSAs either https://github.com/ugobas/PC_ali. The study of protein evolution relies heavily on the quality of multiple sequence alignments (MSA). However, it is known that distant alignments have low accuracy with consequent errors in evolutionary inference, which partly explains why current phylogenetic methods show poor performance when applied to distantly related proteins . The impSeveral approaches attempted to integrate structural information to improve MSA, using additional information such as predicted secondary structure . Moreovede novo when structure information is available.Here, we consider diverse sequence and structure similarity measures. Each of them captures correlated but different aspects of protein evolution. Therefore, we derive the hybrid sequence and structure similarity measure PC_sim that captures all of them and we use it for improving an input MSA or for building an MSA Sequence and structure divergence provide consistent evolutionary information since they are strongly correlated . HoweverThere are several measures of protein structure similarity and divergence, and we distinguish two main types. (i) Some similarities, such as the fraction of spatially superimposed residues, are computed after spatial superimposition, which depends on an optimized rotation matrix. A common criterion for determining the optimal rotation consists in maximizing the template-model (TM) score  see Mat native dGiven the intricate sequence–structure–function relationship that characterizes proteins and the fact that different similarity measures capture only part of it, we studied the correlations between these measures. Different similarity measures provide consistent information, since they are strongly correlated. We found here that their main principal component (PC) represents more than 75% of the total variance, depending on the type of alignment. We thus propose that the main PC of protein similarity measures (PC_sim) yields a convenient description of the similarity between proteins that integrates sequence conservation, conservation of the local coordinates (related with native dynamics), and conservation of the contact matrix (related with folding stability).The protein similarity measures allow inferring evolutionary divergence time, similarly to how sequence identity allows computing the Tajima-Nei (TN) diverence  . These ide novo or by modifying the input MSAs. For comparison, PC_ali also constructs PAs that target the structure similarity measures TM-score and CO. We found that the PAs that target PC_sim yield the highest or second highest value of all similarity scores, and that they arguably provide better performances than alignments that target individual measures. In the second step, PC_ali builds the starting MSA associated with the maximal cliques of the graph of the PAs based on PC_sim. This MSA constitutes the starting point for iterative applications of the progressive multiple alignment algorithm that recurs the guide tree computed with PC_div adopting a similarity measure based on PC_sim.We then developed the MSA program PC_ali, which constructs MSAs based on PC_sim. In a first step, PC_ali constructs the pairwise alignments (PAs) that target PC_sim either http://www.lbgi.fr/balibase/BalibaseDownload/ built with sequence and structure information : Fraction of positions that are considered homologs (no gaps) with respect to the maximum length of the two proteins. This normalization penalizes insertions and deletions, which can produce functional or structural changes, although different length may also derive from different crystallization constructs.Sequence identity (SI): Fraction of aligned positions that share the same amino acid (note that indels are not scored by SI).TM-score (TM): Fraction of spatially superimposed aligned positions. While the RMSD measures structure divergence for fixed number of superimposed positions, it cannot be used when this number is variable since there is a trade-off between the length of the superimposition and its RMSD. To address this problem, L is the number of aligned positions, id is the distance between the two alpha carbons aligned at column i after optimal rotation, L-dependent distance expected for structurally unrelated positions, and the optimal rotation matrix is determined self-consistently by iteratively maximizing the TM-score.Contact overlap (CO): Fraction of shared contacts between two aligned protein structures. Different from the TM-score, the CO does not depend on any rotation matrix, and it is defined asijC and i and j is closer than 4.5 Å and 0 otherwise, a(i), a(j) are the residues of the second structure aligned to residues i, j of the first one (excluding gaps). The CO is normalized so that its maximum value is 1.PC similarity (PC): The PC is the weighted combination of the four similarity measures described above. The weights were determined through the principal component analysis of the four similarity measures for all the superfamilies studied in this work. Using the MAFFT alignment to compute the similarity scores, we obtained:We use these weights in this work. Other alignment programs yielded similar weights, which are reported in To each pairwise similarity measure, we associate an evolutionary divergence that estimates the time during which the two proteins diverged. For sequence identity, we adopt the TN divergence  that repTN divergence (vergence  is compuwhere TM divergence computed from the TM-score (TM) asL because the TM-score is carefully normalized.where volution , which iContact divergence . It is based on the idea that the sequence and the structure alignment have different aims: to infer homology and to identify structurally equivalent residues, respectively. Thus, they need not coincide everywhere. For instance, if a residue inside a secondary structure element (SSE) is deleted, the structure of the mutated protein will rearrange so to maintain the structural integrity and, in the structure alignment, the resulting gap will move to one of the two ends of the SSE. Our program detects such cases and moves the gap in the direction in which the displacement is smaller, it computes sequence identity and TM-score both for the starting and the modified alignment, and it selects the largest similarity. If the TM-score of the modified alignment is higher, the CO is also taken from the modified alignment.Next, we construct modified PAs that target the TM-score , the CO , or the PC similarity  while modifying the input alignment as little as possible, through the following procedure: (i) for each residue we identify the nearest residue in the other protein as the one that maximizes the target score , which depends on the input alignment and the optimal rotation matrix; (ii) we identify as neighbors two residues that present a double match, i.e. i1 is the nearest residue of i2 and i2 is the nearest residue of i1; (iii) we align neighbors that are aligned in the input alignment, obtaining frames; and (iv) proceeding from left to right, we align neighbors that are intermediate between frames. We iterate this procedure, calling new neighbors using the modified alignment. In this way, we obtain modified PAs that are similar to the input alignment and increase the target score without having to specify the gap penalty parameter.n proteins are nodes and links connect aligned residues. The maximum number of links per residue is n. If all PAs are consistent with an MSA, each column of the MSA corresponds to a maximal clique in the graph, i.e. a maximal set of fully interconnected residues. (ii) We rank all nodes based on the clustering coefficient of the PA graph, i.e. the number of pairs of neighbors of the node that are neighbor between themselves. (iii) We determine the maximal cliques of the graph for each residue i iteratively, following the ordering of the clustering coefficient in order to accelerate the computation, exploiting the list of neighbors and taking care to avoid repeated computations. The first clique is constituted by i and its first linked residue s, we add to all previous cliques the residue i. If this residue is linked to all residues in the clique it is added to it, otherwise a new clique is created with all residues that are linked to both i and n. When the neighbors of i are exhausted we store the largest cliques. For each residue we store the maximum size and the sum of the sizes of its cliques, and exclude from future computation residues for which any of them is larger than We then obtained an MSA from the set of modified PAs through the following graph-based algorithm. (i) We transform the PAs into a graph where residues of the For improving the quality of the MSA, PC_ali iteratively applies a progressive multiple alignment algorithm that targets PC_sim. Based on the previous MSA, it optimally superimposes all the protein structures maximizing the sum of the TM-scores of the aligned residues, it computes the PC_div divergence measures for all pairs of proteins, and it uses PC_div for constructing a guide tree through the average linkage algorithm . All these tasks are internally programed in PC_ali.http://www.bioinf.org.uk/software/profit/). PC_ali selects the MSA with the largest average PC_sim score. It performs up to seven progressive MSA steps, but it can stop earlier if the scores converge or cycle. The computations are fast, and the progressive steps take longer than the clique-based MSA.At each step of the clustering algorithm, PC_ali constructs the similarity matrix of two clusters of sister proteins based on PC_sim, using the previous alignment for estimating the CO and for superimposing the structures, it uses the matrix Blosum62 for scoring sequence similarity and it also scores aligned pairs of residues. Subsequently, it aligns the two clusters with the Smith–Waterman algorithm  that we de novo (option -seq) with a scoring matrix inspired to PC_sim that considers secondary structure identity instead of TM-score and contact vector similarity  or it constructs the PAs To assess the MSA, we downloaded the Balibase set of structure-curated multiple alignments  and the corresponding divergences for the required PAs  and for the final MSA. The pairwise scores are printed both for all examined structures (.sim and .div) and for the representative structures of each cluster of identical sequences (.prot.sim and .prot.div). The program then prints the MSA in fasta format (.PCAli.fas), the MSA of secondary structures (.PCAli_ss.msa), the neighbor joining tree constructed with PC_div (.PCAli.tree) and the PDB file with optimally superimposed structures (.PCAli.pdb). The file .id presents an analysis of conservation patterns that we will present elsewhere, and the file _summary.dat reports the average scores obtained with the distinct pairwise and multiple alignments that are constructed.In this work we consider four protein similarity measures: fraction of aligned residues , fraction of aligned residues that are identical (SI), fraction of spatially superimposed residues (TM-score), and fraction of shared contacts (CO) . As expected, all similarity measures are strongly correlated: two proteins whose alignment presents few gaps also present large sequence identity, large number of spatially superimposed residues, and large fraction of shared contacts. PC analysis shows that the main PC, which we call PC0, accounts for more than 75% of the total variance . All exaThe PC loads are remarkably robust to the input MSA: their range is tion see . The loation see . One migload see  because The second PC (PC1) accounts for most of the remaining variance, but its weight is much smaller . It is cWe start presenting four structure-guided pairwise modifications of input MSAs. One of them is based on secondary structure , and the remaining three target structure similarity scores: TM_ali targets the TM-score, CO_ali targets the CO, and PC_ali targets the hybrid sequence and structure similarity score PC_sim.When we used as input the MStA obtained through Mammoth, the PC_ali correction increases all the sequence and structure similarities , which sThe modified alignment SS_ali moves the gaps contained inside any SSE toward the closest end of the SSE. This is motivated by the idea that gaps inside a SSE might happen in evolution, so that the sequence alignment correctly infers homology, but the structure reorganizes so that the structural correspondence is different from the one dictated by the sequence alignment, i.e. sequence and structure alignment do not need to coincide. Accordingly, when we compute the average similarity scores we consider the higher between the SI score of the starting and the modified alignment, and the higher between the two TM-scores. Not surprisingly, this procedure increases all similarity scores in The results presented above and other ones that we will present elsewhere suggest the existence of compensatory changes, particularly strong for closely related protein pairs, that make difficult to disentangle the evolutionary history of a protein superfamily in terms of only one similarity measure such as sequence identity, 3D superimposition or CO. These observations support our proposal to adopt the hybrid measure PC_sim that integrates various aspects of protein similarity. We now assess whether the new similarity measure can improve our ability to infer protein divergence.From the comparison of the aligned sequences, we can infer the time past since the divergence of the two proteins using simple substitution models. This estimated divergence is often used to construct the guide tree for the processive multiple alignment algorithm and its accuracy has an important influence on the final results. The inferred divergence can be computed with simple formulas such as the TN divergence . Adoptinb should vanish, because the divergence D2 should vanish for b is never zero for structure divergence. We try to reduce the influence of conformational changes by considering the maximum structural similarity over all conformations of the same protein.We compute the correlations between divergence measures through a linear model with an offset, Since all divergence measures aim at inferring the same quantity, we assess their quality by measuring the average correlation coefficient with the other divergences, since the divergence measure with highest average correlation can estimate the other measures most reliably. We show in As described in the Materials and methods section, we transform the PAs that target PC_sim into a graph and we determine its maximal cliques, from which we generate an MSA that we improve through subsequent progressive alignment steps. We finally select the MSA with largest PC_sim.We assess these MSAs against eight multiple alignment programs on the Balibase set of MSAs (We show for illustration in t statistics, the error bars allow to visually assess the significance of the difference in the frequent cases in which the SEM is much smaller than the distance from zero. Not surprisingly, PC_ali achieves the largest PC_sim score (The average scores of all nine methods and their PC_sim-corrected modifications are shown in im score  and 5E. im score  and 5F, PC_ali produces the MSAs most similar to those of Balibase, according both to the sum of pair score , and alsOf course the similarity between MSAs depends on their sequence identity, as shown in Concerning individual scores, PC_ali aligns more than all other methods , excludiFinally, when analyzing the PC_ali-modified MSAs, we see that they all perform very similarly irrespective of the MSA from which they are derived (right part of Here we addressed the influence of the similarity score that is targeted by an alignment program, either sequence similarity or structure similarity measured either in terms of superimposed atomic coordinates [as in Mammoth ] or in tIn order to get more insight on the agreement and disagreement between different protein similarity measures, we analyzed four large superfamilies of homologous proteins with known structures that have diverged in sequence, structure, and function throughout a long evolutionary story , which wWe then constructed three new PAs that modify an input MSA produced by sequence or structure alignment program by targeting three different similarity measures: spatial proximity after superimposition measured by the TM-score  Equatio, superimWe then tested whether PC_sim improves the inference of the evolutionary divergence time. We adopted simple estimates of the evolutionary divergence formally analogous to the TN divergence measure obtained from sequence identity and often used in evolutionary studies : the conde novo or by modifying an input MSA. Next, PC_ali obtains a starting MSA from the sets of the maximal cliques of the graph of the PAs. Finally, PC_ali refines this starting MSA through iterative steps of progressive multiple alignments that adopt the guide trees based on PC_div and the similarity measure based on PC_sim, and it selects the MSA with largest PC_sim score.We then developed the new MSA program PC_ali that produces PAs that target PC_sim, either We assessed the resulting MSAs on the Balibase database of structure-curated MSAs (When PC_ali takes an MSA as input, it improves or mantains almost all scores of the input MSA. In particular, when the input is a structural MSA built by Mammoth or TM-align, PC_ali improves the sequence similarity, the aligned fraction, the structure similarities, and the similarity with other alignments , suggestWhen the input is an MSA based on sequence, PC_ali improves all structural scores, the similarity with other MSAs and with the reference MSAs of Balibase, it improves or maintains the aligned fraction except with respect to Muscle, and it worsens the sequence identity, except with respect to Clustal and Decipher see . Howeverde novo or starting from very different input MSAs have very similar (Importantly, the MSAs constructed by PC_ali either  similar , showingbtad630_Supplementary_DataClick here for additional data file.


In making the latter, we wrote a fully documented Python package Homomorph that implements standard HMM algorithms and created a set of tutorials to promote its use by a wide audience. We applied the resulting pipeline to a set of 33 annotated Drosophila genomes, generating 22,813 orthologous groups and 8,566 high-quality alignments.Identifying protein sequences with common ancestry is a core task in bioinformatics and evolutionary biology. However, methods for inferring and aligning such sequences in annotated genomes have not kept pace with the increasing scale and complexity of the available data. Thus, in this work, we implemented several improvements to the traditional methodology that more fully leverage the redundancy of closely related genomes and the organization of their annotations. Two highlights include the application of the more flexible  Though the identification of orthologous proteins is a key step in many comparative genomics analyses, methods for inferring and aligning their sequences in annotated genomes have not kept pace with the increasing scale of the available data. Thus, Singleton and Eisen implemented several improvements to the traditional methodology that more fully leverage the redundancy of closely related genomes and the organization of their annotations. The authors applied the resulting pipeline to 33 annotated Drosophila genomes, generating 22,813 orthologous groups and 8,566 high-quality alignments. Comparative genomics is a powerful tool for yielding insights into evolutionary relationships, molecular function, and the forces that drive gene, genome, and population evolution. These methods often rely on the identification of homologous sequences or homologs, that is sequences with common ancestry, since this ensures that differences between sequences reflect variations in evolution from a common point of divergence. However, many analyses impose the additional condition that the sequences have diverged through speciation events (orthology) rather than duplications  or other mechanisms such as horizontal gene transfer . The undSupplementary Fig. 1). Though this figure is only a rough proxy of the total number of assemblies available, it will likely continue to grow rapidly in the coming years as many large-scale genome assembly efforts such as i5K  into hits, the BLAST output was filtered to extract HSPs associated with the highest-scoring gene. The HSPs were first grouped by target protein, and the resulting groups were sorted in descending order by the bit score of their highest-scoring HSP. Iterating over the groups, all HSPs in a group were passed to the next step until the parent gene of the group was not the parent gene of the highest ranked group. This method collected all candidate HSPs for a target gene if the highest-scoring HSP within a group exceeded the highest-scoring HSP of the next best gene. This is in some senses an extension of the best hit criterion where hits are considered at the level of genes rather than proteins. If multiple genes tied for the highest-scoring HSP, the iteration stopped when the parent gene of the current group matched none of these highest-scoring genes.Because BLAST can return multiple potentially overlapping HSPs for a query and target sequence pair, HSPs were merged into a single “hit” object that encompassed information from HSPs without overlap (“disjoint”) and HSPs with an acceptable amount of overlap (“compatible”). Hits were created by iterating over the HSPs in 2 passes. In the first pass, proceeding from highest to lowest bit score, HSPs were marked as “disjoint” if they did not overlap with any other HSP previously marked as disjoint. Although choosing the highest-scoring subset of HSPs is a kind of “scheduling problem” with a known solution, we implemented a simple greedy strategy to prevent fragmentation by prioritizing fewer long and high-scoring HSPs over many short and low-scoring HSPs. In the second pass, all HSPs in the disjoint set were first marked as “compatible,” and proceeding from highest to lowest bit score, the remaining HSPs were marked as compatible if the overlap with any other compatible HSP was no more than 50% of the length of either.The best hit for each query was chosen as the hit with the highest sum of bit scores from only disjoint HSPs. The best hits were filtered by overlap and reciprocity criteria. The overlap criterion was applied first and required that 50% of residues in the query were aligned in compatible HSPs. This excluded false positives from conserved domains embedded in larger nonhomologous proteins by ensuring that the hits spanned a sufficient fraction of the query and target sequences. The reciprocity criterion required each query–target pair had a corresponding hit where the roles were reversed, which ensured that there was no ambiguity in which target was the best match for the query.k-Clique percolation was implemented in 2 steps. In the first, maximal cliques were identified. In the second, a percolation graph was constructed by defining edges between cliques if they had k − 1 nodes in common. Clusters were the connected components of this second graph. The first step used the NetworkX implementation of a maximal clique algorithm. The second step used a modification of the NetworkX implementation of the k-clique community algorithm. The NetworkX implementation exhaustively finds all edges in the percolation graph. Since joining a k-clique community only requires that a clique has a single edge connecting it to that a community, this approach was needlessly expensive for large graphs. The custom implementation instead used a progressive approach where each clique was checked against a list of known communities, merging communities as necessary in each step.k-core algorithm was used instead. Out of over 10,000 connected components, only 7 timed out, and many of those contained highly dense clusters of histone sequences.The hit graph was sparse, so these algorithms were efficient when applied to its individual connected components. However, some components had a structure with many maximal cliques, which dramatically slowed the first or second step of the clique percolation algorithm. Thus, if either step exceeded 90 s, the process timed out, and the simpler The protein sequences for each annotation were searched against themselves with the same settings as for the inter-genome searches. The resulting output was processed identically except the HSPs were not filtered using the best gene criterion. Thus, all HSPs for each query were merged into hits. The best hit for each query and target gene was chosen as the hit with the highest sum of bit scores from disjoint HSPs (grouping by target gene ensured that only the highest-scoring isoform was selected). Query–target pairs whose hits exceeded the maximum bit score for all inter-genome hits associated with that query and passed the overlap and reciprocity filters were designated as paralogous pairs. The orthologous groups were supplemented with paralogs by adding the paired sequences for each of the original members of the orthologous group.The sequences in each orthologous group were aligned using MAFFT 7.490 with the following settings: –globalpair –maxiterate 1000 –thread 1 –anysymbol –allowshift –leavegappyregion –unalignlevel 0.4 . Represeamax was set to 0.7. A binary profile was created from the alignment using Gaussian process sequence weighting as described in the section on selecting representative sequences . The binary profile was converted into a binary mask by identifying where the weighted fraction of non-gap symbols exceeded 0.5. The binary mask was closed with a structuring element of size 3, and highly conserved regions were identified as the contiguous intervals of this closed mask with a minimum length of 10. Diverged regions were taken as the complement of the highly conserved regions. For each diverged region, the corresponding segments of the sequences in the initial alignment were extracted and aligned with amax set to 0.4. The resulting sub-alignments were stitched into the initial alignment.The representative sequences in the single copy orthologous groups were aligned with the same settings as described in the previous section except The alignments were coded into gap and non-gap symbols to simplify the emission distributions. The “insertion” phylogenetic hidden Markov model (phylo-HMM) was composed of the 4 hidden states described in the main text. The emission distributions for each consisted of 2 components which modeled the gap pattern and the propensity for those patterns to remain constant (“gap stickiness”), respectively. The first component was a 2-state Markov process which was in turn composed of 2 subprocesses. The first was a phylogenetic process on the on the GTR2 consensus tree described in the section on inferring species trees, and the second was jump process at the tips. The second component was a beta-Bernoulli distribution on the number of symbols which were constant between subsequent columns. The “missing data” phylo-HMM was composed of 2 hidden states which were both parameterized with the same 2-state, 2 component Markov process as the insertion phylo-HMM. However, the emission probabilities were calculated as the posterior probability of the observed symbol given the data rather than the probability of the data. Only the alignments of the single copy orthologous groups were curated, so each tip in the species tree corresponded to a single sequence in the alignment.Supplementary Figs. 4 and 6). Because maximum-likelihood estimation of the model parameters yielded posterior decoding curves which toggled between hidden states too rapidly, the models were instead trained discriminatively . To determine the effect of invariant columns and gaps, 2 sampling strategies were used where invariant columns were allowed or disallowed and the maximum fraction of gaps was set at 0, 50, and 100%. Their combination yielded 6 different sets of meta-alignments. A tree was fit to each meta-alignment with the LG substitution model . All figures are derived from the maximum 50% gap fraction meta-alignment set unless otherwise noted.The orthology inference pipeline was first repeated with the outgroup species on model , 4 discron model , and opton model . If the To fit trees using the GTR model of nucleotide substitution, the protein alignments were converted to nucleotide alignments using the corresponding coding sequences in the genome annotations. Some protein sequences were “low quality,” meaning that their coding sequences contained frameshifts, premature stop codons, or other errors even though they were strong hits to known protein-coding genes. The NCBI annotation pipeline corrects some of these defects in the protein sequences, which can complicate a simple “reverse translation” of the alignment. After rejecting alignments where the expected translation from a coding sequence differed from its corresponding protein sequence, 3,425 alignments remained. Consensus tree were derived from meta-alignments sampled from these alignments using the approach described previously except the GTR model was used in place of the LG model.Supplementary Fig. 9).To fit trees using the 2-state GTR model of substitution, the protein alignments were first coded into gap or non-gap symbols. As before, 100 meta-alignments were constructed from these coded alignments for each sampling strategy. In this case, only the presence of invariant columns was varied, yielding 2 sets of meta-alignments. Trees were fit using the GTR2 model with no rate categories. An invariant category, however, was included if invariant columns were allowed. Since the bootstrap confidences were sometimes lower than 50%, the resulting trees from each set were merged into a loose consensus tree to prevent multifurcations .However, connected components and triangle clustering are special cases of the more general he graph . Clusterhe graph . More spionships . We set Supplementary Fig. 3).A weakness of the best reciprocal hits criterion is its exclusion of recently diverged paralogs. Since only the highest-scoring hits for each query are included in the graph, a paralog without a corresponding duplicate in the target genome is ignored if it is marginally more diverged than the other copy. This is corrected by adding likely paralogs to the orthologous groups. Briefly, the protein sequences in each genome were searched against themselves. If the bit score for an intra-genome hit exceeded the bit score of any inter-genome hits for the same query, the 2 sequences were identified as a paralogous pair. Orthologous groups were then supplemented with paralogs by adding the paired sequences for each of the original members of the orthologous group. Most orthologous groups contain no paralogs, and those that do generally have few relative to the original number of sequences in the group . In contrast, the high sequence identity and clear boundaries of the segments in the latter regions suggest that they are conserved but skipped exons. Given the heterogeneous sourcing of the transcript evidence, these sequences containing these segments are likely splice isoforms specific to certain tissues or developmental stage.Since the segments in these regions are likely the result of incorrect or incomplete annotations rather than meaningful biological variation, maintaining them in the alignments would propagate spurious homologies to subsequent analyses. This is a common issue in alignments generated by automated pipelines, so downstream analyses often focus on the strongly supported regions by removing or “trimming” columns below some threshold number of gaps or sequence identity . This apPhylogenetic hidden Markov models (phylo-HMMs) are statistical models that incorporate phylogenetic and spatial information to calculate the probability that each observation in a sequence was generated by 1 of several hidden states . Since tSupplementary Fig. 5).After the model was trained on manually labeled examples, it was used to assign a label to the columns in each alignment. Columns assigned to state 1 are the regions of interest for downstream analyses since the gaps generally follow the expected pattern given the phylogenetic tree. In contrast, columns assigned to states 2 and 3 largely corresponded to the long poorly supported segments and phylogenetically discordant regions discussed previously and were therefore removed from the alignments. In the example decoded alignment shown, the decoded states closely follow the expected patterns . OverallSupplementary Fig. 7).Though the phylo-HMM removed phylogenetically incongruent insertions, some sequences still contained extensive segments of uninterrupted gaps. These segments are easily identified in regions which are otherwise highly conserved, so they are also likely the result of incorrect or incomplete annotations. However, they can also span more diverged regions, which complicates a simple rule- or threshold-based approach for identifying them. Thus, another phylo-HMM was trained to label each position in a sequence as generated by either a “missing” or “not missing” state. In this case, though, the aligned sequences were processed individually and not as aligned columns. As the previous phylo-HMM already ensured that each column has sufficient support, these labels can instead be used to exclude sequences from downstream analyses depending on the amount of tolerated overlap with the regions of interest. Overall, 15% of alignments have at least 1 sequence with a segment of “missing” data , both trees have an identical topology, which is consistent with other published phylogenies (Excluding the placement of logenies . AdditioDrosophila genus. To assist these efforts, the final alignments after curation and the labels from the “missing” phylo-HMM are provided as supplemental data. Although this work focused on single copy orthologs, other studies may require different subsets of orthologous groups that demand other preprocessing and alignment strategies. Therefore, we have included the orthologous groups and the initial alignments with and without nonrepresentative sequences in the supplemental data as well. While we anticipate these resources will remain relevant in the near term, the trends that permitted this work to substantially improve on previous efforts will render them obsolete in the coming years as more Drosophila genomes are assembled and annotated. However, an authoritative and lasting set of orthologous groups and alignments is not the primary goal of this work. Instead, it serves as a case study in how dense taxonomic sampling and modern genome assembly and annotation pipelines present new opportunities and challenges to the traditional techniques for identifying and aligning orthologous groups.The orthologous groups and alignments yielded by this pipeline are a valuable resource for comparative studies of gene birth/death processes and protein evolution at the level of both entire proteomes and specific gene families in the k-clique percolation where k is a tunable parameter that influences the tightness of a cluster. The optimal value of k for a given set of genomes is unclear and likely depends on the desired tradeoff between sensitivity and specificity. Furthermore, k is not necessarily a global parameter and can instead depend on the properties of each connected component. For example, 1 possibility is to take an entire component as an orthologous group if its number of unique genes and unique species are equal since all the sequences are isoforms of a single set of genes. This would effectively set equal to 1 for this component. Another approach is to make k a decreasing function of the density of edges, so sparser graphs are clustered more permissively. However, percolation theory or simulations may yield additional insights.For example, despite many additional preprocessing steps and other tweaks introduced by later authors, the basic framework of orthology inference by clustering the hit graph has remained largely unchanged in the past 20 years . This loAnother challenge is the annotation of multiple isoforms for a single gene. Though prior pipelines have generally selected the longest isoform as the representative before conducting the orthology searches, if the sequences do not share a common intron–exon structure, this approach can introduce artifacts or other issues during alignment. Instead, as protein sequences are increasingly derived from or linked to genomic sequences, we sought to incorporate the full annotations into the orthology inference pipeline. This, however, created 2 additional complications. First, a single gene could have several associated orthologous groups if its isoforms belonged to different clusters. Second, a single orthologous group could have several isoforms of a single gene if its isoforms were clustered together. In both cases, the presence of multiple sequences for a single gene creates ambiguities over which is the “primary” isoform. Since the first occurs at the level of orthologous groups, the orthologous groups were first grouped by the similarity of their parent genes using a graph-based strategy. Afterwards, a single representative is easily chosen as the group with the largest number of distinct species, though other criteria are possible. Since the second occurs within an orthologous group, the sequences were first aligned, and a representative for each gene was chosen as the sequence which was most concordant with this initial alignment.The second major innovation in this work is its method for the refinement and trimming of alignments. Since sequences produced from automated annotation pipelines can contain long segments which are not homologous to most or any other sequences in their respective orthologous groups, their alignments may contain over-aligned or poorly supported regions which can introduce artifacts into downstream analyses. Thus, in refinement over-alignment is avoided by aligning the sequences in 2 stages. In the first, highly conserved regions are aligned using a strong correction for over-alignment, and in the second, more diverged regions are aligned with a weaker correction. This process usually prevents errors caused by long poorly supported segments without degrading the quality of the alignment. In trimming, a phylo-HMM is used to remove regions which are poorly supported by the phylogenetic consensus.While the combination of these 2 steps yielded high-quality alignments that are suitable for further analyses, they are an ad hoc fix for underlying issues with the gene models and alignment algorithms. The most principled solution is to optimize or supplement the gene models using the initial alignments generated by the orthology inference pipeline, which is possible with tools such as OMGene or OrthoFiller , 2018. HMirage2 (The most popular aligners for protein sequences (Clustal Omega , MAFFT , MUSCLE Mirage2 . The bigThese improvements would enhance rather than replace the phylo-HMM trimming method developed in this work. The model could easily be extended to include a state that outputs a splice symbol before transitioning to 1 of the states in the current architecture. This intermediate state would increase the accuracy of state inference since a splice symbol followed by a phylogenetically discordant gap pattern would strongly signal a state 2 region. The association between state 2 and skipped exons can be made explicit by requiring that transitions to and from state 2 first proceed through the splice state. This of course depends on proper labeling of the training data, which would be trivial since the boundaries between exons would be marked by splice site symbols rather than inferred from gap patterns. Unfortunately, this would not allow the phylo-HMM to label extended exon boundaries as state 2 since they would not be bounded by splice symbols to the left and right. Accordingly, the phylo-HMM would need to permit transitions between state 3 and any other state to accommodate more complex splice variants and other annotation errors. Thus, this extended phylo-HMM would combine the strengths of splice-sensitive alignment with the more heuristic approach used here. Since state 2 inferences would necessarily correspond to skipped exons, they would be suitable for analyses of this form of alternative splicing. Though state 3 inferences would not directly correspond to specific biological process, they still have value as spatially and phylogenetically aware labels for trimming poorly supported segments from alignments.The phylo-HMM could be further enhanced by expanding its emission distribution to include more symbols in the amino acid alphabet. This would allow it to better model observed substitution patterns between specific symbols, for example the high rate of exchange between gaps and glutamine residues caused by polyglutamine tracts. The transitions between amino acids could be parametrized with a published matrix such as LG , but theThough benchmarks are available for optimizing and comparing methods of orthology inference, the metrics are calculated over a set of reference genomes which are sparsely sampled over a broad taxonomic range, so it is unclear if they are informative for method designed to yield robust inferences when the genomes are highly related . FurtherIn contrast, though many HMM packages are available for the Python programming language, we found that none were satisfactorily documented or contained tutorials to introduce HMMs and their APIs to a wide audience. We therefore refactored this code into a package available on PyPI and GitHub called Homomorph. The package itself only implements standard HMM algorithms, but the GitHub repository includes tutorials that introduce the API and implement training routines. Similar tutorials for machine-learning libraries such as TensorFlow have undoubtedly fueled the application of neural networks across diverse fields, but HMMs are also powerful models that can be more appropriate when the data obey certain statistical or structural constraints. Thus, we hope this package and its accompanying tutorials will serve as an on-ramp to HMMs and spur their greater adoption by nonspecialists.Though databases of orthologous groups such as COGs , Ensembl