Beta diversity ordinations


Beta diversity ordinations

Dataset

First, let's load some packages including HTSSIP.

library(dplyr)
library(ggplot2)
library(HTSSIP)

Also let's get an overview of the phyloseq object that we're going to use.

physeq_S2D2

Parsing the dataset

See HTSSIP introduction vignette for a description on why dataset parsing is needed.

Let's the parameters for parsing the dataset into individual treatment-control comparisons.

params = get_treatment_params(physeq_S2D2, c('Substrate', 'Day'))
params

We just need the parameters for each treatment, so let's filter out the controls. In this case, the controls are all '12C-Con'.

params = dplyr::filter(params, Substrate!='12C-Con')
params

Now, we will use an expression that will subset the phyloseq object into the comparisons that we want to make.

ex is the expression that will be used for pruning the phyloseq object

ex = "(Substrate=='12C-Con' & Day=='${Day}') | (Substrate=='${Substrate}' & Day == '${Day}')"
physeq_S2D2_l = phyloseq_subset(physeq_S2D2, params, ex)
physeq_S2D2_l

Calculating ordinations

Now, let's actually make ordinations of each treatment compared to the control. This will return a data.frame object for plotting.

# running in parallel
doParallel::registerDoParallel(2)
physeq_S2D2_l_df = SIP_betaDiv_ord(physeq_S2D2_l, parallel=TRUE)
physeq_S2D2_l_df %>% head(n=3)

Each specific phyloseq subset (treatment-control comparison) is delimited with the "phyloseq_subset" column.

physeq_S2D2_l_df %>% .$phyloseq_subset %>% unique

For clarity, I'm going edit these long strings to make them more readable.

physeq_S2D2_l_df = physeq_S2D2_l_df %>%
  dplyr::mutate(phyloseq_subset = gsub(' \\| ', '\n', phyloseq_subset),
                phyloseq_subset = gsub('\'3\'', '\'03\'', phyloseq_subset))
physeq_S2D2_l_df %>% .$phyloseq_subset %>% unique

OK, let's plot the data!

phyloseq_ord_plot(physeq_S2D2_l_df)

As you can see, the 'heavy' gradient fraction 'communities' for the labeled-treatments tend to diverge from the unlabeled gradient fraction communities, but the amount of divergence in dependent on substrate and time point.

Session info

sessionInfo()


Try the HTSSIP package in your browser

Any scripts or data that you put into this service are public.

HTSSIP documentation built on Sept. 14, 2019, 1:02 a.m.