3 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
4 * Copyright (C) $$Year-Rel$$ The Jalview Authors
6 * This file is part of Jalview.
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
11 * of the License, or (at your option) any later version.
13 * Jalview is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 <title>Principal Component Analysis</title>
27 <strong>Principal Component Analysis</strong>
30 A principal component analysis can be performed via the <a
31 href="calculations.html">calculations dialog</a> which is accessed
32 by selecting <strong>Calculate→Calculate Tree or
35 <p>This calculation creates a spatial representation of the
36 similarities within a selected group, or all of the sequences in an
37 alignment. After the calculation finishes, a 3D viewer displays the
38 set of sequences as points in 'similarity space', and similar
39 sequences tend to lie near each other in the space.</p>
41 <em>Caveats</em><br />The calculation can be computationally
42 expensive, and may fail for very large sets of sequences - usually
43 because the JVM has run out of memory. However, the PCA
44 implementation in Jalview 2.10.2 employs more memory efficient
45 matrix storage structures, allowing larger PCAs to be performed.
49 <strong>About PCA</strong>
51 <p>Principal components analysis is a technique for examining the
52 structure of complex data sets. The components are a set of
53 dimensions formed from the measured values in the data set, and the
54 principal component is the one with the greatest magnitude, or
55 length. The sets of measurements that differ the most should lie at
56 either end of this principal axis, and the other axes correspond to
57 less extreme patterns of variation in the data set.</p>
60 <em>Calculating PCAs for aligned sequences</em><br />Jalview can
61 perform PCA analysis on both proteins and nucleotide sequence
62 alignments. In both cases, components are generated by an
63 eigenvector decomposition of the matrix formed from pairwise similarity
64 scores between each pair of sequences. The similarity score model is
65 selected on the <a href="calculations.html">calculations dialog</a>, and
66 may use one of the available score matrices, such as
67 <a href="scorematrices.html#blosum62">BLOSUM62</a>,
68 <a href="scorematrices.html#pam250">PAM250</a>, or the <a
69 href="scorematrices.html#simplenucleotide">simple single
70 nucleotide substitution matrix</a>, or by sequence percentage identity,
71 or sequence feature similarity.
73 <img src="pcaviewer.png">
75 <strong>The PCA Viewer</strong>
77 <p>This is an interactive display of the sequences positioned
78 within the similarity space, as points in a rotateable 3D
79 scatterplot. The colour of each sequence point is the same as the
80 sequence group colours, white if no colour has been defined for the
81 sequence, and grey if the sequence is part of the currently selected
82 group. The viewer also employs depth cueing, so points appear darker
83 the farther away they are, and become brighter as they are rotated
84 towards the front of the view.</p>
86 The 3d view can be rotated by dragging the mouse with the <strong>left
87 mouse button</strong> pressed, or with the <strong>arrow
88 keys</strong> when <strong>SHIFT</strong> is pressed. The
89 view can also be zoomed in and out with
90 the up and down <strong>arrow keys</strong> (and the roll bar of the
91 mouse if present). Labels will be shown for each sequence if the
92 entry in the View menu is checked, and the plot background colour
93 changed from the View→Background Colour.. dialog box. The File
94 menu allows the view to be saved (<strong>File→Save</strong>
95 submenu) as an EPS or PNG image or printed, and the original
96 alignment data and matrix resulting from its PCA analysis to be
97 retrieved. The coordinates for the whole PCA space, or just the
98 current view may also be exported as CSV files for visualization in
99 another program or further analysis.
101 <p>Options for coordinates export are:</p>
103 <li>Output Values - complete dump of analysis (TxT* matrix
104 computed from sum of scores for all pairs of aligned residues from
105 from i->j and j->i, conditioned matrix to be diagonalised,
106 tridiagonal form, major eigenvalues found)</li>
107 <li>Output Points - The eigenvector matrix - rows correspond to
108 sequences, columns correspond to each dimension in the PCA</li>
109 <li>Transformed Points - The 3D coordinates for each sequence
110 as shown in the PCA plot</li>
114 A tool tip gives the sequence ID corresponding to a point in the
115 space, and clicking a point toggles the selection of the
116 corresponding sequence in the associated alignment window views.
117 <!-- Rectangular region
118 based selection is also possible, by holding the 'S' key whilst
119 left-clicking and dragging the mouse over the display. -->
120 By default, points are only associated with the alignment view from
121 which the PCA was calculated, but this may be changed via the <strong>View→Associate
122 Nodes</strong> sub-menu.
125 Initially, the display shows the first three components of the
126 similarity space, but any eigenvector can be used by changing the
127 selected dimension for the x, y, or z axis through each one's menu
128 located below the 3d display. The <strong><em>Reset</em></strong>
129 button will reset axis and rotation settings to their defaults.
133 <em>The output of points and transformed point coordinates was
134 added to the Jalview desktop in v2.7.</em> <em>The Reset button
135 and Change Parameters menu were added in Jalview 2.8.</em> <em>Support
136 for PAM250 based PCA was added in Jalview 2.8.1.</em><em>In Jalview 2.11, support for saving and restoring PCAs in Project files was added, and the Change parameters menu removed.</em>
139 <strong>Reproducing PCA calculations performed with older
140 Jalview releases</strong> Jalview 2.10.2 included a revised PCA
141 implementation which treated Gaps and non-standard residues in the
142 same way as a matrix produced with the method described in the paper
143 by G. Casari, C. Sander and A. Valencia. Structural Biology volume
144 2, no. 2, February 1995 (<a
145 href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=7749921">pubmed</a>)
146 and implemented at the SeqSpace server at the EBI. To reproduce
147 calculations performed with earlier Jalview releases it is necessary
148 to execute the following Groovy script:
150 jalview.analysis.scoremodels.ScoreMatrix.scoreGapAsAny=true
151 jalview.analysis.scoremodels.ScoreModels.instance.BLOSUM62.@matrix[4][1]=3
153 This script enables the legacy PCA mode where gaps were treated as
154 'X', and to modify the BLOSUM62 matrix so it is asymmetric for
155 mutations between C to R (this was a typo in the original Jalview
156 BLOSUM62 matrix which was fixed in 2.10.2).