Selects the ntop genes with the highest variance after transformation and
runs stats::prcomp() with samples as observations, centering on, and no
scaling.
Usage
compute_pca(
study,
transform = c("vst", "log2-tpm"),
ntop = 500L,
components = 10L
)Value
A list containing scores, loadings, and variance data
frames, plus the transform and the number of genes used (ntop).
Examples
# \donttest{
ex <- system.file("extdata", "example", package = "rsemflow")
study <- read_rsem_study(file.path(ex, "data"), file.path(ex, "metadata.tsv"))
p <- compute_pca(study, ntop = 100, components = 3)
#> Warning: replacing previous import ‘S4Arrays::makeNindexFromArrayViewport’ by ‘DelayedArray::makeNindexFromArrayViewport’ when loading ‘SummarizedExperiment’
p$variance
#> component eigenvalue variance_fraction cumulative_variance
#> 1 PC1 1.949986e+02 6.454382e-01 0.6454382
#> 2 PC2 4.978460e+01 1.647852e-01 0.8102234
#> 3 PC3 2.768292e+01 9.162944e-02 0.9018528
#> 4 PC4 1.652027e+01 5.468149e-02 0.9565343
#> 5 PC5 1.313179e+01 4.346572e-02 1.0000000
#> 6 PC6 1.740680e-29 5.761586e-32 1.0000000
# }