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.
- discard taxa with amino acid variation
- 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 @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.
The traditional package used for synonymous mutations is/was MEGA, currently version 11. 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 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).