JAL-3111 tweak PCA documentation
[jalview.git] / help / html / calculations / pca.html
index d109f0b..3529cae 100755 (executable)
 <html>
 <!--
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
--->
+ -->
 <head>
 <title>Principal Component Analysis</title>
 </head>
 <body>
-<p><strong>Principal Component Analysis</strong></p>
-<p>This calculation creates a spatial representation of the
-similarities within a selected group, or all of the sequences in an
-alignment. After the calculation finishes, a 3D viewer displays the set
-of sequences as points in 'similarity space', and similar sequences tend
-to lie near each other in the space.</p>
-<p><em>Caveats</em><br/>The calculation is computationally expensive, and may fail
-for very large sets of sequences - usually because the JVM has run out
-of memory. A future release of Jalview will be able to avoid this by
-executing the calculation via a web service.</p>
+  <p>
+    <strong>Principal Component Analysis</strong>
+  </p>
+  <p>
+    A principal component analysis can be performed via the <a
+      href="calculations.html">calculations dialog</a> which is accessed
+    by selecting <strong>Calculate&#8594;Calculate Tree or
+      PCA...</strong>.
+  </p>
+  <p>This calculation creates a spatial representation of the
+    similarities within a selected group, or all of the sequences in an
+    alignment. After the calculation finishes, a 3D viewer displays the
+    set of sequences as points in 'similarity space', and similar
+    sequences tend to lie near each other in the space.</p>
+  <p>
+    <em>Caveats</em><br />The calculation can be computationally
+    expensive, and may fail for very large sets of sequences - usually
+    because the JVM has run out of memory. However, the PCA
+    implementation in Jalview 2.10.2 employs more memory efficient
+    matrix storage structures, allowing larger PCAs to be performed.
+  </p>
 
-<p><strong>About PCA</strong></p>
-<p>Principal components analysis is a technique for examining the
-structure of complex data sets. The components are a set of dimensions
-formed from the measured values in the data set, and the principle
-component is the one with the greatest magnitude, or length. The sets of
-measurements that differ the most should lie at either end of this
-principle axis, and the other axes correspond to less extreme patterns
-of variation in the data set.</p>
+  <p>
+    <strong>About PCA</strong>
+  </p>
+  <p>Principal components analysis is a technique for examining the
+    structure of complex data sets. The components are a set of
+    dimensions formed from the measured values in the data set, and the
+    principal component is the one with the greatest magnitude, or
+    length. The sets of measurements that differ the most should lie at
+    either end of this principal axis, and the other axes correspond to
+    less extreme patterns of variation in the data set.</p>
 
-       <p>
-               <em>Calculating PCAs for aligned sequences</em><br />Jalview can
-               perform PCA analysis on both proteins and nucleotide sequence
-               alignments. In both cases, components are generated by an eigenvector
-               decomposition of the matrix formed from the sum of substitution matrix
-               scores at each aligned position between each pair of sequences -
-               computed with one of the available score matrices, such as
-               <a href="scorematrices.html#blosum62">BLOSUM62</a>, <a
-                       href="scorematrices.html#pam250">PAM250</a>, or the <a
-                       href="scorematrices.html#simplenucleotide">simple single
-                       nucleotide substitution matrix</a>. The options available for
-               calculation are given in the
-               <strong><em>Change Parameters</em></strong> menu.</p>
-       <p>
-       <em>PCA Calculation modes</em><br/>
-               The default Jalview calculation mode
-               (indicated when <em><strong>Jalview PCA Calculation</strong></em> is
-               ticked in the <strong><em>Change Parameters</em></strong> menu) is to
-               perform a PCA on a matrix where elements in the upper diagonal give
-               the sum of scores for mutating in one direction, and the lower
-               diagonal is the sum of scores for mutating in the other. For protein
-               substitution models like BLOSUM62, this gives an asymmetric matrix,
-               and a different PCA to a matrix produced with the method described in the
-               paper by G. Casari, C. Sander and A. Valencia. Structural Biology
-               volume 2, no. 2, February 1995 (<a
-                       href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=7749921">pubmed</a>)
-               and implemented at the SeqSpace server at the EBI. This method
-               preconditions the matrix by multiplying it with its transpose, and can be employed in the PCA viewer by unchecking the <strong><em>Jalview
-                               PCA Calculation</em></strong> option in the <strong><em>Change
-                               Parameters</em></strong> menu.
-       </p>
-       <img src="pcaviewer.gif">
-       <p><strong>The PCA Viewer</strong></p>
-<p>This is an interactive display of the sequences positioned within
-the similarity space, as points in a rotateable 3D scatterplot. The
-colour of each sequence point is the same as the sequence group colours,
-white if no colour has been defined for the sequence, and green if the
-sequence is part of a the currently selected group.</p>
-<p>The 3d view can be rotated by dragging the mouse with the <strong>left
-mouse button</strong> pressed. The view can also be zoomed in and out with the up
-and down <strong>arrow keys</strong> (and the roll bar of the mouse if
-present). Labels will be shown for each sequence if the entry in the
-View menu is checked, and the plot background colour changed from the
-View&#8594;Background Colour.. dialog box. The File menu allows the view
-to be saved (<strong>File&#8594;Save</strong> submenu) as an EPS or PNG
-image or printed, and the original alignment data and matrix resulting
-from its PCA analysis to be retrieved. The coordinates for the whole PCA
-space, or just the current view may also be exported as CSV files for
-visualization in another program or further analysis.<p>
-<p>Options for coordinates export are:</p>
-<ul>
-<li>Output Values - complete dump of analysis (TxT* matrix computed from sum of scores for all pairs of aligned residues from from i->j and j->i, conditioned matrix to be diagonalised, tridiagonal form, major eigenvalues found)</li>
-<li>Output Points - The eigenvector matrix - rows correspond to sequences, columns correspond to each dimension in the PCA</li>
-<li>Transformed Points - The 3D coordinates for each sequence as shown in the PCA plot</li></ul>
+  <p>
+    <em>Calculating PCAs for aligned sequences</em><br />Jalview can
+    perform PCA analysis on both proteins and nucleotide sequence
+    alignments. In both cases, components are generated by an
+    eigenvector decomposition of the matrix formed from pairwise similarity
+    scores between each pair of sequences. The similarity score model is 
+    selected on the <a href="calculations.html">calculations dialog</a>, and
+    may use one of the available score matrices, such as 
+    <a href="scorematrices.html#blosum62">BLOSUM62</a>,
+    <a href="scorematrices.html#pam250">PAM250</a>, or the <a
+      href="scorematrices.html#simplenucleotide">simple single
+      nucleotide substitution matrix</a>, or by sequence percentage identity,
+      or sequence feature similarity. 
+  </p>
+  <img src="pcaviewer.gif">
+  <p>
+    <strong>The PCA Viewer</strong>
+  </p>
+  <p>This is an interactive display of the sequences positioned
+    within the similarity space, as points in a rotateable 3D
+    scatterplot. The colour of each sequence point is the same as the
+    sequence group colours, white if no colour has been defined for the
+    sequence, and grey if the sequence is part of the currently selected
+    group. The viewer also employs depth cueing, so points appear darker
+    the farther away they are, and become brighter as they are rotated
+    towards the front of the view.</p>
+  <p>
+    The 3d view can be rotated by dragging the mouse with the <strong>left
+      mouse button</strong> pressed. The view can also be zoomed in and out with
+    the up and down <strong>arrow keys</strong> (and the roll bar of the
+    mouse if present). Labels will be shown for each sequence if the
+    entry in the View menu is checked, and the plot background colour
+    changed from the View&#8594;Background Colour.. dialog box. The File
+    menu allows the view to be saved (<strong>File&#8594;Save</strong>
+    submenu) as an EPS or PNG image or printed, and the original
+    alignment data and matrix resulting from its PCA analysis to be
+    retrieved. The coordinates for the whole PCA space, or just the
+    current view may also be exported as CSV files for visualization in
+    another program or further analysis.
+  <p>
+  <p>Options for coordinates export are:</p>
+  <ul>
+    <li>Output Values - complete dump of analysis (TxT* matrix
+      computed from sum of scores for all pairs of aligned residues from
+      from i->j and j->i, conditioned matrix to be diagonalised,
+      tridiagonal form, major eigenvalues found)</li>
+    <li>Output Points - The eigenvector matrix - rows correspond to
+      sequences, columns correspond to each dimension in the PCA</li>
+    <li>Transformed Points - The 3D coordinates for each sequence
+      as shown in the PCA plot</li>
+  </ul>
 
-<p>A tool tip gives the sequence ID corresponding to a point in the
-space, and clicking a point toggles the selection of the corresponding
-sequence in the associated alignment window views.<!-- Rectangular region
+  <p>
+    A tool tip gives the sequence ID corresponding to a point in the
+    space, and clicking a point toggles the selection of the
+    corresponding sequence in the associated alignment window views.
+    <!-- Rectangular region
 based selection is also possible, by holding the 'S' key whilst
-left-clicking and dragging the mouse over the display. --> By default,
-points are only associated with the alignment view from which the PCA
-was calculated, but this may be changed via the <strong>View&#8594;Associate
-Nodes</strong> sub-menu.</p>
-<p>Initially, the display shows the first three components of the
-similarity space, but any eigenvector can be used by changing the
-selected dimension for the x, y, or z axis through each ones menu
-located below the 3d display. The <strong><em>Reset</em></strong> button will reset axis and rotation settings to their defaults.</p>
-<p>
-<p>
-<em>The output of points and transformed point coordinates was added to the Jalview desktop in v2.7.</em>
-<em>The Reset button and Change Parameters menu were added in Jalview 2.8.</em>
-<em>Support for PAM250 based PCA was added in Jalview 2.8.1.</em>
+left-clicking and dragging the mouse over the display. -->
+    By default, points are only associated with the alignment view from
+    which the PCA was calculated, but this may be changed via the <strong>View&#8594;Associate
+      Nodes</strong> sub-menu.
+  </p>
+  <p>
+    Initially, the display shows the first three components of the
+    similarity space, but any eigenvector can be used by changing the
+    selected dimension for the x, y, or z axis through each ones menu
+    located below the 3d display. The <strong><em>Reset</em></strong>
+    button will reset axis and rotation settings to their defaults.
+  </p>
+  <p>
+  <p>
+    <em>The output of points and transformed point coordinates was
+      added to the Jalview desktop in v2.7.</em> <em>The Reset button
+      and Change Parameters menu were added in Jalview 2.8.</em> <em>Support
+      for PAM250 based PCA was added in Jalview 2.8.1.</em>
+  </p>
+  <p>
+    <strong>Reproducing PCA calculations performed with older
+      Jalview releases</strong> Jalview 2.10.2 included a revised PCA
+    implementation which treated Gaps and non-standard residues in the
+    same way as a matrix produced with the method described in the paper
+    by G. Casari, C. Sander and A. Valencia. Structural Biology volume
+    2, no. 2, February 1995 (<a
+      href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=7749921">pubmed</a>)
+    and implemented at the SeqSpace server at the EBI. To reproduce
+    calculations performed with earlier Jalview releases it is necessary
+    to execute the following Groovy script:
+  <pre>
+    jalview.analysis.scoremodels.ScoreMatrix.scoreGapAsAny=true
+    jalview.analysis.scoremodels.ScoreModels.instance.BLOSUM62.@matrix[4][1]=3
+    </pre>
+  This script enables the legacy PCA mode where gaps were treated as
+  'X', and to modify the BLOSUM62 matrix so it is asymmetric for
+  mutations between C to R (this was a typo in the original Jalview
+  BLOSUM62 matrix which was fixed in 2.10.2).
+  </p>
 </body>
 </html>