49019a7ec2541b44b465fb4090c8b1992ef49f04
[jalview.git] / help / html / calculations / pca.html
1 <html>
2 <!--
3  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
4  * Copyright (C) 2014 The Jalview Authors
5  * 
6  * This file is part of Jalview.
7  * 
8  * Jalview is free software: you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License 
10  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
18  * The Jalview Authors are detailed in the 'AUTHORS' file.
19 -->
20 <head>
21 <title>Principal Component Analysis</title>
22 </head>
23 <body>
24 <p><strong>Principal Component Analysis</strong></p>
25 <p>This calculation creates a spatial representation of the
26 similarities within a selected group, or all of the sequences in an
27 alignment. After the calculation finishes, a 3D viewer displays the set
28 of sequences as points in 'similarity space', and similar sequences tend
29 to lie near each other in the space.</p>
30 <p><em>Caveats</em><br/>The calculation is computationally expensive, and may fail
31 for very large sets of sequences - usually because the JVM has run out
32 of memory. A future release of Jalview will be able to avoid this by
33 executing the calculation via a web service.</p>
34
35 <p><strong>About PCA</strong>Principal components analysis is a technique for examining the
36 structure of complex data sets. The components are a set of dimensions
37 formed from the measured values in the data set, and the principle
38 component is the one with the greatest magnitude, or length. The sets of
39 measurements that differ the most should lie at either end of this
40 principle axis, and the other axes correspond to less extreme patterns
41 of variation in the data set.</p>
42
43         <p>
44                 <em>Calculating PCAs for aligned sequences</em><br />Jalview can
45                 perform PCA analysis on both proteins and nucleotide sequence
46                 alignments. In both cases, components are generated by an eigenvector
47                 decomposition of the matrix formed from the sum of substitution matrix
48                 scores at each aligned position between each pair of sequences -
49                 computed with one of the available score matrices, such as
50                 <a href="scorematrices.html#blosum62">BLOSUM62</a>, <a
51                         href="scorematrices.html#pam250">PAM250</a>, or the <a
52                         href="scorematrices.html#simplenucleotide">simple single
53                         nucleotide substitution matrix</a>. The options available for
54                 calculation are given in the
55                 <strong><em>Change Parameters</em></strong> menu.<br /> Jalview allows
56                 two types of PCA calculation. The default
57                 <em><strong>Jalview PCA Calculation</strong></em> mode (indicated when
58                 that option is ticked in the
59                 <strong><em>Change Parameters</em></strong> menu) of the viewer
60                 performs PCA on a matrix where elements in the upper diagonal give the
61                 sum of scores for mutating in one direction, and the lower diagonal is
62                 the sum of scores for mutating in the other. For protein substitution
63                 models like BLOSUM62, this gives an asymmetric matrix, and a different
64                 PCA to one produced with the method described in the paper by G.
65                 Casari, C. Sander and A. Valencia. Structural Biology volume 2, no. 2,
66                 February 1995 (<a
67                         href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=7749921">pubmed</a>)
68                 and implemented at the SeqSpace server at the EBI. The original method
69                 preconditions the matrix by multiplying it with its transpose, and
70                 this mode is enabled by unchecking the
71                 <strong><em>Jalview PCA Calculation</em></strong> option in the
72                 <strong><em>Change Parameters</em></strong> menu.
73         </p>
74 <img src="pcaviewer.gif">
75         <p><strong>The PCA Viewer</strong></p>
76 <p>This is an interactive display of the sequences positioned within
77 the similarity space, as points in a rotateable 3D scatterplot. The
78 colour of each sequence point is the same as the sequence group colours,
79 white if no colour has been defined for the sequence, and green if the
80 sequence is part of a the currently selected group.</p>
81 <p>The 3d view can be rotated by dragging the mouse with the <strong>left
82 mouse button</strong> pressed. The view can also be zoomed in and out with the up
83 and down <strong>arrow keys</strong> (and the roll bar of the mouse if
84 present). Labels will be shown for each sequence if the entry in the
85 View menu is checked, and the plot background colour changed from the
86 View&#8594;Background Colour.. dialog box. The File menu allows the view
87 to be saved (<strong>File&#8594;Save</strong> submenu) as an EPS or PNG
88 image or printed, and the original alignment data and matrix resulting
89 from its PCA analysis to be retrieved. The coordinates for the whole PCA
90 space, or just the current view may also be exported as CSV files for
91 visualization in another program or further analysis.<p>
92 <p>Options for coordinates export are:</p>
93 <ul>
94 <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>
95 <li>Output Points - The eigenvector matrix - rows correspond to sequences, columns correspond to each dimension in the PCA</li>
96 <li>Transformed Points - The 3D coordinates for each sequence as shown in the PCA plot</li></ul>
97
98 <p>A tool tip gives the sequence ID corresponding to a point in the
99 space, and clicking a point toggles the selection of the corresponding
100 sequence in the associated alignment window views.<!-- Rectangular region
101 based selection is also possible, by holding the 'S' key whilst
102 left-clicking and dragging the mouse over the display. --> By default,
103 points are only associated with the alignment view from which the PCA
104 was calculated, but this may be changed via the <strong>View&#8594;Associate
105 Nodes</strong> sub-menu.</p>
106 <p>Initially, the display shows the first three components of the
107 similarity space, but any eigenvector can be used by changing the
108 selected dimension for the x, y, or z axis through each ones menu
109 located below the 3d display. The <strong><em>Reset</em></strong> button will reset axis and rotation settings to their defaults.</p>
110 <p>
111 <p>
112 <em>The output of points and transformed point coordinates was added to the Jalview desktop in v2.7.</em>
113 <em>The Reset button and Change Parameters menu were added in Jalview 2.8.</em>
114 <em>Support for PAM250 based PCA was added in Jalview 2.8.1.</em>
115 </body>
116 </html>