
Principal Component Analysis (PCA)
gly_pca.RdPerform principal component analysis on the expression data.
The function uses prcomp() to perform PCA and broom::tidy() to tidy the results.
If scale = TRUE, constant variables (zero variance) will be removed before PCA.
Arguments
- exp
A
glyexp::GlycomicSE()orglyexp::GlycoproteomicSE()object, or anotherSummarizedExperimentcontaining an expression matrix and sample information.- center
A logical indicating whether to center the data. Default is TRUE.
- scale
A logical indicating whether to scale the data. Default is TRUE.
- add_info
A logical value. If TRUE (default), sample and variable information from the experiment will be added to the result tibbles. If FALSE, only the PCA results are returned.
- ...
Additional arguments passed to
prcomp().
Value
A list containing:
tidy_result: A list of tibbles with PCA results:samples: PCA scores for each sample containing the following columns:sample: Sample namePC: Principal component name (PC1, PC2, etc.)value: Score value for the principal component
variables: PCA loadings for each variable containing the following columns:variable: Variable namePC: Principal component name (PC1, PC2, etc.)value: Loading value for the principal component
eigenvalues: PCA eigenvalues containing the following columns:PC: Principal component name (PC1, PC2, etc.)std.dev: Standard deviationpercent: Percentage of variance explainedcumulative: Cumulative percentage of variance explained
raw_result: The raw prcomp object fromstats::prcomp()meta_data: A list containing metadata from the input experiment
Details
The function performs log transformation on the expression data (log(x + 1)) before PCA analysis.
Required packages
This function only uses base R packages and does not require additional dependencies.