runTSNE {scater} | R Documentation |
Produce a t-distributed stochastic neighbour embedding (t-SNE) plot of two
components for an SingleCellExperiment
dataset.
runTSNE(object, ntop = 500, ncomponents = 2, exprs_values = "logcounts", feature_set = NULL, use_dimred = NULL, n_dimred = NULL, scale_features = TRUE, rand_seed = NULL, perplexity = floor(ncol(object)/5), ...) plotTSNE(object, colour_by = NULL, shape_by = NULL, size_by = NULL, return_SCE = FALSE, draw_plot = TRUE, theme_size = 10, legend = "auto", rerun = FALSE, ncomponents = 2, ...)
object |
an |
ntop |
numeric scalar indicating the number of most variable features to
use for the t-SNE Default is |
ncomponents |
numeric scalar indicating the number of t-SNE
components to plot, starting from the first t-SNE component. Default is
2. If |
exprs_values |
character string indicating which values should be used
as the expression values for this plot. Valid arguments are |
feature_set |
character, numeric or logical vector indicating a set of
features to use for the t-SNE calculation. If character, entries must all be
in |
use_dimred |
character(1), use named reduced dimension representation of cells
stored in |
n_dimred |
integer(1), number of components of the reduced dimension slot
to use. Default is |
scale_features |
logical, should the expression values be standardised
so that each feature has unit variance? Default is |
rand_seed |
(optional) numeric scalar that can be passed to
|
perplexity |
numeric scalar value defining the "perplexity parameter"
for the t-SNE plot. Passed to |
... |
further arguments passed to |
colour_by |
character string defining the column of |
shape_by |
character string defining the column of |
size_by |
character string defining the column of |
return_SCE |
logical, should the function return an |
draw_plot |
logical, should the plot be drawn on the current graphics
device? Only used if |
theme_size |
numeric scalar giving default font size for plotting theme (default is 10). |
legend |
character, specifying how the legend(s) be shown? Default is
|
rerun |
logical, should PCA be recomputed even if |
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 plots (see set.seed
to set a random seed for replicable results). The value of the
perplexity
parameter can have a large effect on the resulting plot, so
it can often be worthwhile to try multiple values to find the most appealing
visualisation.
If return_SCE
is TRUE
, then the function returns a
SingleCellExperiment
object, otherwise it returns a ggplot
object.
L.J.P. van der Maaten. Barnes-Hut-SNE. In Proceedings of the International Conference on Learning Representations, 2013.
## Set up an example SingleCellExperiment data("sc_example_counts") data("sc_example_cell_info") example_sce <- SingleCellExperiment( assays = list(counts = sc_example_counts), colData = sc_example_cell_info) example_sce <- normalize(example_sce) drop_genes <- apply(exprs(example_sce), 1, function(x) {var(x) == 0}) example_sce <- example_sce[!drop_genes, ] ## Examples plotting t-SNE plotTSNE(example_sce, perplexity = 10) plotTSNE(example_sce, colour_by = "Cell_Cycle", perplexity = 10) plotTSNE(example_sce, colour_by = "Cell_Cycle", shape_by = "Treatment", size_by = "Mutation_Status", perplexity = 10) plotTSNE(example_sce, shape_by = "Treatment", size_by = "Mutation_Status", perplexity = 5) plotTSNE(example_sce, feature_set = 1:100, colour_by = "Treatment", shape_by = "Mutation_Status", perplexity = 5) plotTSNE(example_sce, shape_by = "Treatment", return_SCE = TRUE, perplexity = 10)