library("mvarVis")
library("vegan")
library("ggplot2")

coldf

data(coldf)
sample_data <- data.frame(Color = rownames(coldf),
                          Depth = rowSums(coldf),
                          row.names = rownames(coldf))
X <- list(fmla = formula("coldf ~ ."), data = sample_data)
coldf_cca <- ordi(X, rows_annot = sample_data, method = "vegan_cca")

# compare with usual cca
plot(vegan::cca(coldf ~ ., data = sample_data))
plot_mvar(coldf_cca, "text", col = "Color", size = 6) + 
  scale_colour_manual(name = "Color", values = rownames(coldf))
coldf_cca@table$species <- NULL
plot_mvar(coldf_cca, "text", col = "Color", size = 6) + 
  scale_colour_manual(name = "Color", values = rownames(coldf))

Isomap

data(BCI)
dis <- vegdist(BCI, method = "euclidean")
bci_isomap <- ordi(dis, method = "isomap", k = 10)
plot_mvar(bci_isomap, "text")

# or, we could have just passed in the data frame and given a distance
bci_isomap_2 <- ordi(BCI, method = "isomap", dist_method = "bray", k = 10)
plot_mvar(bci_isomap_2, "text")

cca

data(varespec)
data(varechem)

cca_fmla <- formula("varespec ~ Al + P * (K + Baresoil)")
X <- list(fmla = cca_fmla, data = varechem)
vare_cca <- ordi(X, method = "vegan_cca", rows_annot = varespec[, 1:10])
plot_mvar(vare_cca, col = "Callvulg")

rda

data(dune)
data(dune.env)
X <- list(fmla = formula("dune ~ Manure"), data = dune.env)
dune_rda <- ordi(X, method = "rda")
plot_mvar(dune_rda, "text")

decorana

vare_decorana <- ordi(varespec, method = "decorana")
plot_mvar(vare_decorana)

CCorA

# Taken from the vegan ccora help page
data(mite)
group.1 <- c(1,2,4:8,10:15,17,19:22,24,26:30)
group.2 <- c(3,9,16,18,23,25,31:35)
# Separate Hellinger transformations of the two groups of species 
mite.hel.1 <- decostand(mite[,group.1], "hel")
mite.hel.2 <- decostand(mite[,group.2], "hel")
rownames(mite.hel.1) = paste("S",1:nrow(mite),sep="")
rownames(mite.hel.2) = paste("S",1:nrow(mite),sep="")

mite_ccora <- ordi(list(mite.hel.1, mite.hel.2), method = "CCorA", 
                   cols_annot = list(t(mite.hel.2), t(mite.hel.1)))
plot_mvar(mite_ccora, col = "S68")


krisrs1128/mvarVis documentation built on Oct. 13, 2019, 11:14 p.m.