Why the PCA results of PCASamples() from methylkit is different from prcomp()?
1
0
Entering edit mode
4.9 years ago
maria2019 ▴ 250

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 • 2.5k views
ADD COMMENT
2
Entering edit mode
4.9 years ago
maria2019 ▴ 250

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

pca <- PCASamples(meth, obj.return=TRUE,transpose=FALSE) 
pca
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

percMethylation look for this function

ADD REPLY

Login before adding your answer.

Traffic: 2217 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6