Description Usage Arguments Value Examples
Computation can be done using the recipes package
(robust = FALSE
, uses regular PCA) or with the rrcov
package which uses rrcov::PcaGrid()
, a robust PCA computation with built-in
outlier identification.
1 2 3 4 5 6 7 8 |
df |
A data frame. |
num_comp |
A positive integer. The number of PCA components to compute. |
subset |
A character vector. The subset of columns to use for PCA
calculation. Default is all columns. Columns in |
normalize |
A flag. Center and scale before PCA calculation? |
robust |
A flag. Use robust PCA (from |
crit_pca_distances |
A number between 0 and 1. Outlier identification
parameter. See |
A data frame with the principal components with attributes
var_exp
: A numeric vector. The variance explained by each component.
loadings
: A data frame. The contribution of each variable to each
principal component.
outlier
: A logical vector with length nrow(df)
. TRUE
for outlier,
FALSE
otherwise. This is present with robust = TRUE
only.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | if (rlang::is_installed("mirmisc")) {
ga_data <- get_ga_data(
log2 = TRUE,
gene_predicate = ~ median(.) > 0
)
pca_reg <- compute_pcas(ga_data,
subset = intersect(
mirmisc::get_gene_names(),
names(ga_data)
),
robust = FALSE
)
pca_rob <- compute_pcas(ga_data,
subset = intersect(
mirmisc::get_gene_names(),
names(ga_data)
),
robust = TRUE
)
ggplot2::ggplot(
pca_reg,
ggplot2::aes(PC1, PC2, color = meta_collectionga)
) +
ggplot2::geom_point() +
ggplot2::scale_color_viridis_c() +
ggplot2::ggtitle("GAPPS regular")
ggplot2::ggplot(
pca_rob,
ggplot2::aes(PC1, PC2, color = meta_collectionga)
) +
ggplot2::geom_point() +
ggplot2::scale_color_viridis_c() +
ggplot2::ggtitle("GAPPS robust")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.