This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Why the PCA results of PCASamples() from methylkit is different from prcomp()?

I have the 'meth' object for my samples and I wanted to see more PCAs. I realized that PCs from PCASamples are different from what I calculate:

Using PCASamples():

library(methylKit)
meth <-readRDS(file="~/files/meth.rds")
pca <- PCASamples(meth, obj.return=TRUE)
pca$x
         PC1         PC2         PC3          PC4         PC5        PC6
sample1    54.7917242   78.835727 -146.389741  -88.0073775 -129.179034  -48.83519
sample2   45.8439749   79.986099 -132.748956 -115.7681777 -182.780012  -18.20983
sample3  -35.5084338  359.737490 -139.675979  340.2946409  178.827413  -49.74668
sample4    -0.8435795  169.940509  -87.345883   84.1664145   56.099736  -58.92960
  

Using prcomp():

library(methylKit)
meth <-readRDS(file="~/files/meth.rds")
mat=percMethylation(meth)
pca <- prcomp(mat)  
pca
             PC1           PC2         PC3           PC4         PC5
Sample1  -0.2238237  0.0888081766 -0.27426209  2.240539e-01 -0.128535081
Sample2  -0.2242289  0.0725052576 -0.26868740  2.560139e-01 -0.140892847
Sample3  -0.2227445 -0.0067194119 -0.45275679 -3.366611e-01  0.203404391
Sample4  -0.2230264  0.0068922158 -0.34130776 -2.185143e-01  0.139594741
  
methylkit prcomp pca pcasamples multiplepca

1 answer

I just realized that transpose=FALSE in PCASamples gives the same results as prcomp.

pca <- PCASamples(meth, obj.return=TRUE,transpose=FALSE) 
pca

Hi guys - coming late to this, but does anyone know what variables the PCA is using from the meth object?

If you open the meth object it looks there are 34 columns and it is not your usual column 1 samples name and the other columns are variables,

chr start end strand coverage1 numCs1 numTs1 coverage2 numCs2 numTs2 coverage3 numCs3 numTs3 coverage4 numCs4 numTs4 coverage5 numCs5 numTs5 coverage6 numCs6 numTs6 coverage7 numCs7 numTs7 coverage8 numCs8 numTs8 coverage9 numCs9 numTs9 coverage10 numCs10 numTs10

percMethylation look for this function

Log in to answer this question.