getDimRedPlot: getDimRedPlot

View source: R/dimRed.R

getDimRedPlotR Documentation

getDimRedPlot

Description

Generate a plot from dimension reduction coordinates

Usage

getDimRedPlot(
  coords,
  annot = NULL,
  colorCol = NULL,
  shapeCol = NULL,
  colScheme = "[auto]",
  ptSize = 3,
  addLabels = FALSE,
  addDensity = FALSE,
  addVoronoi = FALSE,
  annot.text = NULL,
  orderCol = NULL,
  facetCols = NULL
)

Arguments

coords

dimension reduction coordinates

annot

annotation matrix with the same number of rows as coord

colorCol

name or index in the annotation matrix (annot) that should be used for coloring the points if colorCol not supplied but annot is supplied, it defaults to the first annotation column

shapeCol

name or index in the annotation matrix (annot) that should be used for point shapes if shapeCol not supplied but annot is supplied and has more than one column, it defaults to the second annotation column

colScheme

color sheme to be used in coloring the points. can be a character vector with the supplied colors. Alternatively, if it is a one-element character vector "[auto]" the color scheme will be selected automatically using muRtools::ggAutoColorScale. If NULL, ggplots default color scheme will be used.

ptSize

size of the points in the scatterplot

addLabels

should observation labels be added to each point

addDensity

should Gaussian Kernel density estimation be performed and the contour lines plotted for each color group

addVoronoi

should a Voronoi tessalation grid (based on colorCol) be added to the plot

annot.text

optional text to be added in the lower right corner of the plot

orderCol

name or index in the annotation matrix (annot) that should be used for ordering the points. If not NULL Points will be ordered increasingly by their value, i.e. higher-valued points are plottet over lower-valued points

facetCols

name (string) of columns to be used for faceting the resulting plot. Each facet will contain all the points not in the facet as grey points.

Value

a ggplot2 object containing the dimension reduction plot

Author(s)

Fabian Mueller

Examples


df <- data.frame(
	x = c(rnorm(20, mean=0, sd=0.2), rnorm(10, mean=1, sd=0.4), rnorm(15, mean=1, sd=0.2)),
	y = c(rnorm(20, mean=0, sd=0.2), rnorm(10, mean=1, sd=0.4), rnorm(15, mean=0.5, sd=0.3)),
	group = rep(c("group1", "group2", "group3"), times=c(20,10,15)),
	stringsAsFactors=FALSE
)
getDimRedPlot(df[,c("x", "y")], annot=df[,c("group"), drop=FALSE], colorCol="group")
getDimRedPlot(df[,c("x", "y")], annot=df[,c("group"), drop=FALSE], colorCol="group", addDensity=TRUE)


demuellae/muRtools documentation built on Nov. 6, 2024, 9:44 a.m.