Exploratory multi-omics analysis and principal components

Practical 19: Genomics, systems biology and multi-omics

Learning objectives

Orient matrices correctly; compare covariance and standardized PCA; inspect variance explained and sample patterns; distinguish exploration from inference.

Biological question and data

Which sample patterns appear in the hypothetical protein and metabolite panels?

Animals are rows in the PCA inputs; molecular features are columns. Both panels are supplied log2 values and contain shared latent variation by construction. Standardization is used for description, not prediction.

No biological download is required. Numerical inputs are hypothetical, not observed animal data. The runnable examples use base R. Count and abundance units are specified where used.

1. Prepare matched feature matrices

Use complete measurements and explicit animal alignment.

Show R code
helper_dir <- if (dir.exists("R")) "R" else "../R"
stopifnot(file.exists(file.path(helper_dir,"teaching_data.R")))
source(file.path(helper_dir,"teaching_data.R"))
d <- teaching_data()
P <- t(d$protein);M <- t(d$metabolite)
stopifnot(identical(rownames(P),rownames(M)))
X <- cbind(P,M)
fit <- prcomp(X,center=TRUE,scale.=TRUE)
variance_fraction <- fit$sdev^2/sum(fit$sdev^2)
head(variance_fraction)
[1] 0.57849510 0.07719019 0.06658498 0.05267852 0.04811067 0.03908211
Show R code
stopifnot(abs(sum(variance_fraction)-1)<1e-12)

Unit-variance scaling makes different feature variances comparable for this representation. It also gives a noisy low-variance feature greater relative weight.

2. Plot scores with design labels

The same PCA scores can be labelled by diet, batch or farm to investigate alternative explanations.

Show R code
plot(fit$x[,1],fit$x[,2],pch=19,col=as.integer(d$metadata$diet),
 xlab="PC1 score",ylab="PC2 score",main="Standardized descriptive PCA")
legend("topleft",levels(d$metadata$diet),pch=19,col=1:2,bty="n")

Show R code
loadings <- fit$rotation[,1]
head(sort(abs(loadings),decreasing=TRUE))
protein08 protein07 feature06 feature05 protein03 protein06 
0.3224110 0.3203770 0.3060873 0.3017077 0.2920050 0.2894331 

Loadings describe feature contributions to a mathematical direction. A sign can flip without changing the PCA representation.

3. Demonstrate unit sensitivity

Multiply one feature by 100 and compare covariance PCA to standardized PCA.

Show R code
changed <- X;changed[,1] <- 100*changed[,1]
raw_pca <- prcomp(changed,center=TRUE,scale.=FALSE)
scaled_pca <- prcomp(changed,center=TRUE,scale.=TRUE)
c(covariance_PC1_fraction=raw_pca$sdev[1]^2/sum(raw_pca$sdev^2),
 standardized_PC1_fraction=scaled_pca$sdev[1]^2/sum(scaled_pca$sdev^2))
  covariance_PC1_fraction standardized_PC1_fraction 
                0.9961177                 0.5784951 
Show R code
stopifnot(max(abs(abs(cor(fit$x[,1],scaled_pca$x[,1]))-1))<1e-10)

Positive unit rescaling is cancelled by standardization, while covariance PCA can become dominated by the rescaled feature.

4. Check that PCA sign is arbitrary

A principal-component axis and its negative represent the same geometry. Flipping a score axis does not change distances or variance explained.

Show R code
set.seed(1902)
example_X <- matrix(rnorm(60),20,3)
example_pc <- prcomp(example_X)
score <- example_pc$x[,1:2]
flipped <- score;flipped[,1] <- -flipped[,1]
stopifnot(max(abs(as.matrix(dist(score))-as.matrix(dist(flipped))))<1e-12)

5. Interpret scores with loadings and design

Sample scores describe where observations lie; loadings describe which features contribute to an axis. A diet-associated axis can also reflect batch or a common driver. Colour by relevant metadata and inspect the retained feature set.

Variance explained is relative to the matrix and scaling analysed. It cannot be compared blindly between raw, standardized and differently filtered matrices. A high first-PC fraction can arise from redundant features, not necessarily a more coherent biological mechanism. Do not select exclusions solely to produce clearer clusters.

Interpretation challenge

A new software run reverses PC1 but shows the same sample geometry. Did the biological result reverse?

No. The sign of a component is arbitrary when scores and loadings are changed consistently. Interpret relative positions, loadings and the stated transformation.

Interpretation and limits

PCA is an exploratory linear representation, not an independent test of treatment or a causal network. For prediction, fit scaling and PCA on training animals and project test animals using those parameters. Select the interpretation after considering batch, biological covariates and sampling.

Exercises

  1. Why can a loading sign reverse?
  2. Does a visible diet cluster prove the intervention mechanism?
  3. Why is fitting PCA on train and test together inappropriate for an untouched prediction test?
  1. An eigenvector and its negative represent the same axis.
  2. No; design and other shared drivers must be examined.
  3. The representation incorporates information from the evaluation population.

Continue learning

B12 Statistics and B15 Integration.

Continue with regularized prediction or integration. Return to the practical index or the unified map.