calculateTSNE {scater} | R Documentation |
Perform t-stochastic neighbour embedding (t-SNE) for the cells, based on the data in a SingleCellExperiment object.
calculateTSNE(x, ...) ## S4 method for signature 'ANY' calculateTSNE(x, ncomponents = 2, ntop = 500, subset_row = NULL, feature_set = NULL, scale = FALSE, scale_features = NULL, transposed = FALSE, perplexity = NULL, normalize = TRUE, theta = 0.5, ..., external_neighbors = FALSE, BNPARAM = KmknnParam(), BPPARAM = SerialParam()) ## S4 method for signature 'SummarizedExperiment' calculateTSNE(x, ..., exprs_values = "logcounts") ## S4 method for signature 'SingleCellExperiment' calculateTSNE(x, ..., pca = is.null(dimred), exprs_values = "logcounts", dimred = NULL, use_dimred = NULL, n_dimred = NULL) runTSNE(x, ..., altexp = NULL, name = "TSNE")
x |
For For |
... |
For the For |
ncomponents |
Numeric scalar indicating the number of t-SNE dimensions to obtain. |
ntop |
Numeric scalar specifying the number of features with the highest variances to use for PCA, see |
subset_row |
Vector specifying the subset of features to use for PCA, see |
feature_set |
Deprecated, same as |
scale |
Logical scalar, should the expression values be standardised? See |
scale_features |
Deprecated, same as |
transposed |
Logical scalar, is |
perplexity |
Numeric scalar defining the perplexity parameter, see |
normalize |
Logical scalar indicating if input values should be scaled for numerical precision, see |
theta |
Numeric scalar specifying the approximation accuracy of the Barnes-Hut algorithm, see |
external_neighbors |
Logical scalar indicating whether a nearest neighbors search should be computed externally with |
BNPARAM |
A BiocNeighborParam object specifying the neighbor search algorithm to use when |
BPPARAM |
A BiocParallelParam object specifying how the neighbor search should be parallelized when |
exprs_values |
Integer scalar or string indicating which assay of |
pca |
Logical scalar indicating whether a PCA step should be performed inside |
dimred |
String or integer scalar specifying the existing dimensionality reduction results to use, see |
use_dimred |
Deprecated, same as |
n_dimred |
Integer scalar or vector specifying the dimensions to use if |
altexp |
String or integer scalar specifying an alternative experiment to use to compute the PCA, see |
name |
String specifying the name to be used to store the result in the |
The function Rtsne
is used internally to compute the t-SNE.
Note that the algorithm is not deterministic, so different runs of the function will produce differing results.
Users are advised to test multiple random seeds, and then use set.seed
to set a random seed for replicable results.
The value of the perplexity
parameter can have a large effect on the results.
By default, the function will set a “reasonable” perplexity that scales with the number of cells in x
.
(Specifically, it is the number of cells divided by 5, capped at a maximum of 50.)
However, it is often worthwhile to manually try multiple values to ensure that the conclusions are robust.
If external_neighbors=TRUE
, the nearest neighbor search step will use a different algorithm to that in the Rtsne
function.
This can be parallelized or approximate to achieve greater speed for large data sets.
The neighbor search results are then used for t-SNE via the Rtsne_neighbors
function.
If dimred
is specified, the PCA step of the Rtsne
function is automatically turned off by default.
This presumes that the existing dimensionality reduction is sufficient such that an additional PCA is not required.
For calculateTSNE
, a numeric matrix is returned containing the t-SNE coordinates for each cell (row) and dimension (column).
For runTSNE
, a modified x
is returned that contains the t-SNE coordinates in reducedDim(x, name)
.
Aaron Lun, based on code by Davis McCarthy
van der Maaten LJP, Hinton GE (2008). Visualizing High-Dimensional Data Using t-SNE. J. Mach. Learn. Res. 9, 2579-2605.
Rtsne
, for the underlying calculations.
plotTSNE
, to quickly visualize the results.
?"scater-red-dim-args"
, for a full description of various options.
example_sce <- mockSCE() example_sce <- logNormCounts(example_sce) example_sce <- runTSNE(example_sce, scale_features=NULL) reducedDimNames(example_sce) head(reducedDim(example_sce))