Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotPCA variance explained disagree with prcomp and factoextra pacakge #383

Closed
NikoLichi opened this issue Jul 25, 2023 · 1 comment
Closed

Comments

@NikoLichi
Copy link

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

@cying111
Copy link
Collaborator

Hi @NikoLichi , thank you for pointing out this bug. We will correct the code for the next update!

Regards,
Ying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants