View source: R/make.colour.plot.R
make.colour.plot | R Documentation |
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.
make.colour.plot(dat, x.axis, y.axis, col.axis)
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. |
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". |
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. |
title |
DEFAULT = col.axis. Character. Title for the plot. |
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? |
Thomas M Ashhurst, thomas.ashhurst@sydney.edu.au Givanna Putri
https://sydneycytometry.org.au/spectre
https://sydneycytometry.org.au/spectre for usage instructions and vignettes.
# Draw plot
Spectre::make.colour.plot(dat = Spectre::demo.clustered,
x.axis = "UMAP_X",
y.axis = "UMAP_Y",
col.axis = "CD4_asinh")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.