
Apply contrastive PCA.
contrastive_pca.RdApplies the contrastive PCA algorithm given a specified alpha and a number of contrastive principal components to extract.
Arguments
- object
The underlying class, see
BulkCoExp().- alpha
Alpha parameter to use.
- no_pcs
Number of contrastive PCs to generate.
Examples
# five contrastive PCs at alpha 2.5
cpca_data <- synthetic_c_pca_data()
target <- t(cpca_data$target)
background <- t(cpca_data$background)
meta <- data.table::data.table(sample_id = rownames(target))
obj <- BulkCoExp(target, meta)
obj <- preprocess_bulk_coexp(obj, .verbose = FALSE)
obj <- contrastive_pca_processing(obj, background, .verbose = FALSE)
obj <- contrastive_pca(obj, alpha = 2.5, no_pcs = 5L)
dim(get_c_pca_factors(obj))
#> [1] 400 5