PlotPrioritisation: Plot prioritisation

Description Usage Arguments Details Value Note Examples

Description

Ranking of sample plots by their contributions to the total biodiversity.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
getPlotPrior.JostDiver(t.community.matrix, lev = c("alpha", "beta", "gamma"),
  q = 1, order.by = c("sample", "rank", "diversity"))

getPlotPrior.PhyloAlpha(t.community.matrix, phylo.tree, taxa.match = TRUE,
  order.by = c("sample", "rank", "diversity"), ...)

getPlotPrior(cm.list, is.transposed = FALSE, tre.list = list(),
  taxa.match = TRUE, diversities = c("gamma0", "gamma1", "beta0", "beta1",
  "pd.alpha", "sp.rich"))

mergePlotPriorListOfDF(plot.prior.list, suffixes = c(), rm.prefix = TRUE)

plotPrioritisation(pp.df.list, at = c("rank", "diversity"), x.levels = c(),
  y.levels = c(), add.label = FALSE, label.digits = 1,
  guide = "colourbar", ...)

plotPrioritisation.Phyloseq(pp.df, attr.df, y2.id = "Elevation",
  y2.lab = "Elevation (m)", x.lab = "Amplicon dataset",
  y.lab = "Sample plot", grid.widths = c(8, 2), ...)

plotPrioritisation.NeatMap(pp.df, attr.df, y2.id = "Elevation",
  y2.lab = "Elevation (m)", x.lab = "Amplicon dataset",
  y.lab = "Sample plot", grid.widths = c(8, 3), ...)

Arguments

t.community.matrix

A transposed matrix from community matrix, where rows are plots (Use plots instead of subplots.), columns are OTUs.

lev

Level of diversity to be calculated. Will accept: 'alpha', 'beta', or 'gamma'.

q

Order of the diversity measure. Defaults to the Shannon case where q = 1.

order.by

How the result is ordered. Choose from 'sample', 'rank', or 'diversity'.

phylo.tree, ...

The parameters passed to phylo.alpha.

taxa.match

Logical, if taxa in phylogenies do not match OTUs in the community. If TRUE, as default, to use t.community.matrix and phylo.tree directly, otherwise to call match.phylo.comm before calculate phylogenetic alpha diversity.

cm.list

The list of community matrices.

is.transposed

If TRUE, then the community matrix is already transposed to be the valid input of vegdist. Default to FASLE to transpose.

tre.list

A list of phylo tree objects for 'pd.alpha' and 'sp.rich', corresponding to cm.list. Default to an empty list.

diversities

The vector of diversities used to compute plot prioritisation. The values are 'gamma0','gamma1','beta0','beta1','pd.alpha','sp.rich'. The first two are calculated by d, the last two by pd.

plot.prior.list

The output from getPlotPrior.

suffixes

The vector of suffixes added to distinguish colmun names merged by different data frames. Its length must equal to plot.prior.list.

pp.df.list

The output from mergePlotPriorListOfDF.

at

The values of heatmap, choose from "rank" or "diversity".

pp.df

One element of the 'rank' list from mergePlotPriorListOfDF.

attr.df

Environmental meta-data. Rows are samples, and must include all rownames from pp.df

y2.id, y2.lab

The column of attr.df used to plot the 2nd figure on the right side, default to "Elevation".

grid.widths

A unit vector giving the width of each two columns, used by plot_grid in cowplot and default to c(8, 2).

row.id

What row names are representing.

Details

getPlotPrior.JostDiver computes plot prioritisation by Jost diversity calculated from vegetarian d. It uses a greedy algorithm to remove plots sequentially so as to minimize the loss of diversity among the remaining plots, which always chooses the 1st plot if there are multi-results in each prioritisation loop. Rank 1 is the most important plot and removed at the last, n is the least important and removed in the beginning.

getPlotPrior.PhyloAlpha calculates plot prioritisation by phylogenetic alpha diversity from phylo.alpha. It also can return the ranks based on species richness (SR), but they may be different to ranks calculated from getPlotPrior.JostDiver using gamma0 (also species richness).

getPlotPrior is a generic function including both getPlotPrior.JostDiver and getPlotPrior.PhyloAlpha, and it also handles multiple communities.

mergePlotPriorListOfDF merges a list of data frames produced by getPlotPrior into one. Their columns must contain 'rank' and 'diversity'.

plotPrioritisation produces the list of ggHeatmap given a list of output from mergePlotPriorListOfDF.

plotPrioritisation.Phyloseq produces one clusterd heatmap using phyloseq plot_heatmap and attaches an additional plot of a selected attribute from environmental meta-data, such as Elevation.

plotPrioritisation.NeatMap produces one clusterd heatmap using NeatMap and attaches an additional plot of a selected attribute from environmental meta-data, such as Elevation.

Value

A data frame with 2 columns: rank, diversity. Rank 1 is the most important plot, n is the least important, and row.names are plot names. For example,

rank diversity
CM30c39 28 1845.785714
CM30c44 27 1875.888889
CM31a5 26 1899.653846

Note

Use theme_set(theme_bw(base_size=8)) to remove the grey backgroud.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
plot.prior.g1 <- getPlotPrior.JostDiver(t.community.matrix, lev="gamma", q=1)

phylo.alpha <- getPlotPrior.PhyloAlpha(t.community.matrix, phylo.tree)

plot.prior.list <- getPlotPrior(cm.list, is.transposed=FALSE, diversities=c("gamma1","beta1"))
plot.prior.list <- getPlotPrior(cm.list, is.transposed=FALSE, tre.list=tre.list, diversities=c("gamma1","beta1","pd.alpha","sp.rich"))
pp.df.list <- mergePlotPriorListOfDF(plot.prior.list)

heatmap.list <- plotPrioritisation(pp.df.list, add.label=T)

hm.elv <- plotPrioritisation.Phyloseq(pp.df.list[["rank"]][[1]], env.plot, grid.widths = c(10,2))
plot(hm.elv$heatmap)

hm.elv <- plotPrioritisation.NeatMap(pp.df.list[["rank"]][[1]], env.plot, grid.widths = c(10,2))
plot(hm.elv$heatmap)

walterxie/ComMA documentation built on May 3, 2019, 11:51 p.m.