ggpcoa: '"PCoA"' ordination plot

Description Usage Arguments Details Value Author(s) Examples

Description

Output pcoa ordination plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ggpcoa(ord, ordata, groups = NULL, axes = c(1, 2), obslab = FALSE,
  moblabs = NULL, obssize = 2, obscol = "black", obspch = 16,
  obsFonts = "serif", obsface = "plain", spe = TRUE, msplabs = NULL,
  spearrow = 0.2, spelab = TRUE, spmapsize = NULL, spaline = 1,
  spalwd = 0.5, spacol = "grey30", sprotate = NULL, spesize = 4,
  specol = "red", spepch = 16, speFonts = "serif", speface = "plain",
  envs = NULL, mflabs = NULL, farrow = 0.2, fmapsize = NULL,
  faline = 1, falwd = 0.5, facol = "blue", fzoom = 1, frotate = NULL,
  fsize = 5, fcol = "blue", fFonts = "serif", fface = "plain",
  ellipse = FALSE, ellprob = 0.95, cirlwd = 1, cirline = 2)

Arguments

ord

An object produced by cmdscale.

ordata

An dataframe that is provided to function wascores.

groups

An grouping factor, its length is the same as the row number of the ordination dataframe.

axes

Axes shown.

obslab

A logical value, obslab = FALSE(The row variables are displayed as points), obslab = TRUE(The row variables are displayed as texts).

moblabs

A vector of strings, rename the row variable names displayed.

obssize

The size of row variables.

obscol

The colour of row variables.

obspch

The point shape of row variables.

obsFonts

The family of row variables.

obsface

The fontface of row variables.

spe

A logical value, whether the column variables are displayed.

msplabs

A vector of strings, rename the col variable names displayed.

spearrow

Arrowhead length of col variables.

spelab

A logical value, spelab = FALSE(The col variables are displayed as points), spelab = TRUE(The col variables are displayed as texts).

spmapsize

Numeric value, the size of col variable labels is mapped by the length of arrowhead.

spaline

Type of arrowhead segment.

spalwd

Numeric value, the width of arrowhead segment.

spacol

The colour of arrowhead segment.

sprotate

Numeric value, rotation angle of col variable labels.

spesize

Numeric value, the size of col variable labels or points.

specol

The colour of col variable labels or opoints.

spepch

Type of col variable labels or points .

speFonts

The family of col variable labels.

speface

The fontface of col variable labels.

envs

Dataframe fitted.

mflabs

A vector of strings, rename the fitted variable names displayed.

farrow

Arrowhead length of fitted variables.

fmapsize

Numeric value, the size of fitted variable labels is mapped by the length of arrowhead.

faline

Arrowhead type of fitted variables.

falwd

Numeric value, arrowhead width of fitted variables.

facol

Arrowhead colour of fitted variables.

fzoom

Numeric value, scaling arrow length.

frotate

Numeric value, rotation angle of fitted variable labels.

fsize

Numeric value, the size of fitted variable labels or points.

fcol

The colour of fitted variable labels or opoints.

fFonts

The family of fitted variable labels.

fface

The fontface of fitted variable labels.

ellipse

A logical value, whether confidence ellipses are displayed.

ellprob

Numeric value, confidence interval.

cirlwd

Numeric value, line width of ellipse.

cirline

Line type of ellipse.

Details

Control of some parts is put in the function. Theme of figure can be set by theme of ggplot2.

Value

Returns a ggplot object.

Author(s)

Dongya Wang <wdy91617@163.com>

Examples

 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
26
27
28
29
30
31
32
33
data(Envs)
library(vegan)
# get group factor
Env.w <- hclust(dist(scale(Envs)), "ward.D")
gr <- cutree(Env.w , k=4)
grl <- factor(gr)

# Compute PCoA
Env.bray <- vegdist(Envs)
Env.pcoa <- cmdscale(Env.bray, eig=TRUE)
summary(Env.pcoa)

# Produce a plot 
ggpcoa(Env.pcoa, ordata = Envs)

# Add a group
ggpcoa(Env.pcoa, ordata = Envs, group = grl) 

# Set a theme 
require(ggplot2)
ggpcoa(Env.pcoa, ordata = Envs, group = grl, fcol = "white", facol = "white") + theme_dark()

# Remove the arrow
ggpcoa(Env.pcoa, ordata = Envs, group = grl, spearrow = NULL)

# Modify legend title, group color and point shape
ggpcoa(Env.pcoa, group = grl, ordata = Envs, spearrow = NULL) + 
  scale_color_manual(name = "Groups",values = c("red2", "purple1", "grey20","cyan")) +
  scale_shape_manual(name = "Groups",values = c(8,15,16,17))

#Add confidence ellipses
ggpcoa(Env.pcoa, ordata = Envs, group = grl, spearrow = NULL, ellipse = TRUE) +
  scale_colour_hue(l = 70, c = 300)

wdy91617/ggords documentation built on May 24, 2019, 2:47 p.m.