pcoa.calc: Principal Coordinates Analysis (PCoA)

View source: R/pcoa.calc.R

pcoa.calcR Documentation

Principal Coordinates Analysis (PCoA)

Description

This function performs principal coordinates analysis.

Usage

pcoa.calc(object, distMethod = "Euclidean", binaryChs = NULL,
               nominalChs = NULL, ordinalChs = NULL)

Arguments

object

an object of class morphodata.

distMethod

the distance measure to be used. This must be one of: "Euclidean", "Manhattan", "Minkowski", "Jaccard", "simpleMatching", or "Gower". See details.

binaryChs, nominalChs, ordinalChs

names of categorical ordinal, categorical nominal (multistate), and binary characters. Needed for Gower's dissimilarity coefficient only, see details.

Details

The pcoa.calc function performs principal coordinates analysis using the cmdscale function from package stats. Principal coordinates analysis estimates coordinates for a set of objects in a space. Distances among objects is approximationy of the dissimilarities, based on any similarity or distance coefficient.

Various measures of distance between the observations (rows) are applicable: (1) coefficients of distance for quantitative and binary characters: "Euclidean", "Manhattan", "Minkowski"; (2) similarity coefficients for binary characters: "Jaccard" and simple matching ("simpleMatching"); (3) coefficient for mixed data: ("Gower").

The Gower's dissimilarity coefficient can handle different types of variables. Characters have to be divided into four categories: (1) quantitative characters, (2) categorical ordinal characters, (3) categorical nominal (multistate) characters, and (4) binary characters. All characters are considered to be quantitative characters unless otherwise specified. Other types of characters have to be explicitly specified. To mark characters as ordinal, nominal, or binary, enumerate them by names using ordinalChs, nominalChs, and binaryChs arguments, respectively.

Value

an object of class pcoadata with the following elements:

objects
ID IDs of each row of scores object.
Population population membership of each row of scores object.
Taxon taxon membership of each row of scores object.
scores ordination scores of cases (objects, OTUs).
eigenValues

eigenvalues of principal coordinates.

eigenvaluesAsPercent

eigenvalues as percent, percentage of their total sum.

cumulativePercentageOfEigenvalues

cumulative percentage of eigenvalues.

groupMeans

data.frame containing the means for the taxa.

distMethod

used distance measure.

rank

number of possitive eigenvalues.

Examples

data(centaurea)

pcoRes = pcoa.calc(centaurea, distMethod = "Manhattan")

summary(pcoRes)

plotPoints(pcoRes, axes = c(1,2), col = c("red", "green", "blue", "black"),
  pch = c(20,17,8,21), pt.bg = "orange", legend = TRUE, legend.pos = "bottomright")

# using Gower's method
data = list(
    ID = as.factor(c("id1","id2","id3","id4","id5","id6")),
    Population = as.factor(c("Pop1", "Pop1", "Pop2", "Pop2", "Pop3", "Pop3")),
    Taxon = as.factor(c("TaxA", "TaxA", "TaxA", "TaxB", "TaxB", "TaxB")),
    data = data.frame(
     stemBranching = c(1, 1, 1, 0, 0, 0),  # binaryChs
     petalColour = c(1, 1, 2, 3, 3, 3),  # nominalChs; 1=white, 2=red, 3=blue
     leaves = c(1,1,1,2,2,3), # nominalChs; 1=simple, 2=palmately compound, 3=pinnately compound
     taste = c(2, 2, 2, 3, 1, 1),   # ordinal; 1=hot, 2=hotter, 3=hottest
     stemHeight = c(10, 11, 14, 22, 23, 21),         # quantitative
     leafLength = c(8, 7.1, 9.4, 1.2, 2.3, 2.1)  )   # quantitative
)
attr(data, "class") = "morphodata"

pcoaGower = pcoa.calc(data, distMethod = "Gower", binaryChs = c("stemBranching"),
                      nominalChs = c("petalColour", "leaves"), ordinalChs = c("taste"))

plotPoints(pcoaGower, axes = c(1,2), col = c("red","green"),
           pch = c(20,17), pt.bg = "orange", legend = TRUE, legend.pos = "bottomright")

MorphoTools2 documentation built on March 7, 2023, 6:18 p.m.