View source: R/compareGroups.R
compareGroups | R Documentation |
The function allows to compare richness, evenness, alpha diversity and beta diversity across groups, where beta diversity can be assessed with both a Bray Curtis distribution or overdispersion from a Dirichlet-Multinomial distribution fit. By default, groups are subsampled to the same sample number, for this reason the output of the same run can differ. To switch off this behaviour, subsample can be set to false. Chao1 and Shannon diversity are computed with vegan. The Taylor law is computed taxon-wise as the slope of the regression line for the logarithm of the mean abundance of taxa and the logarithm of the variance of taxa.
compareGroups( abundances, property = "beta", method = "dissim", groups = c(), colors = c(), colorMap = NULL, plot.type = "pergroup", avg = "none", all = FALSE, noSameGroup = TRUE, rowNorm = FALSE, subsample = TRUE, xlab = "", pvalViz = FALSE, pAdjMethod = "BH", returnValues = FALSE )
abundances |
a matrix with taxa as rows and samples as columns |
property |
richness (Chao1), evenness (Sheldon), alpha (alpha-diversity with Shannon index), beta (beta-diversity), taylor (slope of the Taylor law) |
method |
for beta-diversity, dissim (Bray Curtis dissimilarities) and DM (estimation of theta with package dirmult) are supported |
groups |
group membership vector with as many entries as samples in abundances |
colors |
optional color vector with as many entries as (unique) groups (only for plot.type pergroup) |
colorMap |
optional color map with a color for a metadata value, required for color legend (only for plot.type pergroup) |
plot.type |
pergroup (plot property per group; this is the only plot type available for richness, evenness, alpha and beta with DM) and intravsinter (plot property for all within-group samples versus all samples) |
avg |
none, mean or median (average group property with the selected averaging method, does not work for method DM) |
all |
include the beta diversity for all samples |
noSameGroup |
for beta diversity with method dissim: only between-group pairs are used to calculate the beta diversity for all samples |
rowNorm |
for beta diversity with method dissim: normalize the abundances row-wise |
subsample |
subsample groups randomly to have the same sample number in each group; for plot type intravsinter, it equalises in additon the number of pairs within and between groups |
xlab |
the x axis label |
pvalViz |
if true and avg is set to none and plot.type is pergroup, Wilcoxon p-values are displayed on the violin plot using function stat_compare_means in R package ggpubr |
pAdjMethod |
multiple testing correction method to use for p-value plotting (values are those accepted by p.adjust) |
returnValues |
if true, return properties |
if returnValues is true, properties are returned
data("ibd_taxa") data("ibd_metadata") groups=as.vector(ibd_metadata$Diagnosis) compareGroups(ibd_taxa,groups=groups,property="alpha",pvalViz = TRUE) data("floresgut_taxa") data("floresgut_metadata") groups=floresgut_metadata$host_subject_id diet.col=makeColorsGivenMetadata(metadataItem=floresgut_metadata$diet,groups=groups) compareGroups(floresgut_taxa,groups=groups,colors=diet.col$colors,colorMap=diet.col$colormap) age=floresgut_metadata$age age.col=makeColorsGivenMetadata(metadataItem=age,groups=groups,binning="equaldist",numBins=10) col=age.col$colors compareGroups(floresgut_taxa,groups=groups,property="alpha",colors=col,colorMap=age.col$colormap)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.