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

"Proportion of variance explained" values on reduce_dimensions() output #253

Closed
canholyavkin opened this issue Jul 25, 2022 · 1 comment · Fixed by #255
Closed

"Proportion of variance explained" values on reduce_dimensions() output #253

canholyavkin opened this issue Jul 25, 2022 · 1 comment · Fixed by #255

Comments

@canholyavkin
Copy link

The base prcomp() function provides the Proportion of variance explained values after the PCA analysis.

pca <- prcomp(USArrests, scale = TRUE)
summary(pca)
#Importance of components:
#                          PC1    PC2     PC3     PC4
#Standard deviation     1.5749 0.9949 0.59713 0.41645
#Proportion of Variance 0.6201 0.2474 0.08914 0.04336
#Cumulative Proportion  0.6201 0.8675 0.95664 1.00000

As you know, those values are pretty important in evaluating the variability in eigenvectors. However, I couldn't find those values on the reduce_dimensions() output. Is it possible to obtain those values with tidybulk?

@stemangiola
Copy link
Owner

stemangiola commented Jul 26, 2022

Yes the message on how to get them wasn't showing.

Now

se = se |> reduce_dimensions(method="PCA")
No group or design set. Assuming all samples belong to one group.
Getting the 23 most variable genes
Fraction of variance explained by the selected principal components
# A tibble: 2 × 2
  `Fraction of variance`    PC
                   <dbl> <int>
1                  0.599     1
2                  0.188     2
tidybulk says: to access the raw results do `attr(..., "internals")$PCA`

And recover the pca object as such

attr(se, "internals")$PCA

Pull request below, please check branch to see if has solved your problem.

@stemangiola stemangiola linked a pull request Jul 26, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants