Answers.Body: <p>I proposed Syn-SCAN (below). This was used for HIV and as you are looking at viruses seems a good fit.</p>
  <p><strong>There's a simpler way</strong> ... just make a invariable amino acid alignment, i.e. discard all amino acid variation. MEGA will do that, or use an algorithm. You then simply check the remaining nucleotide sequences for identity and discard the identity (lots of algorithms do this).</p>
  <p>What you are left with is, is what you seek, PURE SYNONYMOUS mutations.</p>
  <ol>
  <li>discard taxa with amino acid variation</li>
  <li>retain taxa nucleotides with variation.</li>
  </ol>
  <p>However, just discarding amino acid variation and retaining everything else will either by identity or synonymous. To be honest, its a virus so the amount of sequence identity between taxa is likely to be very little for protein loci.</p>
  <p>Its really that simple. I honestly wouldn't over complicate it.</p>
  <p>Sorry for the singleton vs. synonymous error, I haven't looked at MEGA in ages. Its a bit bizarre it discarded the only thing it was actually used for.</p>
  <hr />
  <p>The short answer to the question is the 3rd codon position is the traditional approximation for synonymous mutation. A small proportion of 1st codon position sites are neutral and a small proportion of 3rd codon position are non-synonymous.</p>
  <p>I agree with @terdon about and @Community regarding additional information sought, because synonymous mutations are heavily subject to compositional bias and that is a big subject. The key issue is the whether the taxa/species in the alignments are known for compositional bias and the genetic distance between different members of the alignment.</p>
  <p>The traditional package used for synonymous mutations is/was <strong>MEGA</strong>, <a href="https://academic.oup.com/mbe/article/38/7/3022/6248099" rel="nofollow noreferrer">currently version 11</a>. Albeit, recent 'upgrades' seem to remove the synonymous distance matrix calculation. HOWEVER, they may have transferred this capability onto its what appears to be upgraded GUI alignment viewer. What I think is if you:</p>
  <ul>
  <li>load the alignment into the GUI;</li>
  <li>click alignment (big button far left of menu);</li>
  <li>you will now see the alignment;</li>
  <li>in the middle of the menu bar are 4 buttons 'C', 'V', 'Pi' and 'S'</li>
  <li>I think 'S' = synonymous</li>
  <li>All synonymous sites in the alignment are now highlighted and there is likely a method of extracting this information.</li>
  </ul>
  <p>C=constant, V=variable Pi=Nei approximation of diversity (population genetics)</p>
  <p>If this is correct then those are the subset sought, please note however you will need to select/deselect the taxa manually and reassess the synonymous sites after each 'point and click' iteration (the S button will remain active I suspect between each selection/deselection). What you appear to want is a synonymous tree and this function I believe was removed from MEGA.</p>
  <p>MEGA is rarely used except for teaching because its functionality is available elsewhere that permit a given algorithm to be integrated into a data pipeline, which MEGA would not permit (might have recently changed). Hence my recollection of MEGA is a little vague.</p>
  <hr />
  <p>The package used for synonymous work is <a href="http://abacus.gene.ucl.ac.uk/software/paml.html" rel="nofollow noreferrer">PAML</a> and remains the undisputed standard without question in the context of formal selection analysis, which is heavily dependent on a estimate of synonymous mutations. What you refer to as 'synonymous mutation' isn't the same as the phylogenetic definition, i.e. your definition depends on the other members of the alignment, whereas this isn't an issue in the phylogenetic definition (because the tree circumvents this, i.e. delineates subsets) except if compositional bias occurs ... huge amounts of work is/has been dedicated to compositional bias.</p>
  <p>Final point is the widely used phylogenetic library in R called <code>ape</code> will not perform a synonymous mutation calculation - I think, however phangorn library in R might do, but is more likely within the context of selection analysis. Thus to answer the question directly, I don't think R will do this calculation.</p>
  <hr />
  <p>It transpires S= singleton (sorry) ....</p>
  <p>Have a look at Syn-SCAN. The link is here <a href="https://hivdb.stanford.edu/pages/synscan.html" rel="nofollow noreferrer">https://hivdb.stanford.edu/pages/synscan.html</a> . I have never used it and the download link is on the website. The good thing is its written in Perl so it would be easy to modify and check (if you can read/write Perl).</p>
  <p>PAML: you can't detach the synonymous mutation calculation from the non-synonymous mutation calculation, without delving into the C-code (which I wouldn't recommend).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-27T13:14:42.207Z
Answers.Text: "Final point is whether R's ape": ape? Should that be API or something else entirely?
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-27T17:42:08.187Z
Answers.Text: Thank you @M_ for the above! I edited my question in response. Thanks again!
Answers.UserDisplayName: ksw
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-27T20:57:14.453Z
Answers.Text: Hi @terdon .. sorry ape is a popular phylogenetics library in R. Personally, I think its over-used. Its not an API ... I will clarify the text.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-28T10:08:15.360Z
Answers.Text: Thanks! As for "Personally, I think its over-used", that's how I feel about R :P
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-27T12:23:15.430Z
Answers.LastActivityDate: 2022-04-28T01:34:18.787Z
Answers.LastEditDate: 2022-04-28T01:34:18.787Z
Answers.UserDisplayName: M__
Body: <p>Could someone kindly recommend a tool or R package that can identify synonymous sites in a multiple sequence alignment?</p>
  <p>I wish to select those taxa for tree reconstruction and other downstream analyses within subset of the alignment.</p>
  <p>To respond to the questions below: yes, I am interested in identifying synonymous sites within a multiple sequence alignment (DNA) of ~70 virus samples with limited genetic diversity. My goal is to subset the multiple sequence alignment including synonymous sites only, because we believe that there are parallel non-synonymous mutations occurring that do not provide information on shared evolutionary history.</p>
  <p>Thank you @M_ for the really helpful information below. In Mega, the S tool identifies singleton sites rather than synonymous sites in a multiple sequence alignment. I'm wondering if there is another tool or a PAML option to subset the synonymous sites?</p>
  <p>Thank you in advance and best!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-04-27T09:59:10.210Z
Comments.Text: Do we also need to handle the translation, or is it already a protein alignment? Are we talking about two sequences or more? What kind of output do you need? Visual? Or text? Something else?
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-04-27T11:38:24.113Z
Comments.Text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comments.UserDisplayName: Community
Tags: <phylogenetics><phylogeny><synonymous-mutations>
Title: Select synonymous sites from a multiple sequence alignment
ThreadText: # Select synonymous sites from a multiple sequence alignment
  
  (Asked by: username_0 on 2022-04-27)
  
  Could someone kindly recommend a tool or R package that can identify synonymous sites in a multiple sequence alignment?
  
  I wish to select those taxa for tree reconstruction and other downstream analyses within subset of the alignment.
  
  To respond to the questions below: yes, I am interested in identifying synonymous sites within a multiple sequence alignment (DNA) of ~70 virus samples with limited genetic diversity. My goal is to subset the multiple sequence alignment including synonymous sites only, because we believe that there are parallel non-synonymous mutations occurring that do not provide information on shared evolutionary history.
  
  Thank you @M\_ for the really helpful information below. In Mega, the S tool identifies singleton sites rather than synonymous sites in a multiple sequence alignment. I'm wondering if there is another tool or a PAML option to subset the synonymous sites?
  
  Thank you in advance and best!
  
  **Tags:** phylogenetics, phylogeny, synonymous-mutations
  
  > **Comments:**
  > **username_1**: Do we also need to handle the translation, or is it already a protein alignment? Are we talking about two sequences or more? What kind of output do you need? Visual? Or text? Something else?  
  > **username_2**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2022-04-27. Score: 0
  
  I proposed Syn-SCAN (below). This was used for HIV and as you are looking at viruses seems a good fit.
  
  **There's a simpler way** ... just make a invariable amino acid alignment, i.e. discard all amino acid variation. MEGA will do that, or use an algorithm. You then simply check the remaining nucleotide sequences for identity and discard the identity (lots of algorithms do this).
  
  What you are left with is, is what you seek, PURE SYNONYMOUS mutations.
  
  1. discard taxa with amino acid variation
  2. retain taxa nucleotides with variation.
  
  However, just discarding amino acid variation and retaining everything else will either by identity or synonymous. To be honest, its a virus so the amount of sequence identity between taxa is likely to be very little for protein loci.
  
  Its really that simple. I honestly wouldn't over complicate it.
  
  Sorry for the singleton vs. synonymous error, I haven't looked at MEGA in ages. Its a bit bizarre it discarded the only thing it was actually used for.
  
  ---
  
  The short answer to the question is the 3rd codon position is the traditional approximation for synonymous mutation. A small proportion of 1st codon position sites are neutral and a small proportion of 3rd codon position are non-synonymous.
  
  I agree with @username_1 about and @username_2 regarding additional information sought, because synonymous mutations are heavily subject to compositional bias and that is a big subject. The key issue is the whether the taxa/species in the alignments are known for compositional bias and the genetic distance between different members of the alignment.
  
  The traditional package used for synonymous mutations is/was **MEGA**, [currently version 11](https://academic.oup.com/mbe/article/38/7/3022/6248099). Albeit, recent 'upgrades' seem to remove the synonymous distance matrix calculation. HOWEVER, they may have transferred this capability onto its what appears to be upgraded GUI alignment viewer. What I think is if you:
  
  * load the alignment into the GUI;
  * click alignment (big button far left of menu);
  * you will now see the alignment;
  * in the middle of the menu bar are 4 buttons 'C', 'V', 'Pi' and 'S'
  * I think 'S' = synonymous
  * All synonymous sites in the alignment are now highlighted and there is likely a method of extracting this information.
  
  C=constant, V=variable Pi=Nei approximation of diversity (population genetics)
  
  If this is correct then those are the subset sought, please note however you will need to select/deselect the taxa manually and reassess the synonymous sites after each 'point and click' iteration (the S button will remain active I suspect between each selection/deselection). What you appear to want is a synonymous tree and this function I believe was removed from MEGA.
  
  MEGA is rarely used except for teaching because its functionality is available elsewhere that permit a given algorithm to be integrated into a data pipeline, which MEGA would not permit (might have recently changed). Hence my recollection of MEGA is a little vague.
  
  ---
  
  The package used for synonymous work is [PAML](http://abacus.gene.ucl.ac.uk/software/paml.html) and remains the undisputed standard without question in the context of formal selection analysis, which is heavily dependent on a estimate of synonymous mutations. What you refer to as 'synonymous mutation' isn't the same as the phylogenetic definition, i.e. your definition depends on the other members of the alignment, whereas this isn't an issue in the phylogenetic definition (because the tree circumvents this, i.e. delineates subsets) except if compositional bias occurs ... huge amounts of work is/has been dedicated to compositional bias.
  
  Final point is the widely used phylogenetic library in R called `ape` will not perform a synonymous mutation calculation - I think, however phangorn library in R might do, but is more likely within the context of selection analysis. Thus to answer the question directly, I don't think R will do this calculation.
  
  ---
  
  It transpires S= singleton (sorry) ....
  
  Have a look at Syn-SCAN. The link is here <https://hivdb.stanford.edu/pages/synscan.html> . I have never used it and the download link is on the website. The good thing is its written in Perl so it would be easy to modify and check (if you can read/write Perl).
  
  PAML: you can't detach the synonymous mutation calculation from the non-synonymous mutation calculation, without delving into the C-code (which I wouldn't recommend).
  
  > **Comments:**
  > **username_1**: "Final point is whether R's ape": ape? Should that be API or something else entirely?  
  > **username_0**: Thank you @M_ for the above! I edited my question in response. Thanks again!  
  > **username_3**: Hi @username_1 .. sorry ape is a popular phylogenetics library in R. Personally, I think its over-used. Its not an API ... I will clarify the text.  
  > **username_1**: Thanks! As for "Personally, I think its over-used", that's how I feel about R :P  
  
  ---
  
  