plot.DiffusionMap: 3D or 2D plot of diffusion map

View source: R/diffusionmap-plotting.r

plot.DiffusionMapR Documentation

3D or 2D plot of diffusion map

Description

If you want to plot the eigenvalues, simply plot(eigenvalues(dm)[start:end], ...)

Usage

plot.DiffusionMap(
  x,
  dims = 1:3,
  new_dcs = if (!is.null(new_data)) dm_predict(x, new_data),
  new_data = NULL,
  col = NULL,
  col_by = NULL,
  col_limits = NULL,
  col_new = "red",
  pal = NULL,
  pal_new = NULL,
  ...,
  ticks = FALSE,
  axes = TRUE,
  box = FALSE,
  legend_main = col_by,
  legend_opts = list(),
  interactive = FALSE,
  draw_legend = !is.null(col_by) || (length(col) > 1 && !is.character(col)),
  consec_col = TRUE,
  col_na = "grey",
  plot_more = function(p, ..., rescale = NULL) p
)

## S4 method for signature 'DiffusionMap,numeric'
plot(x, y, ...)

## S4 method for signature 'DiffusionMap,missing'
plot(x, y, ...)

Arguments

x

A DiffusionMap

dims, y

Diffusion components (eigenvectors) to plot (default: first three components; 1:3)

new_dcs

An optional matrix also containing the rows specified with y and plotted. (default: no more points)

new_data

A data set in the same format as x that is used to create new_dcs <- dm_predict(dif, new_data)

col

Single color string or vector of discrete or categoric values to be mapped to colors. E.g. a column of the data matrix used for creation of the diffusion map. (default: cluster_louvain if igraph is installed)

col_by

Specify a dataset(x) or phenoData(dataset(x)) column to use as color

col_limits

If col is a continuous (=double) vector, this can be overridden to map the color range differently than from min to max (e.g. specify c(0, 1))

col_new

If new_dcs is given, it will take on this color. A vector is also possible. (default: red)

pal

Palette used to map the col vector to colors. (default: use hcl.colors for continuous and palette() for discrete data)

pal_new

Palette used to map the col_new vector to colors. (default: see pal argument)

...

Parameters passed to plot, scatterplot3d, or plot3d (if interactive == TRUE)

ticks

logical. If TRUE, show axis ticks (default: FALSE)

axes

logical. If TRUE, draw plot axes (default: Only if ticks is TRUE)

box

logical. If TRUE, draw plot frame (default: TRUE or the same as axes if specified)

legend_main

Title of legend. (default: nothing unless col_by is given)

legend_opts

Other colorlegend options (default: empty list)

interactive

Use plot3d to plot instead of scatterplot3d?

draw_legend

logical. If TRUE, draw color legend (default: TRUE if col_by is given or col is given and a vector to be mapped)

consec_col

If col or col_by refers to an integer column, with gaps (e.g. c(5,0,0,3)) use the palette color consecutively (e.g. c(3,1,1,2))

col_na

Color for NA in the data. specify NA to hide.

plot_more

Function that will be called while the plot margins are temporarily changed (its p argument is the rgl or scatterplot3d instance or NULL, its rescale argument is NULL, a list(from = c(a, b), to = c(c, d))), or an array of shape from|to \times dims \times min|max, i.e. 2 \times length(dims) \times 2. In case of 2d plotting, it should take and return a ggplot2 object.

Details

If you specify negative numbers as diffusion components (e.g. plot(dm, c(-1,2))), then the corresponding components will be flipped.

Value

The return value of the underlying call is returned, i.e. a scatterplot3d or rgl object.

Examples

data(guo)
plot(DiffusionMap(guo))


theislab/destiny documentation built on Oct. 30, 2024, 1:39 a.m.