Description Usage Arguments Details Value Examples
Calculate BC t-SNE by orthogonal gradient descent
1 | bctsne(X, Z, k = 50, outDim = 2, perplexity = 30, maxIter = 1000)
|
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 |
X
should be preprocessed (e.g. PCA, centered and scaled). Z
is the full model matrix, excluding the intercept.
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
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.