pcRegression: pcRegression

View source: R/pcRegression.R

pcRegressionR Documentation

pcRegression

Description

pcRegression does a linear model fit of principal components and a batch (categorical) variable

Usage

pcRegression(pca.data, batch, n_top = 50, tol = 1e-16)

Arguments

pca.data

a list as created by 'prcomp', pcRegression needs

  • x - the principal components (PCs, correctly: the rotated data) and

  • sdev - the standard deviations of the PCs)

batch

vector with the batch covariate (for each cell)

n_top

the number of PCs to consider at maximum

tol

truncation threshold for significance level, default: 1e-16

Value

List summarising principal component regression

  • maxVar - the variance explained by principal component(s) that correlate(s) most with the batch effect

  • PmaxVar - p-value (returned by linear model) for the respective principal components (related to maxVar)

  • pcNfrac - fraction of significant PCs among the n_top PCs

  • pcRegscale - 'scaled PC regression', i.e. total variance of PCs which correlate significantly with batch covariate (FDR<0.05) scaled by the total variance of n_top PCs

  • maxCorr - maximal correlation of n_top PCs with batch covariate

  • maxR2 - maximal coefficient of determination of n_top PCs with batch covariate

  • msigPC - scaled index of the smallest PC that correlates significantly with batch covariate (FDR<0.05), i.e. msigPC=1 if PC_1 is significantly correlated with the batch covariate and msigPC=0 if none of the n_top PCs is significantly correlated

  • maxsigPC - similar to msigPC, scaled index of the PC with maximal correlation of n_top PCs with batch covariate

  • R2Var - sum over Var(PC_i)*r2(PC_i and batch) for all i

  • ExplainedVar - explained variance for each PC

  • r2 - detailed results of correlation (R-Square) analysis

Examples

    testdata <- create_testset_multibatch(n.genes=1000, n.batch=3, plattform='any')
    pca.data <- prcomp(testdata$data, center=TRUE)
    pc.reg.result <- pcRegression(pca.data, testdata$batch)

theislab/kBET documentation built on Jan. 27, 2024, 9:58 p.m.