plotTreeForce: Plot force-directed layout of tree

Description Usage Arguments Details Value Examples

View source: R/tree-force-layout.R

Description

This plots data on the force-directed layout of an URD tree, generated by treeForceDirectedLayout. Once the tree is rotated into a perspective that is appealing, plotTreeForceStore3DView can be used to store that view in the URD object for additional plots.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
plotTreeForce(
  object,
  label,
  label.type = "search",
  view = "default",
  alpha = 0.8,
  alpha.fade = 0.1,
  size = 5,
  title = NULL,
  title.cex = 3,
  title.line = 0,
  label.tips = (!is.null(object@tree$segment.names) |
    !is.null(object@tree$segment.names.short)),
  use.short.names = !is.null(object@tree$segment.names.short),
  seg.show = NULL,
  cells.show = NULL,
  fade.below = (2/9),
  density.alpha = T,
  label.spacing = 5,
  text.cex = 0.8,
  colors = NULL,
  discrete.colors = NULL,
  color.limits = NULL,
  symmetric.color.scale = NULL
)

Arguments

object

An URD object

label

(Character) Data to use for coloring tree (see data.for.plot)

label.type

(Character) Where to find data for label (default "search" auto-detects, see data.for.plot)

view

(Character) Name of view to use (i.e. the name of an entry in @tree$force.view.list) created by plotTreeForceStore3DView. Default is last view created.

alpha

(Numeric) Maximum transparency of points

alpha.fade

(Numeric) Minimum transparency of points

size

(Numeric) Size of points in the plot

title

(Character) Title to add to the plot. (This is sensitive to resizing the window after plotting, but if a view is stored, the window will be resized before the title is added, so it will be acceptable resolution for figures.)

title.cex

(Numeric) Adjust the title font size

title.line

(Numeric) Adjust the position of the title. Positive numbers move the title upward.

label.tips

(Logical) Should text identifying the tips of the tree be placed in the force directed layout? Defaults to TRUE if @tree$segment.names has been set.

use.short.names

(Logical) Should short names from @tree$segment.names.short be used? Defaults to TRUE if those values have been set.

seg.show

(Character vector) Segments of the tree to put on the plot (Default NULL is all segments)

cells.show

(Character vector) Cells of the tree to show (Default NULL is all cells)

fade.below

(Numeric) If desired, transparency can be lowered for points with low expression values (thereby highlighting the portions of the tree with expression). This value is the portion of the range of expression values to fade. (The default, 2/9, fades the bottom two-ninths of the expression values.) A fully 'faded' point will have alpha of alpha.fade.

density.alpha

(Logical) Should points with short distance to nearest neighbors (i.e. in denser regions of the plot) be more transparent?

label.spacing

(Numeric) How far should labels be from the detected tips

text.cex

(Numeric) Size of the label text

colors

(Character vector) Vector of colors to use if plotting continuous data

discrete.colors

(Character vector) Vector of colors to use if plotting discrete data

color.limits

(Numeric vector, length 2) Minimum and maximum values for color scale. Default NULL auto-detects.

symmetric.color.scale

(Logical) Should the color scale be symmetric and centered around 0? (Default NULL is FALSE if all values are positive, and TRUE if both positive and negative values are present.)

Details

The transparency of points is typically adjusted in two ways: (1) Points with low expression are made more transparent, which is controlled through the fade.below and alpha.fade parameters. (2) Points in higher density regions of the plot are made more transparent, which is controlled by the density.alpha parameter (and the local density is determined by the density.neighbors parameter of treeForceDirectedLayout, and can be adjusted after the fact by re-running fdlDensity).

Plots can be easily saved using rgl:rgl.snapshot and plots can be closed with rgl:rg.close if plotting many genes using a loop.

Value

Nothing. Produces a plot using the rgl package, displayed in an X11 window.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Define the colors used below
stage.colors <- c("#CCCCCC", RColorBrewer::brewer.pal(9, "Set1")[9], RColorBrewer::brewer.pal(12, "Paired")[c(9,10,7,8,5,6,3,4,1,2)])
fire.with.grey <- c("#CECECE", "#DDC998", RColorBrewer::brewer.pal(9, "YlOrRd")[3:9])
branch.colors <- c("#CECECE", "#E6298B")

# Plot a discrete characteristic like stage or clustering results
plotTreeForce(object, "stage.nice", title="STAGE", title.line=1, discrete.colors = stage.colors, alpha=0.4)

# Plot gene expression
plotTreeForce(object, "NOTO", title="NOTO expression", title.line=1, colors = fire.with.grey)

Define a 'clustering' based on whether or not cells are in a given trajectory then plot it
object <- groupFromCells(object, group.id="lineage_Tailbud", cells=cellsAlongLineage(object, "Tailbud", remove.root=F))
plotTreeForce(object, "lineage_Tailbud", title="Tailbud", title.line=1, discrete.colors=branch.colors, alpha=0.4)

farrellja/URD documentation built on June 17, 2020, 4:48 a.m.