plotByDatasetAndCluster: Plot t-SNE coordinates of cells across datasets

View source: R/rliger.R

plotByDatasetAndClusterR Documentation

Plot t-SNE coordinates of cells across datasets

Description

Generates two plots of all cells across datasets, one colored by dataset and one colored by cluster. These are useful for visually examining the alignment and cluster distributions, respectively. If clusters have not been set yet (quantileAlignSNF not called), will plot by single color for second plot. It is also possible to pass in another clustering (as long as names match those of cells).

Usage

plotByDatasetAndCluster(
  object,
  clusters = NULL,
  title = NULL,
  pt.size = 0.3,
  text.size = 3,
  do.shuffle = TRUE,
  rand.seed = 1,
  axis.labels = NULL,
  do.legend = TRUE,
  legend.size = 5,
  reorder.idents = FALSE,
  new.order = NULL,
  return.plots = FALSE,
  legend.fonts.size = 12,
  raster = NULL
)

Arguments

object

liger object. Should call runTSNE or runUMAP before calling.

clusters

Another clustering to use for coloring second plot (must have same names as clusters slot) (default NULL).

title

Plot titles (list or vector of length 2) (default NULL).

pt.size

Controls size of points representing cells (default 0.3).

text.size

Controls size of plot text (cluster center labels) (default 3).

do.shuffle

Randomly shuffle points so that points from same dataset are not plotted one after the other (default TRUE).

rand.seed

Random seed for reproducibility of point shuffling (default 1).

axis.labels

Vector of two strings to use as x and y labels respectively.

do.legend

Display legend on plots (default TRUE).

legend.size

Size of legend on plots (default 5).

reorder.idents

logical whether to reorder the datasets from default order before plotting (default FALSE).

new.order

new dataset factor order for plotting. must set reorder.idents = TRUE.

return.plots

Return ggplot plot objects instead of printing directly (default FALSE).

legend.fonts.size

Controls the font size of the legend.

raster

Rasterization of points (default NULL). Automatically convert to raster format if there are over 100,000 cells to plot.

Value

List of ggplot plot objects (only if return.plots TRUE, otherwise prints plots to console).

Examples

ligerex <- createLiger(list(ctrl = ctrl, stim = stim))
ligerex <- normalize(ligerex)
ligerex <- selectGenes(ligerex)
ligerex <- scaleNotCenter(ligerex)
ligerex <- optimizeALS(ligerex, k = 5, max.iter = 1)
ligerex <- quantile_norm(ligerex)
ligerex <- runTSNE(ligerex)
ligerex <- louvainCluster(ligerex)
plotByDatasetAndCluster(ligerex, pt.size = 1)

rliger documentation built on Nov. 9, 2023, 1:07 a.m.