Answers.Body: <p>Some of the first MSA analysis, eg of codon usage of bacteria were performed using matrix factorization (see old papers from Des Higgins). His group also published discriminative methods for finding functional residues using supervised correspondence analysis </p>
  
  <blockquote>
    <p>Wallace IM1, Higgins DG BMC Bioinformatics. 2007 Apr 23;8:135.
    Supervised multivariate analysis of sequence groups to identify
    specificity determining residues.</p>
  </blockquote>
  
  <p>The method is available in the R package <a href="https://bioconductor.org/packages/ade4" rel="nofollow noreferrer">ade4</a> and Bioconductor package <a href="https://bioconductor.org/packages/made4" rel="nofollow noreferrer">made4</a></p>
  
  <p>Also have a look at the phylogenetic R package <a href="https://cran.r-project.org/package=adephylo" rel="nofollow noreferrer">adephylo</a> and several related packages</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T22:06:57.717Z
Answers.LastActivityDate: 2019-01-09T11:45:09.720Z
Answers.LastEditDate: 2019-01-09T11:45:09.720Z
Answers.UserDisplayName: Aedin
Answers.Body: <p>I personally don't think this will work well for some variables, primarily because you are not mapping conformational epitopes, where amino acids will cluster in physical space by their charge. In particular, the charge is critical to retaining this conformational structure.</p>
  
  <p>However, hydrophobic/hydrophilic characters are far more amenable to linear style epitopes that this analysis is primed towards.</p>
  
  <p>I don't recommend a multi-dimensional array for this analysis, because you have loads of information, but rather a 'dictionary' (Python), hash (Perl) (or 'object' [any]) or XML, which retains all the information for a given sequence and then strips this in preparation for your multivariate statistic. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T19:29:17.647Z
Answers.LastActivityDate: 2019-01-08T19:29:17.647Z
Answers.UserDisplayName: M__
Body: <p>I have a multiple sequence alignment (MSA) of protein sequences, with which I have performed multidimensional scaling to visualize their clustering.  Using R, I used the <code>seqinr</code> package to create an identity matrix (using <code>dist.alignment</code>).  Is there a similar method that is more "generalizable"?  Specifically, I'm interested in classifying the amino acids by some functional characteristics, such as polarity, instead of having the alignment list the amino acids by their identity (A, G, I, etc.).  </p>
  
  <p>Here's a very short set of fake input data, with columns 2-4 representing amino acid residue positions:</p>
  
  <pre><code>a &lt;- c("Strain 1", "Strain 2", "Strain 3", "Strain 4")
  b &lt;- c("Polar_hydrox", "Nonpolar", "Nonpolar", "Polar_hydrox")
  c &lt;- c("Nonpolar", "Nonpolar", "Nonpolar", "Nonpolar")
  d &lt;- c("Nonpolar_cyclic", "Nonpolar_cyclic", "Polar_amide", "Polar_amide")
  e &lt;- c("Polar_amide", "Acidic", "Polar_amide", "Acidic")
  x &lt;- data.frame(a, b, c, d, e)
  </code></pre>
  
  <p>Is what I'm asking a feasible/correct use of MDS?  Or should I be looking into a different method entirely?  I attempted to use Gower's formula to create a dissimilarity matrix on the original dataset (i.e. using the actual amino acid identities instead of the functional groupings), but compared to what I got using <code>dist.alignment</code>, the MDS plots look different.</p>
  
  <p>Edit: Gower's formula and the <code>dist.alignment</code> function are obviously calculating the distance matrices differently, but I don't know the details on the different methods.  Would using Gower's formula be a good approach for calculating distance matrices for the example dataset?</p>
  
  <p>Edit: clarified functions used for calculating distance matrix.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-08T07:57:15.253Z
Comments.Text: If you use different distances metrics it is expected to get different MDS plots. What do you mean by more generalizable? What is your biological goal?
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-08T15:27:35.840Z
Comments.Text: Thanks for your response.  My goal is to see whether sequences appear more related to one another when considering what the functionality of their amino composition is, versus the raw amino acid composition.  I'm interested in the phenomena that not every kind of amino acid change will affect immune escape equally.
Comments.UserDisplayName: Frank Henderson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-08T15:55:54.620Z
Comments.Text: The question is then why do you settle for Gower's formula and not other distance metrics like the Manhattan distance? It is as good as any other distance metric as far as I can tell.
Comments.UserDisplayName: llrs
Tags: <r><clustering>
Title: Using multidimensional scaling to visualize protein sequences by functionality
ThreadText: # Using multidimensional scaling to visualize protein sequences by functionality
  
  (Asked by: username_0 on 2019-01-07)
  
  I have a multiple sequence alignment (MSA) of protein sequences, with which I have performed multidimensional scaling to visualize their clustering. Using R, I used the `seqinr` package to create an identity matrix (using `dist.alignment`). Is there a similar method that is more "generalizable"? Specifically, I'm interested in classifying the amino acids by some functional characteristics, such as polarity, instead of having the alignment list the amino acids by their identity (A, G, I, etc.).
  
  Here's a very short set of fake input data, with columns 2-4 representing amino acid residue positions:
  
  ```
  a <- c("Strain 1", "Strain 2", "Strain 3", "Strain 4")
  b <- c("Polar_hydrox", "Nonpolar", "Nonpolar", "Polar_hydrox")
  c <- c("Nonpolar", "Nonpolar", "Nonpolar", "Nonpolar")
  d <- c("Nonpolar_cyclic", "Nonpolar_cyclic", "Polar_amide", "Polar_amide")
  e <- c("Polar_amide", "Acidic", "Polar_amide", "Acidic")
  x <- data.frame(a, b, c, d, e)
  
  ```
  
  Is what I'm asking a feasible/correct use of MDS? Or should I be looking into a different method entirely? I attempted to use Gower's formula to create a dissimilarity matrix on the original dataset (i.e. using the actual amino acid identities instead of the functional groupings), but compared to what I got using `dist.alignment`, the MDS plots look different.
  
  Edit: Gower's formula and the `dist.alignment` function are obviously calculating the distance matrices differently, but I don't know the details on the different methods. Would using Gower's formula be a good approach for calculating distance matrices for the example dataset?
  
  Edit: clarified functions used for calculating distance matrix.
  
  **Tags:** r, clustering
  
  > **Comments:**
  > **username_1**: If you use different distances metrics it is expected to get different MDS plots. What do you mean by more generalizable? What is your biological goal?  
  > **username_0**: Thanks for your response.  My goal is to see whether sequences appear more related to one another when considering what the functionality of their amino composition is, versus the raw amino acid composition.  I'm interested in the phenomena that not every kind of amino acid change will affect immune escape equally.  
  > **username_1**: The question is then why do you settle for Gower's formula and not other distance metrics like the Manhattan distance? It is as good as any other distance metric as far as I can tell.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-01-08. Score: 2
  
  Some of the first MSA analysis, eg of codon usage of bacteria were performed using matrix factorization (see old papers from Des Higgins). His group also published discriminative methods for finding functional residues using supervised correspondence analysis
  
  > Wallace IM1, Higgins DG BMC Bioinformatics. 2007 Apr 23;8:135.
  > Supervised multivariate analysis of sequence groups to identify
  > specificity determining residues.
  
  The method is available in the R package [ade4](https://bioconductor.org/packages/ade4) and Bioconductor package [made4](https://bioconductor.org/packages/made4)
  
  Also have a look at the phylogenetic R package [adephylo](https://cran.r-project.org/package=adephylo) and several related packages
  
  
  ---
  
  ### Answer by username_3 on 2019-01-08. Score: 1
  
  I personally don't think this will work well for some variables, primarily because you are not mapping conformational epitopes, where amino acids will cluster in physical space by their charge. In particular, the charge is critical to retaining this conformational structure.
  
  However, hydrophobic/hydrophilic characters are far more amenable to linear style epitopes that this analysis is primed towards.
  
  I don't recommend a multi-dimensional array for this analysis, because you have loads of information, but rather a 'dictionary' (Python), hash (Perl) (or 'object' [any]) or XML, which retains all the information for a given sequence and then strips this in preparation for your multivariate statistic.
  
  
  ---
  
  