scPCA {scPCA} | R Documentation |
Given target and background dataframes or matrices, scPCA
will perform the sparse contrastive principal component analysis (scPCA) of
the target data for a given number of eigenvectors, a vector of real valued
contrast parameters and a vector of penalty terms. For more information on
the contrastive PCA method, consult Abid A, Zhang MJ, Bagaria VK, Zou J (2018).
“Exploring patterns enriched in a dataset with contrastive principal
component analysis.”
Nature communications, 9(1), 2134..
Sparse PCA is performed via the method of Zou H, Hastie T, Tibshirani R (2006).
“Sparse principal component analysis.”
Journal of computational and graphical statistics, 15(2), 265–286..
scPCA(target, background, center = TRUE, scale = FALSE, n_eigen = 2, cv = NULL, contrasts = exp(seq(log(0.1), log(1000), length.out = 40)), penalties = seq(0.05, 1, length.out = 20), clust_method = c("kmeans", "pam"), n_centers, max_iter = 10, n_medoids = 8, parallel = FALSE)
target |
The target (experimental) data set, in a standard format such
as a |
background |
The background data set, in a standard format such as a
|
center |
A |
scale |
A |
n_eigen |
A |
cv |
A |
contrasts |
A |
penalties |
A |
clust_method |
A |
n_centers |
A |
max_iter |
A |
n_medoids |
A |
parallel |
A |
A list containing the following components:
rotation - the matrix of variable loadings
x - the rotated data, centred and scaled if requested, multiplied by the rotation matrix
contrast - the optimal contrastive parameter
penalty - the optimal L1 penalty term
center - whether the target dataset was centered
scale - whether the target dataset was scaled
# perform cPCA on the simulated data set scPCA( target = toy_df[, 1:30], background = background_df, contrasts = exp(seq(log(0.1), log(100), length.out = 5)), penalties = 0, n_centers = 4 ) # perform scPCA on the simulated data set scPCA( target = toy_df[, 1:30], background = background_df, contrasts = exp(seq(log(0.1), log(100), length.out = 5)), penalties = seq(0.1, 1, length.out = 3), n_centers = 4 ) # cPCA as implemented in Abid et al. scPCA( target = toy_df[, 1:30], background = background_df, contrasts = exp(seq(log(0.1), log(100), length.out = 10)), penalties = 0, n_centers = 1 )