bctsne: Calculate BC t-SNE by orthogonal gradient descent In bcTSNE: Projected t-SNE for Batch Correction

Description

Calculate BC t-SNE by orthogonal gradient descent

Usage

 `1` ```bctsne(X, Z, k = 50, outDim = 2, perplexity = 30, maxIter = 1000) ```

Arguments

 `X` numeric matrix, input matrix `Z` numeric matrix, covariate matrix `k` integer of length 1, reduced dimension (number of eigenvectors) `outDim` integer of length 1, the output dimension `perplexity` numeric of length 1, the t-SNE perplexity `maxIter` integer of length 1, the maximum iterations for the BC t-SNE algorithm

Details

`X` should be preprocessed (e.g. PCA, centered and scaled). `Z` is the full model matrix, excluding the intercept.

Value

`list` wth the following items:

`Xred`

numeric matrix, the reduced dimension input to `bctsne`

`Z`

model matrix indicating batch membership

`perplexity`

perpelexity value used in computing t-SNE

`Y`

batch-corrected projection matrix

`maxIter`

maximum iterations used in training

Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24``` ```## Create small simulated dataset, A, with embeded batch effects set.seed(2731) kRid <- 20 p <- 100 n <- 200 W <- matrix(rnorm(p*kRid), kRid) S <- matrix(rnorm(n*kRid), n) z <- sample(1:3, rep = TRUE, size = n) Z <- model.matrix( ~ -1 + as.factor(z)) l <- matrix(rnorm(kRid*NCOL(Z)), kRid) A <- (S - Z %*% t(l) ) %*% W ## Scale A to give input, X X <- scale(A) resUnadj <- Rtsne::Rtsne(X) ## Standard t-SNE resAdj <- bctsne(X = X, Z = Z, k = 10) ## Batch-corrected t-SNE ## Plot results, no true effects were included in the simulated data, so ## we expect all batches to overlap with bcTSNE; batch membership indicated ## by color plot(resUnadj\$Y, col = z) plot(resAdj\$Y, col = z) ```

bcTSNE documentation built on Dec. 11, 2021, 9:57 a.m.