SVGCanvas: SVG canvas

SVGCanvasR Documentation

SVG canvas

Description

Creates an object of class SVGCanvas.

Usage

SVGCanvas(
  trees,
  outgroupTips = NULL,
  analysisNames = character(0),
  width = 682,
  height = 682,
  uniqueTrees = unique(trees),
  xMargins = c(10L, 10L),
  yMargins = c(10L, 10L),
  textY = 3L
)

Arguments

trees

A list of trees, perhaps of class multiPhylo

outgroupTips

Character vector specifying tips to include in the outgroup, to be sent to TreeTools::RootTree().

analysisNames

Character vector of length length(trees), to be used to specify the analytical method under which each tree in trees was generated (e.g. equal weights parsimony, maximum likelihood). Will be displayed as a legend beside each tree. A list of methods will be displayed beside an output tree as a legend; analyses associated with a tree will be given the CSS class thisAn; other analyses will bear the class notThisAn. Defaults to character(0), which suppresses this legend.

width, height

Numeric specifying the size of the plot in pixels

uniqueTrees

(optional) A list generated by unique(trees). Can be prepopulated to avoid time-intensive recalculation.

xMargins, yMargins

Numeric vectors of length 2 specifying, in pixels, the margin to be left at each side of the plot

textY

Numeric specifying how far to adjust the vertical position of text

Details

SVGCanvas objects are used to visualize character reconstructions on phylogenetic trees. The vizualizations are rendered as SVG elements that can be saved as stand-alone SVG files, or included in HTML documents.

If incorporated in an HTML vignette, Javascript and CSS can be used to style the output and enable users to interact with the visualizations.

Value

An object of class SVGCanvas

Author(s)

Martin R. Smith

Examples

{
## Not run: 
 # Generate multiPhylo object containing four trees, with first and last identical:
   trees <- structure(list(
     ape::rtree(10, br=NULL),
     ape::rtree(10, br=NULL),
     ape::rtree(10, br=NULL),
     NULL), class='multiPhylo')
   trees[[4]] <- trees[[1]]

   treesGeneratedBy <- c('rtree', 'rtree', 'rtree', 'duplication')

   canvas <- SVGCanvas(trees=trees,
                       outgroupTips='t1',
                       analysisNames=treesGeneratedBy,
                       width=300, height=300)

   PlotCharacterMapping(char = '0011----11',
                        stateLabels = c('Absent', 'Present'),
                        singleTree = trees[[1]],
                        legendText = 'This is printed on PNGs',
                        canvas = canvas,
                        svgFilename = 'tree_number_%s.svg')

  
## End(Not run)
}

TGuillerme/Inapp documentation built on Feb. 4, 2024, 7:26 a.m.