plot.pco: Plotting Routines For Principal Coordinates Ordinations

Description Usage Arguments Details Value Note Author(s) References Examples

View source: R/pco.R

Description

A set of routines for plotting, highlighting points, or adding fitted surfaces to PCOs.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## S3 method for class 'pco'
plot(x, ax = 1, ay = 2, col = 1, title = "", pch = 1, ...)
## S3 method for class 'pco'
points(x, which, ax = 1, ay = 2, col = 2, pch = 1, cex = 1, ...)
## S3 method for class 'pco'
plotid(ord, ids = seq(1:nrow(ord$points)), ax = 1, ay = 2,
    col = 1, ...)
## S3 method for class 'pco'
hilight(ord, overlay, ax = 1, ay = 2, title="", cols=c(2,3,4,5,6,7), 
    glyph=c(1,3,5), ...)
## S3 method for class 'pco'
chullord(ord, overlay, ax = 1, ay = 2, cols=c(2,3,4,5,6,7), 
    ltys = c(1,2,3), ...)
## S3 method for class 'pco'
density(ord, overlay, ax = 1, ay = 2, cols = c(2, 3, 4, 5,
    6, 7), ltys = c(1, 2, 3), numitr=100, ...)
## S3 method for class 'pco'
surf(ord, var, ax = 1, ay = 2, thinplate=TRUE, col = 2, labcex = 0.8,
    family = gaussian, grid=50, gamma=1, ...)
## S3 method for class 'pco'
thull(ord,var,grain,ax=1,ay=2,col=2,grid=50,nlevels=5,levels=NULL,
    lty=1,numitr=100,...)

Arguments

x

an object of class ‘pco’

ax

the dimension to use for the X axis

ay

the dimension to use for the Y axis

title

a title for the plot

which

a logical variable to specify points to be highlighted

ord

an object of class ‘pco’

overlay

a factor or integer vector to hilight or distinguish

cols

the sequence of color indices to be used

glyph

the sequence of glyphs (pch) to be used

ltys

the sequence of line types to be used

numitr

number of iterations to use in estimating the probability of obtaining the observed density

var

a variable to be surfaced

thinplate

a logical variable to control how the surface is fit: thinplate = TRUE (the default) fits a thinplate spline, thinplate = FALSE fits independent smooth splines. If you have too few data points you may have to specify thinplate-FALSE

family

controls the link function passed to ‘gam’: one of ‘gaussian’, ‘binomial’, or ‘poisson’

gamma

controls the smoothness of the fit from gam

grid

the number of X and Y points to use in establishing a grid for surf

ids

identifier labels for samples. Defaults to 1:n

col

color index for points or contours

labcex

size of contour interval labels

pch

plot character: glyph to plot

cex

character expansion factor: size of plotted characters

grain

the size of moving window to use in calculating the tensioned hull

nlevels

the number of contour intervals to draw on the tensioned hull

levels

specific levels to use in drawing the tensioned hull

lty

the line type to use in drawing the tensioned hull contours

...

arguments to pass to the plot function

Details

Function ‘plot’ produces a scatterplot of sample scores for the specified axes, erasing or over-plotting on the current graphic device. Axes dimensions are controlled to produce a graph with the correct aspect ratio.

Functions ‘points’, ‘plotid’, ‘hilight’, ‘chullord’, and ‘surf’ add detail to an existing plot. The axes specified must match the underlying plot exactly.

Function ‘plotid’ identifies and labels samples (optionally with values from a third vector) in the PCO, and requires interaction with the mouse: left button identifies, right button exits.

Function ‘points’ is passed a logical vector to identify a set of samples by color of glyph. It can be used to identify a single set meeting almost any criterion that can be stated as a logical expression.

Function ‘hilight’ is passed a factor vector or integer vector, and identifies factor values by color and glyph. By specifying values for arguments ‘cols’ and ‘glyph’ it is possible to control the sequence of colors and pch glyphs used in the hilight.

Function ‘chullord’ is passed a factor vector or integer vector, and plots a convex hull around all points in each factor class. By specifying values for arguments ‘cols’ and ‘ltys’ it is possible to control the sequence of colors and linetypes of the convex hulls.

Function ‘density’ calculates the fraction of points within the convex hull that belong to the specified type.

Function ‘surf’ calculates and plots fitted surfaces for logical or quantitative variables. The function employs the gam function to fit a variable to the ordination coordinates, and to predict the values at all grid points. The grid is established with the ‘expand.grid’ function, and the grid is then specified in a call to ‘predict.gam’. The predicted values are trimmed to the the convex hull of the data, and the contours are fit by ‘contour’. The default link function for fitting the GAMs is ‘gaussian’, suitable for unbounded continuous variables. For logical variables you should specify ‘family = binomial’ to get a logistic GAM, and for integer counts you should specify ‘family = poisson’ to get a Poisson GAM.

Value

Function ‘plotid’ returns a vector of row numbers of identified plots

Note

Previous versions of surf relied on the ‘interp’ function of package akima. The revised routine using predict.gam was suggested by Jari Oksanen as used in packageordisurf.

Author(s)

David W. Roberts [email protected]

References

http://ecology.msu.montana.edu/labdsv/R/labs/lab8/lab8.html

Examples

1
2
3
4
5
6
7
8
data(bryceveg)
data(brycesite)
dis.bc <- dsvdis(bryceveg,'bray/curtis')
pco.1 <- pco(dis.bc,5)
plot(pco.1)
points(pco.1,brycesite$elev>8000)
surf(pco.1,brycesite$elev)
## Not run: plotid(pco.1,ids=row.names(bryceveg))

Example output

Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-25. For overview type 'help("mgcv-package")'.
Loading required package: MASS
Loading required package: cluster

Attaching package: 'labdsv'

The following object is masked from 'package:stats':

    density


Family: gaussian 
Link function: identity 

Formula:
var ~ s(x, y)

Estimated degrees of freedom:
16.7  total = 17.73 

GCV score: 69475.24     
D^2 =  0.8544 

labdsv documentation built on May 30, 2017, 12:46 a.m.