Plot embedding with ArchR-compatible aesthetics
plot_embedding.RdGeneral-purpose embedding plotter (UMAP/TSNE) supporting discrete (clusters) and continuous (scores) coloring.
Usage
plot_embedding(x, ...)
# Default S3 method
plot_embedding(
x,
embedding,
features = NULL,
colors_discrete = palette_discrete("stallion"),
colors_continuous = palette_continuous("solarExtra"),
plot_as = NULL,
hex_bins = 200L,
hex_fun = "median",
hex_cut = c(0.02, 0.98),
quant_cut = c(0.01, 0.99),
size = 0.1,
alpha = 1,
randomize = TRUE,
seed = 1L,
rastr = FALSE,
raster_px = 512L,
highlight_cells = NULL,
sample_cells = NULL,
label_means = TRUE,
label_size = 4,
label_as_factors = TRUE,
bg_color = "white",
bg_width = 1,
keep_axis = FALSE,
base_size = 10,
title = NULL,
xlabel = NULL,
ylabel = NULL,
extend = 0.05,
legend_position = "bottom",
legend_text_size = 5,
legend_title = NULL,
legend_labels = c("quantile", "value"),
verbose = getOption("MarchR.verbose", FALSE),
...
)
# S3 method for class 'MarchRProject'
plot_embedding(
x,
embedding = "UMAP",
color_by = "cell_metadata",
col_name = "clusters",
colors_discrete = palette_discrete("stallion"),
colors_continuous = palette_continuous("solarExtra"),
plot_as = NULL,
hex_bins = 200L,
hex_fun = "median",
hex_cut = c(0.02, 0.98),
quant_cut = c(0.01, 0.99),
size = 0.1,
alpha = 1,
randomize = TRUE,
seed = 1L,
rastr = FALSE,
raster_px = 512L,
highlight_cells = NULL,
sample_cells = NULL,
label_means = TRUE,
label_size = 4,
label_as_factors = TRUE,
bg_color = "white",
bg_width = 1,
keep_axis = FALSE,
base_size = 10,
title = NULL,
xlabel = NULL,
ylabel = NULL,
extend = 0.05,
legend_position = "bottom",
legend_text_size = 5,
legend_title = NULL,
legend_labels = c("quantile", "value"),
verbose = getOption("MarchR.verbose", FALSE),
...
)Arguments
- x
(vector, factor, or matrix) Color source. Numeric vector for continuous, character/factor for discrete, or features-by-cells matrix (with
features).- ...
Additional arguments (unused).
- embedding
(character) Embedding prefix (e.g.
"UMAP","tSNE"). Default"UMAP".- features
(character) Row names to plot if
xis a matrix.- colors_discrete
(character) Discrete palette. Default
palette_discrete("stallion").- colors_continuous
(character) Continuous palette. Default
palette_continuous("solarExtra").- plot_as
(character)
"points","hexplot", or NULL for auto-detection.- hex_bins
(integer) Hex bin count (hexplot only). Default 200.
- hex_fun
(character) Hex aggregation function (hexplot only). Default
"median".- hex_cut
(numeric) Hex fill quantile thresholds (hexplot only). Default
c(0.02, 0.98).- quant_cut
(numeric) Quantile thresholds for continuous color clipping. Default
c(0.01, 0.99).- size
(numeric) Point size. Default 0.1.
- alpha
(numeric) Point alpha. Default 1.
- randomize
(logical) Shuffle point draw order. Default TRUE.
- seed
(integer) Random seed for shuffling. Default 1.
- rastr
(logical) Rasterize points via scattermore. Default FALSE.
- raster_px
(numeric) Raster resolution in pixels. Default 512.
- highlight_cells
(integer or character) Cell indices or names to highlight. Non-highlighted cells are rendered in grey. Default NULL (no highlighting).
- sample_cells
(integer) Number of cells to randomly subsample for plotting. NULL plots all cells. Default NULL.
- label_means
(logical) Show cluster center labels (discrete only). Default TRUE.
- label_size
(numeric) Label text size. Default 3.
- label_as_factors
(logical) Prefix labels with numbers ("1-A"). Default TRUE.
- bg_color
(character) Halo background color. Default
"white".- bg_width
(numeric) Halo offset. Default 1.
- keep_axis
(logical) Show axis tick text/marks. Default FALSE.
- base_size
(numeric) Theme base font size. Default 10.
- title
(character) Plot title. NULL for auto.
- xlabel
(character) X-axis label. NULL for auto from column names.
- ylabel
(character) Y-axis label. NULL for auto from column names.
- extend
(numeric) Axis range extension factor. Default 0.05.
- legend_position
(character) Legend position. Default
"bottom".- legend_text_size
(numeric) Legend text size. Default 5.
- legend_title
(character) Legend title. NULL for auto.
- legend_labels
(character) Continuous color bar labels:
"quantile"marks thequant_cutends (e.g. "p1", "p99");"value"shows data units. Default"quantile".- verbose
(logical) Print progress messages. Default
getOption("MarchR.verbose", FALSE).- color_by
(character)
"cell_metadata"or matrix assay name.- col_name
(character) Column or feature name(s) to color by. Default
"clusters".
Details
ArchR correspondence: plotEmbedding(ArchRProj, embedding, colorBy, name)
This function masks BPCells::plot_embedding. Users who need the BPCells version
should call it as BPCells::plot_embedding() explicitly.