View source: R/pca_cor_samplevar.R
h_pca_var_rsquared | R Documentation |
This helper function calculates R2 values between one sample variable from AnyHermesData
and all Principal Components (PCs) separately (one linear model is fit for each PC).
h_pca_var_rsquared(pca, x)
pca |
( |
x |
( |
Note that in case there are estimation problems for any of the PCs, then NA
will
be returned for those.
A vector with R2 values for each principal component.
object <- hermes_data %>%
add_quality_flags() %>%
filter() %>%
normalize()
# Obtain the principal components.
pca <- calc_pca(object)$x
# Obtain the sample variable.
x <- colData(object)$AGE18
# Correlate them.
r2 <- h_pca_var_rsquared(pca, x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.