aPCoA (version 1.0)

aPCoA: Covariate Adjusted PCoA Plot

Description

Adjusted confounding covariates to show the effect of the primary covariate in a PCoA plot. This method is designed for non-Euclidean distance. This function will plot the original PCoA plot along with the covariate adjusted PCoA plot.

Usage

aPCoA(formula,data,maincov,drawEllipse=TRUE,drawCenter=TRUE)

Arguments

formula

A typical formula such as Y~ A, but here Y is a dissimilarity distance. The formula has the same requirements as in adonis function of the vegan package.

data

A dataset with the rownames the same as the rownames in distance. This dataset should include both the confounding covariate and the primary covariate.

maincov

the covariate of interest in the dataset, must be a factor

drawEllipse

Do you want to draw the 95% confidence elipse for each cluster?

drawCenter

Do you want to show the connection between cluster center (medoid) and cluster members?

Value

Two PCoA plots. One is the original one, while the other is the PCoA plot after adjusting for the confounding covariate.

plotMatrix

The matrix for plotting the adjusted PCoA plot.

Examples

Run this code
# NOT RUN {
library(mvabund)
library(vegan)
library(aPCoA)
data("Tasmania")
data<-data.frame(treatment=Tasmania$treatment,block=Tasmania$block)
bray<-vegdist(Tasmania$abund, method="bray")
rownames(data)<-rownames(as.matrix(bray))
opar<-par(mfrow=c(1,2),
          mar=c(3.1, 3.1, 3.1, 5.1),
          mgp=c(2, 0.5, 0),
          oma=c(0, 0, 0, 4))
result<-aPCoA(bray~block,data,treatment)
par(opar)
# }

Run the code above in your browser using DataCamp Workspace