pca2tsne {MOSS}R Documentation

Mapping principal components onto a 2D map via tSNE.

Description

This function is called by moss whenever 'moss(tSNE=TRUE)' to project latent factors onto two dimensions via t-stochastic neighbor embedding (tSNE) However, it can be used on any generic data matrix. The function uses the Barnes-Hut tSNE algorithm from Rtsne package, and uses an iterative procedure to select a tSNE map minimizing the projection cost across several random initial conditions. The function is inspired by the iterative procedure discussed in Taskesen et al. 2016 and code originally provided with the publication.

Usage

pca2tsne(Z, perp = 50, n.samples = 1, n.iter = 1000, parallel = FALSE)

Arguments

Z

A matrix with axes of variation (typically PCs) as columns and subjects as rows.

perp

Perplexity value. Defaults to 50.

n.samples

Number of times the algorithm starts from different random initial conditions. Defaults to 1.

n.iter

Number of iterations for each run of the algorithm.

parallel

Should random starts be done in parallel? Logical. Default to FALSE. Defaults to 1000.

Value

Returns output of function 'Rtsne::Rtsne' from the random initial condition with the smallest 'reconstruction error'.

References

Examples


library("MOSS")
sim_blocks <- simulate_data()$sim_blocks

# Example of pca2tsne usage.
Z <- pca2tsne(sim_blocks$`Block 3`, 
              perp = 50, 
              n.samples = 1,
              n.iter = 1e3)$Y
plot(Z, xlab = "x_tSNE(X)", ylab = "y_tSNE(X)")

# Example of usage within moss.
set.seed(34)
moss(sim_blocks[-4],
  tSNE = list(
    perp = 50,
    n.samples = 1,
    n.iter = 1e3
  ),
  plot = TRUE
)$tSNE_plot


[Package MOSS version 0.2.2 Index]