poissonPca: Principal Component Analysis on Poisson data

View source: R/poisson_pca.R

poissonPcaR Documentation

Principal Component Analysis on Poisson data

Description

Principal Component Analysis on Poisson data

Usage

poissonPca(y, k = 50, transform = NULL, center = FALSE, scale = FALSE)

Arguments

y

Sparse matrix (can be a matrix, dgCMatrix, or SparseMatrix)

k

Number of principal components to return (Default: 50)

transform

CountTransform object or character(1) specifying a transformation to apply to y before PCA. Arguments center and scale are only applied when transform is a character string for a non-residual transformation. Accepted strings are: "pearson" for Pearson residuals, "deviance" for deviance residuals, "id" (or NULL) for the identity function, "log1p" for log(x + 1), "cpm_log1p" for log(x/1e6 + 1), and "med_log1p" for log(x/median(colSums(y)) + 1).

center

Whether transformed data should be shifted to have mean zero. Can be specified either as a vector of two logical values, specifying whether the rows/columns should be centered, respectively, or a single logical value specifying whether the columns should be centered (for consistency with prcomp()).

scale

Whether transformed rows should be scaled to have unit variance

Value

List with components:

  • sdevStandard deviations of principal components

  • rotationMatrix of variable loadings (i.e., matrix containing the eigenvectors of the covariance/correlation matrix as columns)

  • xMatrix of rotated data (rotated after applying the transformations specified)

Examples

data(tenx_subset)
dim(tenx_subset)
system.time({
    pc <- poissonPca(tenx_subset, k = 10, transform = "pearson")
})
plot(pc$x[, 1:2])
barplot(pc$sdev)

rafalab/smallcount documentation built on June 1, 2025, 2:10 p.m.