Skip to contents

Create a scatter plot with cells colored based on the provided feature. This can be used to create dimensional reduction plots (e.g. UMAP, tSNE, PCA) or to compare different cell attributes (e.g. CD4 vs CD8 expression). When plotting V(D)J data, per-chain values will be summarized for each cell.

Usage

plot_scatter(
  input,
  data_col = NULL,
  x = "UMAP_1",
  y = "UMAP_2",
  group_col = NULL,
  data_slot = "data",
  top = NULL,
  other_label = "other",
  plot_colors = NULL,
  plot_lvls = NULL,
  outline = FALSE,
  trans = "identity",
  panel_nrow = NULL,
  panel_scales = "fixed",
  min_q = NULL,
  max_q = NULL,
  na_color = "grey80",
  n_label = NULL,
  label_params = list(),
  ...,
  chain = NULL,
  chain_col = global$chain_col,
  summary_fn = NULL,
  sep = global$sep
)

Arguments

input

Single cell object or data.frame, if a data.frame is provided, cell barcodes should be stored as row names.

data_col

Name of meta.data column or other variable (e.g. gene name) to use for coloring points

x, y

Name of meta.data column or other variable to plot on x and y-axis

group_col

meta.data column to use for splitting plot into panels

data_slot

Slot to pull data from when input is a Seurat object

top

To only show the top cell groups, provide one of the following, all other cells will be labeled using the value provided to the other_label argument. If NULL this will be automatically set.

  • Integer specifying the number of top groups to show

  • Vector specifying the names of cell groups to show

other_label

Label to use for 'other' cells when top is specified, if NULL all cell groups will be shown.

plot_colors

Character vector specifying colors to use for cell clusters specified by cluster_col.

plot_lvls

Character vector containing order to use for plotting cell clusters specified by cluster_col.

outline

Add an outline around each cluster, outline aesthetics can be modified by passing arguments directly to ggtrace::geom_point_trace()

trans

Transformation to use when plotting data, e.g. 'log10'. By default values are not transformed, refer to ggplot2::continuous_scale() for more options.

panel_nrow

The number of rows to use for arranging plot panels

panel_scales

Should scales for plot panels be fixed or free. This passes a scales specification to ggplot2::facet_wrap(), can be 'fixed', 'free', 'free_x', or 'free_y'. 'fixed' will cause panels to share the same scales.

min_q

Minimum quantile cutoff for color scale.

max_q

Maximum quantile cutoff for color scale.

na_color

Color to use for missing values. If plotting V(D)J data, cells lacking data will be plotted as NAs.

n_label

Location on plot where n label should be added, this can be any combination of the following:

  • 'corner', display the total number of cells plotted in the top right corner, the position of the label can be modified by passing x and y specifications with the label_params argument

  • 'legend', display the number of cells plotted for each group shown in the plot legend

  • 'none', do not display the number of cells plotted

label_params

Named list providing additional parameters to modify n label aesthetics, e.g. list(size = 4, color = "red")

...

Additional arguments to pass to ggplot2::geom_point(), or ggtrace::geom_point_trace() if outline = TRUE, e.g. color, size, etc.

chain

Chain(s) to use for filtering data before plotting. If NULL data will not be filtered based on chain.

chain_col

meta.data column containing chains for each cell

summary_fn

Function to use for summarizing per-chain values for each cell, can be either a function, e.g. mean, or a purrr-style lambda, e.g. ~ mean(.x, na.rm = TRUE) where .x refers to the column. If NULL, the mean will be calculated for numeric values, non-numeric columns will be combined into a single string.

sep

Separator used for storing per-chain V(D)J data for each cell

Value

ggplot object

See also

summarize_vdj() for more examples on how per-chain data can be summarized for each cell

Examples

# Create scatter plot
plot_scatter(
  vdj_sce,
  data_col = "reads",
  x        = "UMAP_1",
  y        = "UMAP_2",
  trans    = "log10"
)