Skip to contents

Please use make.colour.plot(fast = TRUE) instead.

Usage

fast.colour.plot(
  dat,
  x.axis,
  y.axis,
  col.axis = NULL,
  col.type = "continuous",
  add.label = FALSE,
  hex = FALSE,
  hex.bins = 30,
  colours = "spectral",
  col.min.threshold = 0.01,
  col.max.threshold = 0.995,
  align.xy.by = dat,
  align.col.by = dat,
  regression.line = NULL,
  title = col.axis,
  filename = NULL,
  dot.size = 1,
  plot.width = 9,
  plot.height = 7,
  nudge_x = 0.5,
  nudge_y = 0.5,
  square = TRUE,
  legend.loc = "right",
  save.to.disk = TRUE,
  path = getwd(),
  blank.axis = FALSE,
  col.tab = NULL
)

Arguments

dat

NO DEFAULT. data.table Input sample.

x.axis

NO DEFAULT. Character. Column for X axis.

y.axis

NO DEFAULT. Character. Column for Y axis.

col.axis

DEFAULT = NULL. If not specified, plot is coloured by density. If you provide a character name of a column (e.g. "BV605.Ly6C", "Group", "FlowSOM_metacluster" etc), then each point will be coloured by the value in that column.

col.type

DEFAULT = "continuous". Can also be "factor".

add.label

DEFAULT = FALSE. Adds labels on the plot at the centroid of each factor. Only works if col.type = "factor".

hex

DEFAULT = FALSE. Whether to split the data into bins and show the average expression of the bin. Currently only works when specifying col.axis, so does not work with density plots.

hex.bins

DEFAULT = 30. Number of bins to split into. Only used if hex is TRUE.

colours

DEFAULT = "spectral". Only used if type = 'colour', ignored if type = 'factor'. Specify a colour scheme. Can be "jet", "spectral", "viridis", "inferno", "magma", or "BuPu". Can also provide a data.table with the first column being the factors, and the second column being the corresponding colour code.

col.min.threshold

DEFAULT = 0.01. Numeric. Define minimum threshold for colour scale. Values below this limit will be coloured as the chosen minimum threshold.

col.max.threshold

DEFAULT = 0.995 Numeric. Define maximum threshold for colour scale. Values above this limit will be coloured as the chosen maximum threshold.

align.xy.by

DEFAULT = dat. data.table Sample to use to determine minimum and maximum X and Y axis values.

align.col.by

DEFAULT = dat. data.table. Sample to use to determine minimum and maximum colour values.

regression.line

DEFAULT = NULL. Regression line to add to show the trend of the data. This will be passed on to ggplot2::geom_smooth function, and accepts either NULL or a character vector, e.g. "lm", "glm", "gam", "loess" or a function.

title

DEFAULT = col.axis. Character. Title for the plot.

filename

DEFAULT = NULL. Character. The name of the file to save the plot to.

dot.size

DEFAULT = 1. Numeric. Size of the dots.

plot.width

DEFAULT = 9. Width of the ggplot when saved to disk.

plot.height

DEFAULT = 7. Height of the ggplot when saved to disk.

nudge_x

DEFAULT = 0.5. When add.label = TRUE, distance the label is shifted from the centroid point on the X axis.

nudge_y

DEFAULT = 0.5. When add.label = TRUE, distance the label is shifted from the centroid point on the Y axis.

square

DEFAULT = TRUE. Ensures the plot is saved as a square. Set to FALSE if you want a plot with different X and Y lengths.

legend.loc

DEFAULT = 'right'. By default plot legends will be on the right hand side. Can specify the legend location to "bottom" if desired, or 'none' to remove it entirely.

save.to.disk

DEFAULT = TRUE. Will save the ggplot to disk. If FALSE, will only show the ggplot.

path

DEFAULT = getwd(). The location to save your ggplot. By default, will save to current working directory. Can be overidden.

blank.axis

DEFAULT = FALSE Logical, do you want a minimalist graph?

Details

Create a FAST dot plot (X vs Y) coloured by a selected continuous (e.g. marker expression) or factorial (e..g. cluster, group) column.

This function allows you to create a coloured XY plot where each cell is coloured by a selected column. Typically used to plot cells on tSNE1/2 or UMAP1/2 coloured by select cellular markers or clusters, samples, groups etc.

See also

https://sydneycytometry.org.au/spectre for usage instructions and vignettes.

Author

Thomas M Ashhurst, thomas.ashhurst@sydney.edu.au Givanna Putri

Examples

# Load packages
library(Spectre)
cell.dat <- Spectre::demo.umap
#> Error: 'demo.umap' is not an exported object from 'namespace:Spectre'
cell.dat <- as.data.table(cell.dat)
#> Error: object 'cell.dat' not found

# Draw plot
Spectre::fast.colour.plot(
  dat = cell.dat,
  x.axis = "UMAP_42_X",
  y.axis = "UMAP_42_Y",
  col.axis = "BV605.Ly6C"
)
#> Warning: `fast.colour.plot()` was deprecated in Spectre 1.3.0.
#>  fast.colour.plot() will be removed in the next version. Please use
#>   make.colour.plot(fast = TRUE) instead.
#> Error: object 'cell.dat' not found