Plot t-SNE embeddings computed by compute_tsne(). Supports both
2D (ggplot2) and 3D (plotly) views.
Usage
plot_tsne(
tsne_res,
view = c("2d", "3d"),
colour = NULL,
size = 1.5,
alpha = 0.8,
palette = NULL,
...
)Arguments
- tsne_res
A
phip_tsneobject returned bycompute_tsne(). The function also works with a plain tibble/data frame that contains at least columnstSNE1andtSNE2(andtSNE3for 3D).- view
Character, either
"2d"or"3d"."2d"returns aggplotobject;"3d"returns aplotlyHTML widget.- colour
Optional name of a column in
tsne_resto map to point colour. IfNULL, the function uses the first metadata column stored inattr(tsne_res, "meta_cols"), if available.- size
Numeric point size for scatter plots. Defaults to
1.5.- alpha
Numeric transparency for points (0-1). Defaults to
0.8.- palette
Optional vector of colour values passed to
scale_color_manual()(2D) orcolors(3D plotly).- ...
Currently ignored; reserved for future extensions.
Examples
if (FALSE) { # \dontrun{
tsne_res <- compute_tsne(ps, compute_distance(ps))
# 2D plot
p2d <- plot_tsne(tsne_res, view = "2d", colour = "type_person")
# 3D interactive plot
p3d <- plot_tsne(tsne_res, view = "3d", colour = "type_person")
} # }