How can I create a eigencorplot of pca created from deseq2 object with PCAtools
0
0
Entering edit mode
BioinfGuru ▴ 70
@yagalbi-11519
Last seen 3 months ago
Ireland

Hi,

I asked this over on biostars with no reply - a bit too technical and more appropriate here I think.

I am working through the PCAtools readme. Two data sets are used to demonstrate the package, the first pca created takes a deseq2 object (DESeq2 data), and the second does not (GEO data).

The eigencorplot() function is introduced on the GEO data, and I am trying to figure out how to use it on the DESeq2 data. Can anyone explain why I can't get it to work, and offer a solution?

It is clear the problem is associated with my use of the 'metavars' argument which is "A vector of column names in metadata representing continuous variables". Clearly in both datasets some of the columns are not continuous, but for the GEO data set it works (coercion I think), while the DESeq2 data set it doesn't.

Thanks, Kenneth

# Compute PCA
pGEO <- pca(mat, metadata = metadata, removeVar = 0.1) # GEO
pDESEQ <- pca(vst, metadata = colData(airway), removeVar = 0.1) # DESeq2

# View available metadata columns in pca object
colnames(pGEO$metadata) # prints: Study, Age, Distant.RFS, ER, GGI, Grade, Size, Time.RFS
colnames(pDESEQ$metadata) # prints: SampleName, cell, dex, albut, Run, avgLength, Experiment, Sample, BioSample

# Eigencorplot
eigencorplot(pGEO, metavars = c('Study','Age','Distant.RFS','ER', 'GGI','Grade','Size','Time.RFS')) # successful
eigencorplot(pDESEQ, metavars = c('SampleName', 'cell', 'dex', 'albut', 'Run', 'avgLength', 'Experiment', 'Sample', 'BioSample')) # error

# Error
Error in `[.data.frame`(data, , components[i]) : 
  undefined columns selected
DESeq2 eigencorplot PCAtools • 655 views
ADD COMMENT
1
Entering edit mode

try traceback()

that may help the developer figure out what's going on.

Or you can make a reproducible example, with makeExampleDESeqDataSet()

ADD REPLY
0
Entering edit mode

Figured it out with ?eigencorplot, thanks Michael. I was trying to pass 10 PCs when I only had 8, and I was including metadata columns that were not part of the design.

eigencorplot(pDESEQ,
         components = getComponents(pcaobj = pDESEQ, seq_len(8)), # default 10 --> error
         metavars = c('cell', 'dex')) # the 'design' variables
ADD REPLY

Login before adding your answer.

Traffic: 464 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