# Principal component analysis by several decomposition

4 messages
Open this post in threaded view
|

## Principal component analysis by several decomposition

 Hello,    I am coping with PCA obtained after several matrix decomposition of a data matrix containing biological information (for sake of completeness, matrix of metabolites and samples). I have a few of doubts about the procedure and results, then I will be greatfull to everyone who will address some (or all) of my issues. 1. Be X a m x n data matrix (n are variables/metabolites, m observables/samples), n is much greater than m; 2. I applied a scaling by Xm=zscore(X); 3. performed svd by [U S W]=svd(Xm); Assuming that W contains the principal components (PCs) of Xm (is it right, or I have to compute W'*Xm' to get them?), I can plot PCs one by one for each sample obtaining a biplot; now, how can I get the coefficients associated to each variables for each PCs? In addition, it seems that a more ready procedure is to compute pca by "princomp": [coeff,score,latent]=princomp(Xm) and in that case the coefficients are within the "coeff" matrix, but where are the PCs stored? Are they in "score"? Again, by computing PCs by eigenval decomposition: [V,D]=eig(cov(Xm)); I will get the reconstructed V'*Xm' matrix which contains the PCs, but where are the coefficients? Thank you in advance -- Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Open this post in threaded view
|

## Re: Principal component analysis by several decomposition

 onewayenzyme wrote > Hello, >    I am coping with PCA obtained after several matrix decomposition of a > data matrix containing biological information (for sake of completeness, > matrix of metabolites and samples). I have a few of doubts about the > procedure and results, then I will be greatfull to everyone who will > address > some (or all) of my issues. > > 1. Be X a m x n data matrix (n are variables/metabolites, m > observables/samples), n is much greater than m; > 2. I applied a scaling by Xm=zscore(X); > 3. performed svd by [U S W]=svd(Xm); > > Assuming that W contains the principal components (PCs) of Xm (is it > right, > or I have to compute W'*Xm' to get them?), I can plot PCs one by one for > each sample obtaining a biplot; now, how can I get the coefficients > associated to each variables for each PCs? > > In addition, it seems that a more ready procedure is to compute pca by > "princomp": > > [coeff,score,latent]=princomp(Xm) > > and in that case the coefficients are within the "coeff" matrix, but where > are the PCs stored? Are they in "score"? > > Again, by computing PCs by eigenval decomposition: > > [V,D]=eig(cov(Xm)); > > I will get the reconstructed V'*Xm' matrix which contains the PCs, but > where > are the coefficients? > > > > Thank you in advance > > > > > -- > Sent from: > https://octave.1599824.n4.nabble.com/Octave-General-f1599825.htmlHave a look at the source of  pcacov will most likely help you to answer your questions. Look for the file pcacov.m on your disk, it is part of the statistics package function [COEFF, latent, explained] = pcacov(X)   [U,S,V] = svd(X);   if nargout == 1     COEFF     = U;   elseif nargout == 2     COEFF     = U;     latent    = diag(S);   else     COEFF     = U;     latent    = diag(S);     explained = 100*latent./sum(latent);   end endfunction -- Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html