DimPlotAtomic: Atomic Dimension Reduction Plot without splitting the data

View source: R/dimplot.R

DimPlotAtomicR Documentation

Atomic Dimension Reduction Plot without splitting the data

Description

Atomic Dimension Reduction Plot without splitting the data

Usage

DimPlotAtomic(
  data,
  dims = 1:2,
  group_by = NULL,
  group_by_sep = "_",
  features = NULL,
  lower_quantile = 0,
  upper_quantile = 0.99,
  lower_cutoff = NULL,
  upper_cutoff = NULL,
  pt_size = NULL,
  pt_alpha = 1,
  bg_color = "grey80",
  bg_cutoff = NULL,
  color_name = "",
  label_insitu = FALSE,
  show_stat = !identical(theme, "theme_blank"),
  label = FALSE,
  label_size = 4,
  label_fg = "white",
  label_bg = "black",
  label_bg_r = 0.1,
  label_repel = FALSE,
  label_repulsion = 20,
  label_pt_size = 1,
  label_pt_color = "black",
  label_segment_color = "black",
  highlight = NULL,
  highlight_alpha = 1,
  highlight_size = 1,
  highlight_color = "black",
  highlight_stroke = 0.8,
  add_mark = FALSE,
  mark_type = c("hull", "ellipse", "rect", "circle"),
  mark_expand = unit(3, "mm"),
  mark_alpha = 0.1,
  mark_linetype = 1,
  stat_by = NULL,
  stat_plot_type = c("pie", "ring", "bar", "line"),
  stat_plot_size = 0.1,
  stat_palette = "Set1",
  stat_args = list(),
  graph = NULL,
  edge_size = c(0.05, 0.5),
  edge_alpha = 0.1,
  edge_color = "grey40",
  add_density = FALSE,
  density_color = "grey80",
  density_filled = FALSE,
  density_filled_palette = "Greys",
  density_filled_palcolor = NULL,
  lineages = NULL,
  lineages_trim = c(0.01, 0.99),
  lineages_span = 0.75,
  lineages_palette = "Dark2",
  lineages_palcolor = NULL,
  lineages_arrow = ggplot2::arrow(length = unit(0.1, "inches")),
  lineages_linewidth = 1,
  lineages_line_bg = "white",
  lineages_line_bg_stroke = 0.5,
  lineages_whiskers = FALSE,
  lineages_whiskers_linewidth = 0.5,
  lineages_whiskers_alpha = 0.5,
  facet_by = NULL,
  facet_scales = "fixed",
  facet_nrow = NULL,
  facet_ncol = NULL,
  facet_byrow = TRUE,
  title = NULL,
  subtitle = NULL,
  xlab = NULL,
  ylab = NULL,
  theme = "theme_this",
  theme_args = list(),
  aspect.ratio = 1,
  legend.position = "right",
  legend.direction = "vertical",
  raster = NULL,
  raster_dpi = c(512, 512),
  hex = FALSE,
  hex_linewidth = 0.5,
  hex_count = !is.null(group_by),
  hex_bins = 50,
  hex_binwidth = NULL,
  palette = ifelse(is.null(features), "Paired", "Spectral"),
  palcolor = NULL,
  seed = 8525,
  ...
)

Arguments

data

A data frame.

dims

A character vector of the column names to plot on the x and y axes or a numeric vector of the column indices.

group_by

A character string of the column name to group the data. A character/factor column is expected. If multiple columns are provided, the columns will be concatenated with group_by_sep.

group_by_sep

A character string to concatenate the columns in group_by, if multiple columns are provided.

features

A character vector of the column names to plot as features.

lower_quantile, upper_quantile, lower_cutoff, upper_cutoff

Vector of minimum and maximum cutoff values or quantile values for each feature.

pt_size

A numeric value of the point size. If NULL, the point size will be calculated based on the number of data points.

pt_alpha

A numeric value of the point transparency. Default is 1.

bg_color

A character string of the background or NA points. Default is "grey80".

bg_cutoff

A numeric value to be used a cutoff to set the feature values to NA. Default is NULL.

color_name

A character string of the color legend name. Default is "".

label_insitu

Whether to place the raw labels (group names) in the center of the points with the corresponding group. Default is FALSE, which using numbers instead of raw labels.

show_stat

Whether to show the number of points in the subtitle. Default is TRUE.

label

Whether to show the labels of groups. Default is FALSE.

label_size

A numeric value of the label size. Default is 4.

label_fg

A character string of the label foreground color. Default is "white".

label_bg

A character string of the label background color. Default is "black".

label_bg_r

A numeric value of the background ratio of the labels. Default is 0.1.

label_repel

Whether to repel the labels. Default is FALSE.

label_repulsion

A numeric value of the label repulsion. Default is 20.

label_pt_size

A numeric value of the label point size. Default is 1.

label_pt_color

A character string of the label point color. Default is "black".

label_segment_color

A character string of the label segment color. Default is "black".

highlight

A character vector of the row names to highlight. Default is NULL.

highlight_alpha

A numeric value of the highlight transparency. Default is 1.

highlight_size

A numeric value of the highlight size. Default is 1.

highlight_color

A character string of the highlight color. Default is "black".

highlight_stroke

A numeric value of the highlight stroke. Default is 0.5.

add_mark

Whether to add mark to the plot. Default is FALSE.

mark_type

A character string of the mark type. Default is "hull".

mark_expand

A unit value of the mark expand. Default is 3mm.

mark_alpha

A numeric value of the mark transparency. Default is 0.1.

mark_linetype

A numeric value of the mark line type. Default is 1.

stat_by

A character string of the column name to calculate the statistics. Default is NULL.

stat_plot_type

A character string of the statistic plot type. Default is "pie".

stat_plot_size

A numeric value of the statistic plot size. Default is 0.1.

stat_args

A list of additional arguments to the statistic plot. Default is list(palette = "Set1").

graph

A character string of column names or the indexes in the data for the graph data. Default is NULL. If "@graph" is provided, the graph data will be extracted from the data attribute 'graph'.

edge_size

A numeric vector of the edge size range. Default is c(0.05, 0.5).

edge_alpha

A numeric value of the edge transparency. Default is 0.1.

edge_color

A character string of the edge color. Default is "grey40".

add_density

Whether to add density plot. Default is FALSE.

density_color

A character string of the density color. Default is "grey80".

density_filled

Whether to fill the density plot. Default is FALSE.

density_filled_palette

A character string of the filled density palette. Default is "Greys".

density_filled_palcolor

A character vector of the filled density palette colors. Default is NULL.

lineages

A character vector of the column names for lineages. Default is NULL.

lineages_trim

A numeric vector of the trim range for lineages. Default is c(0.01, 0.99).

lineages_span

A numeric value of the lineages span. Default is 0.75.

lineages_palette

A character string of the lineages palette. Default is "Dark2".

lineages_palcolor

A character vector of the lineages palette colors. Default is NULL.

lineages_arrow

An arrow object for the lineages. Default is arrow(length = unit(0.1, "inches")).

lineages_linewidth

A numeric value of the lineages line width. Default is 1.

lineages_line_bg

A character string of the lineages line background color. Default is "white".

lineages_line_bg_stroke

A numeric value of the lineages line background stroke. Default is 0.5.

lineages_whiskers

Whether to add whiskers to the lineages. Default is FALSE.

lineages_whiskers_linewidth

A numeric value of the lineages whiskers line width. Default is 0.5.

lineages_whiskers_alpha

A numeric value of the lineages whiskers transparency. Default is 0.5.

facet_by

A character string specifying the column name of the data frame to facet the plot. Otherwise, the data will be split by split_by and generate multiple plots and combine them into one using patchwork::wrap_plots

facet_scales

Whether to scale the axes of facets. Default is "fixed" Other options are "free", "free_x", "free_y". See ggplot2::facet_wrap

facet_nrow

A numeric value specifying the number of rows in the facet. When facet_by is a single column and facet_wrap is used.

facet_ncol

A numeric value specifying the number of columns in the facet. When facet_by is a single column and facet_wrap is used.

facet_byrow

A logical value indicating whether to fill the plots by row. Default is TRUE.

title

A character string specifying the title of the plot. A function can be used to generate the title based on the default title. This is useful when split_by is used and the title needs to be dynamic.

subtitle

A character string specifying the subtitle of the plot.

xlab

A character string specifying the x-axis label.

ylab

A character string specifying the y-axis label.

theme

A character string or a theme class (i.e. ggplot2::theme_classic) specifying the theme to use. Default is "theme_this".

theme_args

A list of arguments to pass to the theme function.

aspect.ratio

A numeric value specifying the aspect ratio of the plot.

legend.position

A character string specifying the position of the legend. if waiver(), for single groups, the legend will be "none", otherwise "right".

legend.direction

A character string specifying the direction of the legend.

raster

Whether to raster the plot. Default is NULL.

raster_dpi

A numeric vector of the raster dpi. Default is c(512, 512).

hex

Whether to use hex plot. Default is FALSE.

hex_linewidth

A numeric value of the hex line width. Default is 0.5.

hex_count

Whether to count the hex.

hex_bins

A numeric value of the hex bins. Default is 50.

hex_binwidth

A numeric value of the hex bin width. Default is NULL.

palette

A character string specifying the palette to use. A named list or vector can be used to specify the palettes for different split_by values.

palcolor

A character string specifying the color to use in the palette. A named list can be used to specify the colors for different split_by values. If some values are missing, the values from the palette will be used (palcolor will be NULL for those values).

seed

The random seed to use. Default is 8525.

...

Additional arguments.

Value

A ggplot object


plotthis documentation built on April 11, 2025, 5:45 p.m.