Skip to content

plotPCA variance explained disagree with prcomp and factoextra pacakge #383

@NikoLichi

Description

@NikoLichi

Hi there,

I am exploring this great tool! with my long-read data set.

When looking to get a more customized PCA plot, I encountered a calculation on the variance explained in BAMBU which differs from other results in different packages.

The way that the variance for PC1 and PC2 is calculated in BAMBU uses the output from prcomp command, taking into account the standard deviation like:
round(pcs$sdev[1]/sum(pcs$sdev) * 100, 1)
In my case, I got a PC1= 8.1% and PC2 = 6.9% with BAMBU.

However, using the fviz_eig() function in the library(factoextra) which gives the contribution this number goes to 13% for PC1 and 10% for PC2 (please see attached figure).
Screenshot 2023-07-25 at 15 27 24
This is also consistent with the output of summary (prcomp).

I am not a principal component expert, but I would like to understand why the calculation to obtain the variance in the PCA plot was calculated in this way. And maybe, if it is needed adjust the BAMBU code for reproducibility purposes.

All the best,
Niko

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions