I'm trying to create an eigencor plot of clinical variables against principle components using the PCAtools guidelines. https://www.bioconductor.org/packages/devel/bioc/vignettes/PCAtools/inst/doc/PCAtools.html#correlate-the-principal-components-back-to-the-clinical-data I want to first eliminate batch effects as the batches are really noticeable in PCA plots. This is the script I currently have:
> analysis_PCA <- vst(analysis_dds, blind=FALSE)
mat <- assay(analysis_PCA)
mm <- model.matrix(~DM, colData(analysis_PCA))
mat <- limma::removeBatchEffect(mat, batch=analysis_PCA$Batch, design=mm)
assay(analysis_PCA) <- mat
p <- pca(analysis_PCA, metadata = DASCondition, removeVar = 0.1)
eigencorplot(p,
components = getComponents(p, 1:10),
components = getComponents(p, 1:10),
metavars = c("BMI", "LFVEF"),
col = c('darkblue', 'blue2', 'black', 'red2', 'darkred'),
cexCorval = 0.7,
colCorval = 'white',
fontCorval = 2,
posLab = 'bottomleft',
rotLabX = 45,
posColKey = 'top',
cexLabColKey = 1.5,
scale = TRUE,
main = 'PC1-27 clinical correlations',
colFrame = 'white',
plotRsquared = FALSE)
This produced this error:
Error in t.default(mat) : argument is not a matrix
I know that the plot runs if I don't use the removeBatchEffect portion and if i use the removeBatchEffect and then plotPCA to generate PCA plots it works.