View source: R/visualization.R
tof_plot_cells_embedding | R Documentation |
This function makes scatterplots using single-cell data embedded in a
low-dimensional space (such as that generated by
tof_reduce_dimensions
, with each point colored using a
user-specified variable.
tof_plot_cells_embedding(
tof_tibble,
embedding_cols,
color_col,
facet_cols,
compute_embedding_cols = where(tof_is_numeric),
embedding_method = c("pca", "tsne", "umap"),
embedding_args = list(),
theme = ggplot2::theme_bw(),
...,
method = c("ggplot2", "scattermore")
)
tof_tibble |
A 'tof_tbl' or a 'tibble'. |
embedding_cols |
Unquoted column names indicating which columns in
'tof_tibble' should be used as the x and y axes of the scatterplot. Supports
tidyselect helpers. Must select exactly 2 columns. If not provided, a
feature embedding can be computed from scratch using the method provided
using the 'embedding_method' argument and the
|
color_col |
An unquoted column name specifying which column in 'tof_tibble' should be used to color each point in the scatterplot. |
facet_cols |
An unquoted column name specifying which column in
'tof_tibble' should be used to break the scatterplot into facets using
|
compute_embedding_cols |
Unquoted column names indicating which columns in 'tof_tibble' to use for computing the embeddings with the method specified by ‘embedding_method'. Defaults to all numeric columns in ’tof_tibble'. Supports tidyselect helpers. |
embedding_method |
A string indicating which method should be used for
the feature embedding (if 'embedding_cols' are not provided). Options
(which are passed to |
embedding_args |
Optional additional arguments to pass to
|
theme |
A ggplot2 theme to apply to the scatterplot. Defaults to
|
... |
Optional additional arguments to pass to
|
method |
A string indicating which plotting engine should be used. Valid
values include "ggplot2" (the default) and "scattermore" (recommended if more than
100K cells are being plotted). Note that |
A ggplot object.
Other visualization functions:
tof_plot_cells_layout()
,
tof_plot_cells_scatter()
sim_data <-
dplyr::tibble(
cd45 = rnorm(n = 1000),
cd38 = c(rnorm(n = 500), rnorm(n = 500, mean = 2)),
cd34 = c(rnorm(n = 500), rnorm(n = 500, mean = 4)),
cd19 = rnorm(n = 1000),
cluster_id = c(rep("a", 500), rep("b", 500))
)
# embed with pca
pca_plot <-
tof_plot_cells_embedding(
tof_tibble = sim_data,
color_col = cd38,
embedding_method = "pca",
compute_embedding_cols = starts_with("cd")
)
# embed with tsne
tsne_plot <-
tof_plot_cells_embedding(
tof_tibble = sim_data,
color_col = cluster_id,
embedding_method = "tsne",
compute_embedding_cols = starts_with("cd")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.