Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 22

Eigenvectors and Principal Components

Recommended resources

Introduction

In our previous lesson, we established a crucial foundation by learning how to construct and interpret a covariance matrix from a dataset. We saw that this matrix, , is a compact summary of our data's structure: its diagonal entries represent the variance of individual features, and its off-diagonal entries describe how pairs of features vary together. You also saw how this matrix can be computed efficiently using the formula for a centered data matrix .

This lesson will bridge the gap between the statistical concept of covariance and the geometric goal of dimensionality reduction. We will explore how the eigenvectors of the covariance matrix reveal the "principal axes" of your data—the natural directions along which your data points spread the most. By the end of this lesson, you will be able to explain precisely why finding the eigenvectors of is the key to identifying these axes of maximum variance, which is the heart of Principal Component Analysis (PCA).


The Geometric Goal: Finding Axes of Maximum Variance

Imagine your data as a cloud of points in a high-dimensional space. For your cancer research project, this could be thousands of gene expression levels for each patient sample. Most of these genes are likely correlated, causing the data cloud to be shaped like a tilted and elongated ellipsoid rather than a uniform sphere.

Dimensionality reduction with PCA is fundamentally about finding a new, more informative coordinate system for this data cloud. Instead of using the original gene axes, we want to find axes that align with the data's natural shape.

  • The first principal axis should be the line that goes through the longest part of the cloud. If you were to project all your data points onto this single line, the resulting points would be as spread out as possible, preserving the maximum amount of the original variance.
  • The second principal axis would be the line, orthogonal to the first, that captures the most of the remaining variance.
  • This continues for all subsequent axes.

These "principal axes" are the directions that tell the most interesting story about your data's variation.

A scatter plot of centered data points. The red and green arrows represent the two principal axes of the data. Notice how the red arrow, Eigenvector 1, aligns with the direction of the greatest spread in the data cloud. The green arrow, Eigenvector 2, is orthogonal to the first and captures the remaining variance.

The image above gives a perfect visual summary. The red arrow points in the direction that best captures the data's primary trend. But how do we find this direction mathematically? The answer, perhaps surprisingly, lies in the eigenvectors of the covariance matrix.


The Mathematical Solution: Eigenvectors as Principal Axes

The core insight of PCA is that the eigenvectors of the covariance matrix are precisely these principal axes of variance. Let's build the intuition for why this is true.

In the last module, you learned that an eigenvector of a matrix is a special vector that, when transformed by , does not change its direction, only its length. The transformation is . Here, our matrix is the covariance matrix .

The problem of finding the first principal axis is equivalent to finding the unit vector that maximizes the variance of the data when projected onto it. The variance of the data projected onto a direction is given by the quadratic form . So, our goal is to maximize this quantity.

A key result from linear algebra, which you can explore in the reading below, states that the vector that maximizes (subject to being a unit vector) is the eigenvector of corresponding to the largest eigenvalue.

[PDF] A geometric interpretation of the covariance matrix

This document provides an excellent, intuitive explanation connecting the geometric shape of data to the algebraic properties of its covariance matrix.

Please read the section titled Eigendecomposition of a covariance matrix. Focus on the core argument: the problem of finding the direction of largest variance is mathematically identical to finding the principal eigenvector of the covariance matrix. The text states it clearly: "the largest eigenvector of the covariance matrix always points into the direction of the largest variance of the data".

This is the central connection for today's lesson:

  • The Problem: Find the direction (axis) of maximum variance in the data.
  • The Solution: This direction is given by the eigenvector of the data's covariance matrix that has the largest corresponding eigenvalue.

The other eigenvectors provide the other principal axes, in decreasing order of the variance they capture. Because the covariance matrix is symmetric, its eigenvectors are always orthogonal, giving us a nice, perpendicular set of new axes for our data.


A Step-by-Step Walkthrough

Let's solidify this connection by watching a detailed walkthrough. The following video by Luis Serrano explains the entire PCA process, but we will focus on the specific segments that link the covariance matrix to its eigenvectors.

Principal Component Analysis (PCA)

This video provides one of the clearest visual explanations of PCA. Pay close attention to how he treats the covariance matrix as a linear transformation and how its eigenvectors emerge as the principal directions of that transformation.

Please watch the following segments: The Covariance Matrix: This is a quick recap of the last lesson. Notice how he assembles the 2x2 matrix from the variances and covariances of the centered data. Eigenvectors and Eigenvalues: This is the most crucial part for us. He interprets the covariance matrix as a linear transformation that stretches a circle into an ellipse. The eigenvectors are the axes of this ellipse—the directions of pure stretch. This is a powerful geometric analogy for the principal axes. The PCA Connection: Here, he explicitly makes the connection. The eigenvectors of the covariance matrix give us the directions of the principal components (the red and green vectors). He also notes that because covariance matrices are symmetric, the eigenvectors are always orthogonal (perpendicular), which is a vital and convenient property.

As the video demonstrates, the eigenvectors of aren't just an abstract mathematical concept; they have a tangible, geometric meaning. They are the axes of the ellipsoid that best fits your data cloud, and therefore, they are the principal axes of variance.


Application: Interpreting Principal Components in Bioinformatics

This concept is not merely theoretical; it's a cornerstone of modern data analysis, especially in computational biology. When you run PCA on a gene expression dataset, you are performing an eigendecomposition of its covariance matrix. The resulting principal components are new, composite features, and the eigenvectors tell you exactly how they are constructed from the original genes.

The following article, written from a bioinformatics perspective, discusses how to interpret the results of PCA.

Exploring Principal Component Analysis (PCA)

This article frames PCA within the context of biological data analysis, which should resonate with your work.

First, read the section How Weights Are Decided to reinforce that the eigenvectors are mathematically derived from the data's covariance structure. Next, focus on the section that explains how to interpret a PCA biplot, specifically the part about the loading vectors: Interpreting the Biplot. The "loadings" shown as arrows in a biplot are simply the eigenvectors. Each value in an eigenvector corresponds to an original variable (a gene, in your case) and represents its contribution or "weight" in that principal component. A large positive or negative value means that gene is important for defining that principal axis.

By examining the eigenvectors (the loadings), you can move from a simple dimensionality reduction plot to a biological interpretation. If the first principal component (the first eigenvector) effectively separates your ALL and AML samples, you can look at the largest values in that eigenvector to identify which genes are the primary drivers of that separation. In this way, the eigenvectors of the covariance matrix become a guide to the underlying biology.

The PCA process. We've now connected Step 3 (compute covariance matrix) to Step 4 (compute eigenvectors). The eigenvectors define the principal axes we will use for projection in Step 6.

Conclusion

In this lesson, we have forged a critical link between statistics and linear algebra to understand the core of PCA.

Key Takeaways:

  • The principal axes of variance are the directions in your data that capture the most information about how the data points are spread.
  • These axes correspond directly to the eigenvectors of the covariance matrix.
  • The first principal axis is the eigenvector associated with the largest eigenvalue, as it represents the direction of maximum variance. Subsequent eigenvectors represent directions of successively smaller variance, and they are all orthogonal to each other.
  • In applied contexts like bioinformatics, these eigenvectors (often called "loadings") provide a recipe, showing how the original features (e.g., genes) are weighted to create the new principal component axes.

You now understand why eigendecomposition is the engine of PCA. In the next lesson, we will turn our attention to the other half of the puzzle: the eigenvalues. While the eigenvectors give us the direction of the principal axes, the eigenvalues will tell us the magnitude—exactly how much variance is captured by each one.