Answers.Body: <p>Your strategy is fine but the order is wrong.</p>
  <p>What I would do is:</p>
  <ul>
  <li>2 -&gt; checked by 4 and 6</li>
  </ul>
  <p>Run <em>usearch</em> and check the output of that in HMMER3. You can then use this to kick out stuff from usearch, that are not real homologues.  Thats what HMMER3, hmmeralign (I dunno hmmersearch), are doing (below). It's also possible the HMMER approaches could replace usearch.</p>
  <p>Once you have identified your homologues with confidence you can then align each separate group via <em>muscle5</em></p>
  <p><strong>Your way</strong></p>
  <p>What you are doing is using HMMER3 to assess the quality of the alignment. What could be a problem is feeding <em>usearch</em> straight into muscle5 ... a non-homologous protein will get you a bad alignment. The bad alignment will not give you a good tree. <em>Both aligners and trees need nice homologues, otherwise they don't work.</em> The errors between aligner (muscle5) and tree are also synergistic. Thus if that bad sequences isn't removed by hmmer stuff then alignment errors compound onto sequence errors in the bad sequence giving a really bad tree.</p>
  <p>You could of course align, HMMER3, filter stuff then align again (thats much better a bit complicated).</p>
  <p>I don't know how good usearch is - but you are relying on it alot, supposing it gives you orthologues at &lt;25% identity that could be any protein. Basically you are feeding that stuff straight into muscle5 and if HMMER3 doesn't trap it that will go straight onto a tree. That could be a bad alignment and that would be a bad tree.</p>
  <p><strong>Summary</strong></p>
  <ol>
  <li><p>What you have to understand is phylogenetic trees are very sensitive to bad sequences, i.e. stuff that is not true homologues. The aligner will also be sensitive. There will also be bad synergistic relationships between the two.</p>
  </li>
  <li><p>HMMER3 and is associated methods (hmmeralign) are trying to clean stuff up before that stage, rather than simply relying on <em>usearch</em>. Prof Eddie (HMMER and pfam[?] author) has an excellent reputation in this area - not in tree building but identifying protein families and thats what you are doing here.</p>
  </li>
  <li><p>hmmeralign doesn't replace muscle5, but it will provide a very good assessment of the protein families around a given seed. It's going to give you the homologues. That output would then go to muscle5 to get homologous sites.</p>
  </li>
  <li><p>The tree needs <em>both</em> homologues and homologous sites.</p>
  </li>
  </ol>
  <p>The whole hmmer project has a really good reputation in the area of protein family identification and thats why its been recommended.</p>
  <p><strong>Probable simple answer</strong> I think the answer to the question is you're are confusing hmmeralign with muscle5. They are complimentary but distinct. Again hmmeralign identifies homologues and the muscle5 designates homologous sites.</p>
  <hr />
  <p>Answering the comments</p>
  <blockquote>
  <p>50% cut-off</p>
  </blockquote>
  <p>It looks like <em>usearch</em> clusters according to a %age identity threshold.</p>
  <p>There are three weaknesses:</p>
  <ol>
  <li>Gene duplication can take place about 50% ... it depends whether thats cool, usually it isn't, but it's your call.</li>
  <li>There can be complete change of function &gt;50% identity and this is about the definition of a homologue. If you are using a functional definition its not a homologue</li>
  <li>Homologues can have &lt;&lt;50% identity and thats very common certainly in viruses I don't know about bacteria.</li>
  </ol>
  <p>hmmersearch is going to rank your data according to the hmmer algorithms. It's going to be like blast,but all hmmer algorithms are focused around defining protein families (it's a better approach than blast <em>for this</em> application). So it provides another option to assess the output of <em>usearch</em>. Thus if there a gene duplication for example you should be able to spot it (it will be a sharp break in the continuous output). This will help you assess you 50% cut-off.</p>
  <p>hmmeralign would be quite cool, because you can take a representation of <em>usearch</em> and then search that via hmmeralign and see if you get a similar output. It is extremely important for assessing 50% cut-off, does the homology drop below 50%? hmmeralign will tell you, but it must see the complete original database (not the stuff extracted from <em>usearch</em>. You can cross check that with hmmersearch to assess where hmmeralign is making the cut-off. So hmmeralign will independently (or <em>usearch</em>) will find you homologues and hmmersearch will give you an insight about how it's done it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-25T05:20:35.497Z
Answers.Text: I have trouble seeing where hmmsearch fits in here, or is it not meant to?
Answers.UserDisplayName: donkey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-26T23:44:58.457Z
Answers.Text: One more point of confusion. If you suggest I check hmmalign with usearch, then what alignment do you recommend I feed to hmmbuild? Just a straight alignment from muscle5?
Answers.UserDisplayName: donkey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-27T02:00:04.263Z
Answers.Text: I would go straight into muscle5, without hesitation. Thats because if something goes wrong I'd spot it in the tree and the outputs. If you're phylogenetics isn't so strong, you might want to perform all 'sanity checks' in hmmer.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-25T01:12:34.027Z
Answers.LastActivityDate: 2023-06-25T22:06:30.633Z
Answers.LastEditDate: 2023-06-25T22:06:30.633Z
Answers.UserDisplayName: M__
Body: <p>My goal is to understand the phylogeny of genes involved in bacterial restriction-modification systems, in psychrophilic bacteria.</p>
  <p>To do so here is what I have done.</p>
  <ol>
  <li>Downloaded the protein sequences of all RM genes in psychrophilic bacteria from REBASE. I also downloaded a set of genomes I'd like understand the phylogeny of from NCBI.</li>
  <li>Clustered these genes using usearch's <code>uclust</code> method.</li>
  <li>Aligned the resulting centroids using MUSCLE5.</li>
  <li>Built an HMM from the aligned centroids using HMMER3.</li>
  <li>Ran <code>hmmsearch</code> to get hits from my HMM on each genome (AA).</li>
  </ol>
  <p>I am unsure how to proceed now. I now a phylogenetic tree requires an alignment, but I'm not sure where my HMM hits fit-in. Am I meant to use <code>hmmalign</code> on the output of <code>hmmsearch</code> and then feed the resulting alignment to IQ-TREE or similar?</p>
  <p>Thank you for your help as I learn bioinformatics.</p>
  <p>PS: Reading through the forum it seems like MOLE-BLAST does exactly this, however I have too many genes and their length is too long to use the MOLE-BLAST as hosted by NCBI at least.</p>
  <p>I should mention I set the identity threshold of search to 50% for proteins. Also, I got this method from this paper which achieved something similar (<a href="https://pubmed.ncbi.nlm.nih.gov/30893937/" rel="nofollow noreferrer">https://pubmed.ncbi.nlm.nih.gov/30893937/</a>).</p>
  
Tags: <phylogenetics><phylogeny><hmmer>
Title: How to determine the phylogeny of a specific set of genes
ThreadText: # How to determine the phylogeny of a specific set of genes
  
  (Asked by: username_0 on 2023-06-24)
  
  My goal is to understand the phylogeny of genes involved in bacterial restriction-modification systems, in psychrophilic bacteria.
  
  To do so here is what I have done.
  
  1. Downloaded the protein sequences of all RM genes in psychrophilic bacteria from REBASE. I also downloaded a set of genomes I'd like understand the phylogeny of from NCBI.
  2. Clustered these genes using usearch's `uclust` method.
  3. Aligned the resulting centroids using MUSCLE5.
  4. Built an HMM from the aligned centroids using HMMER3.
  5. Ran `hmmsearch` to get hits from my HMM on each genome (AA).
  
  I am unsure how to proceed now. I now a phylogenetic tree requires an alignment, but I'm not sure where my HMM hits fit-in. Am I meant to use `hmmalign` on the output of `hmmsearch` and then feed the resulting alignment to IQ-TREE or similar?
  
  Thank you for your help as I learn bioinformatics.
  
  PS: Reading through the forum it seems like MOLE-BLAST does exactly this, however I have too many genes and their length is too long to use the MOLE-BLAST as hosted by NCBI at least.
  
  I should mention I set the identity threshold of search to 50% for proteins. Also, I got this method from this paper which achieved something similar (<https://pubmed.ncbi.nlm.nih.gov/30893937/>).
  
  **Tags:** phylogenetics, phylogeny, hmmer
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-06-25. Score: 0 | Accepted answer
  
  Your strategy is fine but the order is wrong.
  
  What I would do is:
  
  * 2 -> checked by 4 and 6
  
  Run *usearch* and check the output of that in HMMER3. You can then use this to kick out stuff from usearch, that are not real homologues. Thats what HMMER3, hmmeralign (I dunno hmmersearch), are doing (below). It's also possible the HMMER approaches could replace usearch.
  
  Once you have identified your homologues with confidence you can then align each separate group via *muscle5*
  
  **Your way**
  
  What you are doing is using HMMER3 to assess the quality of the alignment. What could be a problem is feeding *usearch* straight into muscle5 ... a non-homologous protein will get you a bad alignment. The bad alignment will not give you a good tree. *Both aligners and trees need nice homologues, otherwise they don't work.* The errors between aligner (muscle5) and tree are also synergistic. Thus if that bad sequences isn't removed by hmmer stuff then alignment errors compound onto sequence errors in the bad sequence giving a really bad tree.
  
  You could of course align, HMMER3, filter stuff then align again (thats much better a bit complicated).
  
  I don't know how good usearch is - but you are relying on it alot, supposing it gives you orthologues at <25% identity that could be any protein. Basically you are feeding that stuff straight into muscle5 and if HMMER3 doesn't trap it that will go straight onto a tree. That could be a bad alignment and that would be a bad tree.
  
  **Summary**
  
  1. What you have to understand is phylogenetic trees are very sensitive to bad sequences, i.e. stuff that is not true homologues. The aligner will also be sensitive. There will also be bad synergistic relationships between the two.
  2. HMMER3 and is associated methods (hmmeralign) are trying to clean stuff up before that stage, rather than simply relying on *usearch*. Prof Eddie (HMMER and pfam[?] author) has an excellent reputation in this area - not in tree building but identifying protein families and thats what you are doing here.
  3. hmmeralign doesn't replace muscle5, but it will provide a very good assessment of the protein families around a given seed. It's going to give you the homologues. That output would then go to muscle5 to get homologous sites.
  4. The tree needs *both* homologues and homologous sites.
  
  The whole hmmer project has a really good reputation in the area of protein family identification and thats why its been recommended.
  
  **Probable simple answer** I think the answer to the question is you're are confusing hmmeralign with muscle5. They are complimentary but distinct. Again hmmeralign identifies homologues and the muscle5 designates homologous sites.
  
  ---
  
  Answering the comments
  
  > 50% cut-off
  
  It looks like *usearch* clusters according to a %age identity threshold.
  
  There are three weaknesses:
  
  1. Gene duplication can take place about 50% ... it depends whether thats cool, usually it isn't, but it's your call.
  2. There can be complete change of function >50% identity and this is about the definition of a homologue. If you are using a functional definition its not a homologue
  3. Homologues can have <<50% identity and thats very common certainly in viruses I don't know about bacteria.
  
  hmmersearch is going to rank your data according to the hmmer algorithms. It's going to be like blast,but all hmmer algorithms are focused around defining protein families (it's a better approach than blast *for this* application). So it provides another option to assess the output of *usearch*. Thus if there a gene duplication for example you should be able to spot it (it will be a sharp break in the continuous output). This will help you assess you 50% cut-off.
  
  hmmeralign would be quite cool, because you can take a representation of *usearch* and then search that via hmmeralign and see if you get a similar output. It is extremely important for assessing 50% cut-off, does the homology drop below 50%? hmmeralign will tell you, but it must see the complete original database (not the stuff extracted from *usearch*. You can cross check that with hmmersearch to assess where hmmeralign is making the cut-off. So hmmeralign will independently (or *usearch*) will find you homologues and hmmersearch will give you an insight about how it's done it.
  
  > **Comments:**
  > **username_0**: I have trouble seeing where hmmsearch fits in here, or is it not meant to?  
  > **username_0**: One more point of confusion. If you suggest I check hmmalign with usearch, then what alignment do you recommend I feed to hmmbuild? Just a straight alignment from muscle5?  
  > **username_1**: I would go straight into muscle5, without hesitation. Thats because if something goes wrong I'd spot it in the tree and the outputs. If you're phylogenetics isn't so strong, you might want to perform all 'sanity checks' in hmmer.  
  
  ---
  
  