Introduction and initialization

This is an R Markdown file containing code to parse the results of a dada2 analysis into phyloseq for further analysis. It is separated into chunks that may be run independently by pressing the play button. You will need 3 files in the same location in order to run this pipeline successfully:

Recommended use: Set the individual chunks until you are content with the ouput, then knit the whole document into a PDF/html, so you have a full record of a successful run.

Optional custom Taxonomy file

A custom taxonomy file may be provided instead of using the taxonomy output from dada2. This may be used to supply taxonomy derived e.g. from BLAST searches of the ASVs. Custom taxonomy files must be tab-delimited text with as many rows as the original, colum headers (for all columns except for the first column). For example:

Kingdom Phylum Class Order Family Genus Species
ESV1 Kingdomx Phylumx Classx Orderx Familyx Genusx Speciesx
ESV2 Kingdomy Phylumy Classy Ordery Familyy Genusy Speciesy
ESV3 Kingdomz Phylumz Classz Orderz Familyz Genusz Speciesz
… ESVn Kingdomy Phylumy Classy Ordery Familyy Genusy Speciesy

Friendly warning: Parsing the results of a BLAST search into this format may require some effort.

Descriptor table

‘descriptors.txt’ should be a tab-delimited .txt table describing the samples. It must have the same length and order as the samples in seqtab_nochim.rds. To check the order and length of samples in seqtab_nochim.rds and generate a template to fill out, you may run the chunk below with “optional_sample_check” set to “TRUE”.

Any number of descriptors is possible. The sample names may be retained as one descriptor, but this is not necessary, as they will be added during parsing. For example, if there are 4 samples (order: s1, s2, s3, s4), the txt file could look as follows:

Subject Species Time
Kar1 A.thaliana 24hpi
Kar1 A.thaliana 72hpi
Mec2 S.tuberosum 24hpi
Mec3 S.tuberosum 24hpi

Finally, the file should end with an empty line, since it may throw an error otherwise. However, this is usually not a serious problem.

If you choose to use the blank file, you MUST retain the original order of the samples!

Setup

This chunk also loads required packages and defines the location of the input files. It requires the correct path as input, and allows setting the pruning of control samples and choosing generation of a phylogenetic tree. Beware: The generation of a phylogenetic tree may take several days for >1000 sequences, it is therefore recommended to only use this feature for the final analysis or small sample sets. This scricpt assumes the packages Biostrings, dada2, DECIPHER, ggplot2, ggsci, phangorn, phyloseq and stringr to be installed.

# CHANGE ME to the directory that contains 'seqtab_nochim.rds'
path = "Nems_DADA2_results_260821"

# CHANGE ME to TRUE to list all samples and generate an empty metadata file 
optional_sample_check = TRUE

# CHANGE ME to TRUE to update cuphyr
update_cuphyr = TRUE

# Initiate by loading packages and setting knit options
################# NO CHANGES NECESSARY BELOW #################
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(root.dir = paste0(path))
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(warning = FALSE)

if (update_cuphyr) {
  devtools::install_github("simeross/cuphyr")
}

# Sequence and microbiome specific libraries
library(dada2)
library(Biostrings)
library(DECIPHER)
library(cuphyr)
# The export of phyloseq objects to a BIOM format and the generation of fancier 
# ordination plots require the phyloseq-extended package. The first command 
# installs the package that is currently on the dev brach of the author's 
# repository, the second command sources some extra functions, including the 
# better ordination plot implementation.
remotes::install_github("mahendra-mariadassou/phyloseq-extended", ref = "dev")
source("https://raw.githubusercontent.com/mahendra-mariadassou/phyloseq-extended/master/load-extra-functions.R" )

library(phyloseq)
#library(SIAMCAT)

# Phylogeny libraries
library(phangorn)
library(ape)

# Plotting and figure export
library(gridExtra)
library(viridis)
library(ggpubr)
library(cowplot)

# Tidyverse
library(tidyverse)
library(stringr)

# Various packages for specific analysis
library(readxl)
library(openxlsx)
library(ggpmisc)
library(betareg)
library(BBmisc)
library(aod)
library(betareg)
#install.packages('MicrobiomeStat')
library(MicrobiomeStat)


# Checks whether output path exists and creates it if not. Throws warning if 
# directory exists.
outp <- paste0(path,"/analysis_output")
dir.create(file.path(outp))

if (optional_sample_check) {
  seqtabcheck <- readRDS(paste0(path,"/seqtab_nochim.rds")) 
  samps <- rownames(seqtabcheck)
  lensamps <- length(samps)
  blankcol <- vector(mode = "character", length = lensamps)
  blanktable <- data.frame(SampleIDs = samps, ExampleProperty1 = blankcol, 
                           ExampleProperty2 = blankcol, 
                           ExampleProperty3 = blankcol)
  write.table(blanktable, file = paste0(path, "/descriptors_blank.txt"), 
              sep = "\t", row.names = F)
  cat("'seqtab_nochim.rds' contains samples in the following order:\n", 
      samps, "\nThe number of samples in the file is:", lensamps, sep = "\n")
  rm(optional_sample_check, seqtabcheck, samps, 
     lensamps, blankcol, blanktable, update_cuphyr)
  }else{rm(optional_sample_check, update_cuphyr)}
## 'seqtab_nochim.rds' contains samples in the following order:
## 
## 1-Nem
## 10-Nem
## 11-Nem
## 12-Nem
## 13-Nem
## 14-Nem
## 15-Nem
## 16-Nem
## 17-Nem
## 18-Nem
## 2-Nem
## 3-Nem
## 4-Nem
## 5-Nem
## 6-Nem
## 7-Nem
## 8-Nem
## 9-Nem
## NegativK-4-Nem
## Positivkontroll-Nem
## 
## The number of samples in the file is:
## 20

Parameters

This chunk allows the adjustment of several parameters, such as setting the pruning of control samples based on keywords, requiring that a phylogenetic tree be provided or generated, defining a minimum ASV count and providing an alternative taxonomy.

# Dedicated environment containing all global analysis settings for better
# overview and collected export of settings
parameters <- new.env()

# CHANGE ME to 'TRUE' to remove control samples from the analysis or 'FALSE' to
# analyse all samples.
parameters$prune_controls = "TRUE"
# CHANGE ME to a list of unique identifiers that only occur in the names of
# samples you do NOT want to analyse. Common examples are provided.
parameters$controls = c("NegativK-4-Nem", "Vann", "Neg", "Positivkontroll-Nem", "Contr",
    "POSK")

# CHANGE ME to 'TRUE' to remove certain taxonomic groups from the analysis by
# name. This is useful to exclude non-target organisms or noise from organelles
# such as Chloroplasts and Mitochondria. It is recommended to first look at all
# data before using this setting.
parameters$prune_noise_taxgroups = "FALSE"
# CHANGE ME to define the taxonomic groups to be removed as noise.
parameters$noise_taxgroups = c("Chloroplast", "Mitochondria")

# CHANGE ME to a number of ASV counts [~reads] that analyzed samples should
# minimally have. Samples with lower ASV counts than 'minread' will be pruned.
# Set to 0 to not prune any samples.
parameters$minASVcount = 3000

# CHANGE ME to 'TRUE', if you want to provide a custom taxonomy table instead
# of using the default dada2 output ('taxa.rds').
parameters$customTax = "TRUE"
# CHANGE ME to the location of the custom taxonomy file. This only matters if
# parameters$customTax='TRUE', otherwise it will be ignored.
parameters$taxfile = "Nems_DADA2_results_260821/custom_BLAST_taxonomy_nt.txt"

# CHANGE ME to 'TRUE' to generate a phylogenetic tree. This process takes a
# long time depending on the number of sequences (up to days for thousands).
# If a tree is provided as 'phylotree.rds' in 'path', then it will be used
# regardless of the value of 'parameters$maketree'
parameters$maketree = "FALSE"

# CHANGE ME to 'TRUE' to root the used phylogenetic tree (if one exists) on the
# leaf with the longest branch (outgroup). This makes analyses that rely on the
# phylogenetic tree reproducible instead of picking a random leaf as root when
# calculating UNIFRAC distances. Implementation based on
# http://john-quensen.com/r/unifrac-and-tree-roots/ and answers in
# https://github.com/joey711/phyloseq/issues/597
parameters$roottree = "TRUE"

## CHANGE ME to 'TRUE' to export all generated phyloseq objects as .biom
## objects
parameters$biom_export = "FALSE"

Parsing input data

This chunk loads the input data into a usable format.This chunk does not require any user inputs. If no phylogenetic tree with the name ‘phylotree.rds’ was provided and ‘parameters$maketree=“TRUE”’, it will be calculated here. The phylogenetic tree is necessary for certain plots that incorporate ‘true’ taxonomic relationships beyond the annotations, such as PCoA.

############### NO NEED FOR CHANGES BELOW ############### Make dedicated
############### environments to contain temporary values and manage other
############### objects
tmp <- new.env()
plots <- new.env()
set <- new.env()

# Read in variables
tmp$seqtabp <- readRDS(paste0(path, "/seqtab_nochim.rds"))
if (parameters$customTax == "TRUE") {
    tmp$taxap <- read.delim(parameters$taxfile, header = TRUE, sep = "\t")
    rownames(tmp$taxap) <- colnames(tmp$seqtabp)
    tmp$taxap <- as.matrix(tmp$taxap)
} else {
    tmp$taxap <- readRDS(paste0(path, "/taxa.rds"))
}
tmp$samp_table <- read.delim(paste0(path, "/descriptors.txt"), header = TRUE, sep = "\t")
tmp$samp_list <- rownames(tmp$seqtabp)

# Check if descriptors has the same samples as seqtabp
if (length(tmp$samp_table[, 1]) != length(tmp$samp_list)) {
    stop("There are ", length(tmp$samp_table[, 1]), " samples in 'descriptors.txt', but ",
        length(tmp$samp_list), " samples in 'seqtab_nochim.rds'. Please make sure that the correct samples 
    are contained in descriptors.txt.
       
    You may use 'optional_sample_check <- TRUE' in the first chunk to generate an 
    empty template for 'descriptors.txt'")
} else if (!identical(tmp$samp_table[, 1], tmp$samp_list)) {
    warning("Warning: The samples in 'descriptors.txt' do not have the same names 
          or order as the samples in 'seqtab_nochim.rds'. This may be fine if 
          abbreviated names were used or the sample names are not contained in 
          the first column of 'descriptors.txt'. Double-checking never hurts!")
}


# generate phylogenetic tree of ASVs only if there is no file called
# 'phylotree.rds' in the working directory and 'parameters$maketree' is 'TRUE'
if (!file.exists(paste0(path, "/phylotree.rds"))) {
    if (parameters$maketree == "TRUE") {
        tmp$ASVs <- getSequences(tmp$seqtabp)
        names(tmp$ASVs) <- tmp$ASVs
        tmp$ASV_align <- AlignSeqs(DNAStringSet(tmp$ASVs), anchor = NA)
        tmp$ASV_phang <- phyDat(as(tmp$ASV_align, "matrix"), type = "DNA")
        tmp$dm <- dist.ml(tmp$ASV_phang)
        tmp$treeNJ <- NJ(tmp$dm)
        tmp$fit <- pml(tmp$treeNJ, data = tmp$ASV_phang)
        tmp$fitGTR <- update(tmp$fit, k = 4, inv = 0.2)
        tmp$fitGTR <- optim.pml(tmp$fitGTR, model = "GTR", optInv = TRUE, optGamma = TRUE,
            rearrangement = "stochastic", control = pml.control(trace = 0))
        saveRDS(tmp$fitGTR, file = paste0(path, "/phylotree.rds"))
    }
}

## parse into phyloseq object
row.names(tmp$samp_table) <- tmp$samp_list
if (file.exists(paste0(path, "/phylotree.rds"))) {
    tmp$treep <- readRDS(paste0(path, "/phylotree.rds"))
    p <- phyloseq(otu_table(tmp$seqtabp, taxa_are_rows = FALSE), sample_data(tmp$samp_table),
        tax_table(tmp$taxap), phy_tree(tmp$treep$tree))
} else {
    p <- phyloseq(otu_table(tmp$seqtabp, taxa_are_rows = FALSE), sample_data(tmp$samp_table),
        tax_table(tmp$taxap))
}

## Adding nucleotide info and giving sequences ASV## identifiers
tmp$ASV_sequences <- Biostrings::DNAStringSet(taxa_names(p))
taxa_names(p) <- paste0("ASV", seq(ntaxa(p)))
names(tmp$ASV_sequences) <- taxa_names(p)
p <- merge_phyloseq(p, tmp$ASV_sequences)

## optional pruning
if (parameters$prune_controls == "TRUE") {
    if (!is.null(parameters$controls)) {
        tmp$samp_clean <- tmp$samp_list[!tmp$samp_list %in% grep(paste0(parameters$controls,
            collapse = "|"), tmp$samp_list, value = T)]
        tmp$contr_pruned <- setdiff(tmp$samp_list, tmp$samp_clean)
        ps <- prune_samples(tmp$samp_clean, p)
        # Physeq object for Just controls
        ps.contr <- prune_samples(tmp$contr_pruned, p)
        ps.contr <- prune_taxa(taxa_sums(ps.contr) > 0, ps.contr)
        ps.transcontr <- transform_sample_counts(ps.contr, function(ASV) ASV/sum(ASV))

        message(cat("\n", "Number of control samples that were pruned and will not be analysed:\n",
            length(tmp$samp_list) - length(tmp$samp_clean), "\n", "The following controls were pruned:\n",
            tmp$contr_pruned, "The controls are contained in a separate phyloseq object: ps.contr",
            "\n", sep = "\n"))
    } else {
        warning(cat("\n\nparameters$prune_controls is TRUE but 'parameters$controls' is empty. 
    No samples were pruned.\n\n"))
    }
} else {
    ps <- p
}
## 
## 
## Number of control samples that were pruned and will not be analysed:
## 
## 2
## 
## 
## The following controls were pruned:
## 
## NegativK-4-Nem
## Positivkontroll-Nem
## The controls are contained in a separate phyloseq object: ps.contr
# Prune ASVs defined as noise
if (parameters$prune_noise_taxgroups == "TRUE") {
    tmp$ps_taxlvls <- colnames(tax_table(ps))
    tmp$noise_ASVs <- character(0)
    for (lvl in tmp$ps_taxlvls) {
        tmp$noise_ASVs <- c(tmp$noise_ASVs, cuphyr::list_subset_ASVs(physeq = ps,
            subv = parameters$noise_taxgroups, taxlvlsub = lvl))
    }
    tmp$noise_ASVs <- unique(tmp$noise_ASVs)
    tmp$no_noise_ASVs <- colnames(otu_table(ps))
    tmp$no_noise_ASVs <- setdiff(tmp$no_noise_ASVs, tmp$noise_ASVs)
    if (length(tmp$noise_ASVs) > 0) {
        ps <- prune_taxa(tmp$no_noise_ASVs, ps)
        tmp$no_noise_ps <- ps
        cat(length(tmp$noise_ASVs), "ASVs were pruned because they belonged to the following 
        taxonomic groups:\n")
        cat(parameters$noise_taxgroups, "\n", sep = "\n")
    } else {
        cat("No ASVs were recognized as belonging to the following taxonomic groups 
        defined as noise:\n")
        cat(parameters$noise_taxgroups, "\n", sep = "\n")
    }
}

# Prune samples with fewer than reads than minASVcount
if (parameters$minASVcount > 0) {
    tmp$samp_pruned <- names(which(sample_sums(ps) < parameters$minASVcount))
    ps <- prune_samples(sample_sums(ps) >= parameters$minASVcount, ps)
    if (length(tmp$samp_pruned) > 0) {
        cat("The following samples were pruned because ASV counts were lower than",
            parameters$minASVcount, ":\n")
        cat(tmp$samp_pruned, "\n", sep = "\n")
    }
}

# Remove 0 count ASVs (e.g. control ASVs that remain) from the base object
ps <- prune_taxa(taxa_sums(ps) > 0, ps)
sample_data(ps)[["ndvi"]] <- as.numeric(sample_data(ps)[["ndvi"]])


# Transformed per sample (per-sample relative abundance)
ps.trans <- transform_sample_counts(ps, function(ASV) ASV/sum(ASV))

# Read descriptor values as numeric
sample_data(ps.trans)[["ndvi"]] <- as.numeric(sample_data(ps.trans)[["ndvi"]])
sample_data(ps.trans)[["ndvi_july"]] <- as.numeric(sample_data(ps.trans)[["ndvi_july"]])

# Get a tbl of the base object for easier access in some phyloseq-independent
# analyses. Takes some seconds, potentially up to minutes.
ps_tbl <- as_tibble(psmelt(ps))
ps_trans_tbl <- as_tibble(psmelt(ps.trans))

# Condensing to Abundance per Genus and Sample
genus_abundance_tbl_per_sample <- ps_trans_tbl %>%
    group_by(Genus, Sample) %>%
    mutate(Genus_Sample_Abundance = sum(Abundance)) %>%
    select(Genus, Sample, ndvi, ndvi_july, Genus_Sample_Abundance, Alias) %>%
    unique()

if (parameters$roottree == "TRUE" && parameters$maketree == "TRUE") {
    phyloseq::phy_tree(ps) <- cuphyr::root_tree_in_outgroup(physeq = ps)
}

if (parameters$biom_export == "TRUE") {
    suppressWarnings(phyloseq.extended::write_phyloseq(p, biom_file = paste0(path,
        "all_samples.biom"), biom_format = "standard"))
    suppressWarnings(phyloseq.extended::write_phyloseq(ps, biom_file = file.path(path,
        "samples_without_controls.biom"), biom_format = "standard"))
    suppressWarnings(phyloseq.extended::write_phyloseq(ps.trans, biom_file = file.path(path,
        "samples_without_controls_rel_abundance.biom"), biom_format = "standard"))
    suppressWarnings(phyloseq.extended::write_phyloseq(ps.contr, biom_file = file.path(path,
        "just_controls.biom"), biom_format = "standard"))
}

ps
## phyloseq-class experiment-level object
## otu_table()   OTU Table:         [ 151 taxa and 18 samples ]
## sample_data() Sample Data:       [ 18 samples by 21 sample variables ]
## tax_table()   Taxonomy Table:    [ 151 taxa by 7 taxonomic ranks ]
## refseq()      DNAStringSet:      [ 151 reference sequences ]

Output

The chunks below will produce various plots and other output. Each chunk is headed by a description of the output and may contain some parameters to adjust the output.

Plot looks

This chunk sets the background structure and color palette. Viridis was chosen because it is optimized for grey-scale printing and various types of color blindness and More info on the Viridis palette can be found on the Viridis info page. It also establishes save_plot as a shorter variant of ggsave with customized date-time structure to save plots with the same name mulitple times instead of overwriting them (overwriting can be triggered with overwrite=TRUE).

##### Optional settings (sensible defaults) #####
# Can be changed to adjust the output format for all plots. Default "pdf", 
# possible "eps"/"ps", "tex" (pictex), "jpeg", "tiff", "png", "bmp" and "svg"
parameters$output_format = "pdf"

# Can be changed to preferred ggplot2 theme. Recommended: "theme_bw()".
theme_set(theme_bw())

############### NO NEED FOR CHANGES BELOW ###############

my_scale_col <- scale_color_viridis(discrete = TRUE)
my_scale_fill <- scale_fill_viridis(discrete = TRUE)

# Custom, more narrow color ranges based on viridis
# Base order to have adjacent colors be distinct from each other
tmp$sort_colors <- c(rbind(c(1:5), c(6:10), c(11:15), c(16:20)))

# Customized vectors
tmp$n_col <- 20
tmp$viridis_greens <- viridis(tmp$n_col,  option = "D", begin = 0.85, 
                              end = 0.7)[tmp$sort_colors]
tmp$viridis_reds <- viridis(tmp$n_col,  option = "B", begin = 0.7, 
                            end = 0.5)[tmp$sort_colors]
tmp$viridis_blues <- viridis(tmp$n_col,  option = "D", begin = 0.2, 
                             end = 0.4)[tmp$sort_colors]
tmp$viridis_yellows <- viridis(tmp$n_col,  option = "D", begin = 1, 
                               end = 0.9)[tmp$sort_colors]
tmp$viridis_dark <- viridis(tmp$n_col,  option = "A", begin = 0, 
                            end = 0.1)[tmp$sort_colors]
tmp$viridis_light <- viridis(tmp$n_col,  option = "A", begin = 1, 
                             end = 0.9)[tmp$sort_colors]
# Collected list that is available in the global environment
sub_viridis <- list(tmp$viridis_greens, tmp$viridis_blues, tmp$viridis_yellows, 
                    tmp$viridis_light, tmp$viridis_reds, tmp$viridis_dark)
names(sub_viridis) <- c("greens", "blues", "yellows", "lights", "reds", "darks")

tmp$out <- paste0(".", parameters$output_format)

#################### Function ############################

# Generic save function for plots that checks whether file exists and if so, 
# creates a new one with d/m/y+time info to avoid overwriting. Overwriting can 
# be triggered with overwrite = TRUE. Width, height and resolution are taken 
# from parameters in the 'set' environment or set to 20x20 cm with 300dpi.
save_plot <- function(
  pl, filetype = ".pdf", plot_name = "my_plot", overwrite=FALSE){
  wp <- if (!is.null(set$wp)) set$wp else 20
  hp <- if (!is.null(set$hp)) set$hp else 20
  res <- if (!is.null(set$res)) set$res else 300
  name <- paste0("/", plot_name,filetype)
  if (file.exists(paste0(outp, name)) & !overwrite) {
  name <- paste0("/", plot_name, "_", 
                 format(Sys.time(), "%d-%m-%y_%H%M%S"),filetype)}
  ggsave(file.path(outp, name), pl, 
         width = wp, height = hp, unit = "cm", dpi = res)
}

################################################

Total ASV counts ranked

This chunk plots the absolute abundance of all samples (including controls) and all samples without controls and other trimmed samples.

# CHANGE ME to the sample group for color coding. Accepted values are the column 
# headers in the descriptor file.
set$color_by = "Symptoms"

##### Optional settings (sensible defaults) #####

# Can be changed to change the width (in cm) of the saved plot.
set$wp = 17
# Can be changed to change the height (in cm) of the saved plot.
set$hp = 20  
# Can be changed to change the resolution (in dpi) of the saved plot.
set$res = 300

############### NO NEED FOR CHANGES BELOW ###############
# Rank samples
set$ranked <- cuphyr::make_ranked_sums(p, myset = tmp$subset_id)
set$ranked_ps <- cuphyr::make_ranked_sums(ps, myset = tmp$subset_id)
set$ymax <- max(set$ranked$Abundance)
set$ymax <- set$ymax + round(set$ymax/10)
set$xmax <- nrow(set$ranked) + 1
set$title2 <- "Samples (without controls)"

# Stabilize colors
set$color_vars <- set$ranked[,set$color_by]  %>% 
  unlist() %>% as.character() %>% unique()
set$color_vars <- sort(set$color_vars)
set$color_varsPalette <- viridis(length(set$color_vars))
names(set$color_varsPalette) <- set$color_vars
set$my_scale_fill <- scale_fill_manual(values = set$color_varsPalette)

# plot
plots$overview_all <- ggplot(data = set$ranked, aes(x = Rank, y = Abundance)) + 
  aes_string(fill = set$color_by) + 
  geom_col() + set$my_scale_fill + ggtitle("All samples") + ylim(0, set$ymax) + 
  xlim(0,set$xmax) + ylab("ASV counts ('reads')")

if (length(tmp$noise_ASVs) > 0) {
  set$ranked_nonoise <- cuphyr::make_ranked_sums(
    tmp$no_noise_ps, myset = tmp$subset_id)
  plots$overview_noise <- ggplot(
    data = set$ranked_nonoise, aes(x = Rank, y = Abundance)) + 
  aes_string(fill = set$color_by) + 
  geom_col() + set$my_scale_fill + 
    ggtitle("Samples (without controls), noise ASVs removed") + 
    ylim(0, set$ymax) + 
    xlim(0,set$xmax) + ylab("ASV counts ('reads')")
}

if (parameters$minASVcount > 0) {
plots$overview_all <- plots$overview_all + 
  geom_hline(yintercept = parameters$minASVcount, linetype = "dashed") + 
    ggtitle("All samples (ASV count cutoff indicated)")
set$title2 <- "Samples (without controls and low count samps)"
}

plots$overview_ps <- ggplot(data = set$ranked_ps, aes(x = Rank, y = Abundance)) + 
  aes_string(fill = set$color_by) + 
  geom_col() + set$my_scale_fill + ggtitle(set$title2) + ylim(0, set$ymax) + 
  xlim(0,set$xmax) + ylab("ASV counts ('reads')")
plots$combo_overview <- ggarrange(
  plots$overview_all, plots$overview_ps, nrow = 2, align = "v", 
  common.legend = TRUE, legend = "right")

if (length(tmp$noise_ASVs) > 0) {
plots$combo_overview <- ggarrange(
  plots$overview_all, plots$overview_noise, plots$overview_ps,
  nrow = 3, align = "v", 
  common.legend = TRUE, legend = "right")
}

#Save plots
save_plot(plots$combo_overview, plot_name = "Overview_all_and_pruned", 
          filetype = tmp$out)

#Clean up plot parameters
rm(list = ls(set), envir = set)

#Print plots
plots$combo_overview

Controls

This chunk generates an overview over the controls (positive AND negative)

# CHANGE ME to the desired sample categories on the x-axis. In this case it 
# should be the Sample names.
set$x_axis_value = "Sample"

# CHANGE ME to the taxonomic level for color coding. Use "OTU" for ASVs, 
# "Genus", "Species" or "OTU" recommended to compare pos. controls.
set$color_by_taxlvl = "Species"

# CHANGE ME to the taxonomic level for labeling the tree tips (if phylogenetic 
# tree is available). Use "OTU" for ASVs.
set$label_by_taxlvl = "OTU"

# CHANGE ME to a sample category to shape the tree tip labels by (if 
# phylogenetic tree is available).
set$label_shape_by = "Symptoms"

##### Optional settings (sensible defaults) #####

# Can be changed to generate a tree for just the control sequences IF no 
# phylogenetic tree for all seuquences is provided. This may slow down this 
# chunk when running it for the first time
set$control_tree = TRUE

# Can be changed to change the width (in cm) of the saved plot.
set$wp = 17
# Can be changed to change the height (in cm) of the saved plot.
set$hp = 20  
# Can be changed to change the resolution (in dpi) of the saved plot.
set$res = 300

############### NO NEED FOR CHANGES BELOW ###############
if (set$control_tree & class(try(phy_tree(ps.transcontr), 
                                 silent = TRUE)) == "try-error") {
  # generate phylogenetic tree of ASVs only if there is no file called 
  # 'phylotree.rds' in the working directory and 'parameters$maketree' is "TRUE"
  if (!file.exists(paste0(path, "/controls_phylotree.rds"))) {
    set$ASVs <- phyloseq::refseq(ps.transcontr)
    set$ASV_align <- AlignSeqs(set$ASVs, anchor = NA)
    set$ASV_phang <- phyDat(as(set$ASV_align, "matrix"), type = "DNA")
    set$dm <- dist.ml(set$ASV_phang)
    set$treeNJ <- NJ(set$dm)
    set$fit <- pml(set$treeNJ, data = set$ASV_phang)
    set$fitGTR <- update(set$fit, k = 4, inv = 0.2)
    set$fitGTR <- optim.pml(set$fitGTR, model = "GTR", 
                            optInv = TRUE, optGamma = TRUE,
                            rearrangement = "stochastic", 
                            control = pml.control(trace = 0))
    saveRDS(set$fitGTR, file = paste0(path, "/controls_phylotree.rds"))}
  set$fitGTR <- readRDS(paste0(path, "/controls_phylotree.rds"))
  phyloseq::phy_tree(ps.transcontr) <- set$fitGTR$tree
}

plots$topnpplot <- plot_bar(ps.contr, x = set$x_axis_value, 
                            fill = set$color_by_taxlvl) + my_scale_fill + 
  theme(axis.title.x = element_blank(), legend.position = "none", 
        legend.key.size = unit(3, "mm")) + 
  ylab("ASV counts") + guides(col = guide_legend(ncol = 3))

plots$topntplot <- plot_bar(ps.transcontr, x = set$x_axis_value, 
                            fill = set$color_by_taxlvl) + my_scale_fill + 
  theme(axis.title.x = element_blank(), legend.position = "none", 
        legend.key.size = unit(3, "mm")) + 
  ylab("Relative abundance") + guides(col = guide_legend(ncol = 3))

plots$combo_contr <- ggarrange(plots$topnpplot, plots$topntplot, ncol = 2, 
                               labels = c("A", "B"), align = "hv", 
                               common.legend = TRUE, legend = "right")

if (class(try(phy_tree(ps.transcontr), silent = TRUE)) != "try-error") {
plots$tre <- plot_tree(
          ps.transcontr, ladderize = "left", label.tips = set$label_by_taxlvl, 
          color = "abundance", text.size = 2.5, shape = set$label_shape_by) + 
          scale_color_viridis_c(aesthetics = c("color","fill")) + 
          theme(legend.position = "left", panel.border = element_blank())
plots$combo_contr <- ggarrange(plots$tre, ggarrange(plots$topnpplot, 
                                                    plots$topntplot, ncol = 2, 
                               labels = c("B", "C"), align = "hv", 
                               common.legend = TRUE, legend = "right"), 
                               nrow = 2, legend = "right", labels = c("A")) 
}

# save
save_plot(plots$combo_contr, plot_name = "Controls", filetype = tmp$out)

plots$combo_contr

Get a list of Top N taxa at a given level

This chunk lists the top n most abundant taxonomic terms at a given level. Change the function parameters to the desired values. For more info, check help page of the function with ?cuphyr::abundant_tax_physeq(). Change ‘ignore_na’ to include/exclude NA values at the given level.

#The character vector can later be accessed by calling 'tmp$tops'
tmp$tops <- cuphyr::abundant_tax_physeq(physeq = ps, 
                            lvl = "Genus",
                            top = 15,
                            output_format = "tops",
                            ignore_na = TRUE,
                            silent = FALSE)
## 
## The top 15 most abundant annotated groups at the taxonomic level 'Genus' are:
## Globodera
## Meloidogyne
## Pristionchus
## Rhabditis
## Pellioditis
## Cephaloboides
## Aporcelaimellus
## Acrobeloides
## Nygolaimus
## Cruznema
## Sectonema
## Acrobeles
## Eucephalobus
## Mesorhabditis
## Aphelenchoides

Sequences belonging to phylum

This chunk gives an overview of the number of ASVs belonging to which Phylum

# Number of ASVs belonging to Nematoda

ps_tbl %>% select(OTU, Phylum) %>% unique() %>% group_by(Phylum) %>% summarise(length(OTU))
## # A tibble: 5 × 2
##   Phylum                     `length(OTU)`
##   <chr>                              <int>
## 1 Arthropoda                            10
## 2 Candidatus Bipolaricaulota             1
## 3 Nematoda                             133
## 4 Proteobacteria                         1
## 5 Tardigrada                             6
# Total ASV counts

ps_tbl %>% select(OTU, Abundance) %>% summarise(total_sum = sum(Abundance))
## # A tibble: 1 × 1
##   total_sum
##       <int>
## 1    405276
# Total ASV counts per phylum

ps_tbl %>% select(OTU, Phylum, Abundance) %>% group_by(Phylum) %>% summarise(Abundance_sum = sum(Abundance))
## # A tibble: 5 × 2
##   Phylum                     Abundance_sum
##   <chr>                              <int>
## 1 Arthropoda                           426
## 2 Candidatus Bipolaricaulota             4
## 3 Nematoda                          404660
## 4 Proteobacteria                        11
## 5 Tardigrada                           175
# Percentage of ASV counts belonging to Nematoda

nem_percentage = 404660/405276 # ASV counts Nematoda / Total ASV counts
nem_percentage
## [1] 0.99848

Top N ASVs/taxa Bar plot

This chunk plots abundance of the Top n ASVs or taxa at a given level as a bar plot, giving an insight into the presence of the n ASV and most common taxa for the primary and secondary parameters. The default for n is set at 20, a larger n may lead to delay/skipping of the plot in standard out, but it should be saved as a PDF regardless for ASVs. For taxa, a large n may lead to unreadable plots. The chunk does not require any input, but it is possible to adjust the default ‘n’, and to change width, height and resolution of the PDF-output if necessary.

# CHANGE ME to the sample category that will be shown in separate panels.
# Accepted values are the column headers in your descriptor file.
set$panel_by = "Symptoms"

# CHANGE ME to the desired sample categories on the x-axis.  Accepted values
# are the column headers in the descriptor file.

set$x_axis_value = "Alias"

# CHANGE ME to the count of top ASVs you want to plot (e.g. 'set$topASVs = 20'
# plots the 20 most abundant ASVs)
set$topASVs = 100

# CHANGE ME to the taxonomic level of interest (color coding). Accepted values
# are the column headers in your descriptor file.
set$taxlvl = "Genus"

# CHANGE ME to change the number of Top n taxa to be plotted at taxlvl.
set$top_n = 15

# CHANGE ME to an entry at the chosen taxonomic level you want to highlight.
# Comment out to not highlight anything.
set$highlight = "Ditylenchus"

##### Optional settings (sensible defaults) #####

# Can be changed to turn unified coloring on or off (same taxonomy term = same
# color in both plots). Highlighting will unify colors even if unify_colors is
# FALSE.
set$unify_colors = TRUE

# Can be changed to include (FALSE) or exclude (TRUE) NA values in the barplot
set$ignore_na = FALSE

# Can be changed to remove ASV segmentation in the top n taxlvl plot. This
# improves visual clarity when a bar segment appears black due to the border of
# many small ASVs overlapping.
set$fuse_ASVs = FALSE

# Can be changed to change the width (in cm) of the saved plot.
set$wp = 30
# Can be changed to change the height (in cm) of the saved plot.
set$hp = 20
# Can be changed to change the resolution (in dpi) of the saved plot.
set$res = 300

# Can be changed to change the y-axis label
set$y_axis_label = "Relative abundance"




############### NO NEED FOR CHANGES BELOW ###############

# Make physeq objects of top n taxa and top n ASVs
set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl, top = set$top_n,
    ignore_na = set$ignore_na)
set$topnASVs <- names(sort(taxa_sums(ps), decreasing = TRUE))[1:set$topASVs]
set$ps.topnASVs <- prune_taxa(set$topnASVs, ps.trans)

if (set$unify_colors | exists("highlight", envir = set) | set$fuse_ASVs) {
    set$toptax <- union(phyloseq::tax_table(set$ps.topnTax)[, set$taxlvl], phyloseq::tax_table(set$ps.topnASVs)[,
        set$taxlvl])
    set$toptax <- sort(set$toptax)
    set$taxlvlPalette <- viridis(length(set$toptax))
    names(set$taxlvlPalette) <- set$toptax
    if (exists("highlight", envir = set)) {
        # It is possible to change the highlight color here by substituting
        # 'sub_viridis$reds[4]' with a hexcode-string, e.g. '#ff7f7f''
        set$taxlvlPalette[set$highlight] <- sub_viridis$reds[4]
    }
    set$taxlvlPalette <- set$taxlvlPalette[sort(names(set$taxlvlPalette))]
    set$my_scale_fill <- scale_fill_manual(values = set$taxlvlPalette, na.value = "grey")
} else {
    set$my_scale_fill <- my_scale_fill
}

# Plot
if (set$unify_colors | exists("highlight", envir = set) | set$fuse_ASVs) {
    set$my_scale_fill <- scale_fill_manual(values = set$taxlvlPalette[sort(unique(phyloseq::tax_table(set$ps.topnTax)[,
        set$taxlvl]))], na.value = "grey")
}
plots$topn_tax <- plot_bar(set$ps.topnTax, x = set$x_axis_value, fill = set$taxlvl,
    title = paste0("Top ", set$top_n, " ", set$taxlvl)) + facet_grid(paste0("~",
    set$panel_by), scales = "free", space = "free") + set$my_scale_fill + ylab(set$y_axis_label) +
    xlab("Sample") + theme(strip.background = element_blank(), strip.text = element_text(size = 16),
    axis.title = element_text(size = 16), legend.text = element_text(size = 14))

if (set$fuse_ASVs) {
    plots$topn_tax <- plots$topn_tax + geom_bar(aes_string(color = set$taxlvl, fill = set$taxlvl),
        stat = "identity", position = "stack") + scale_color_manual(values = set$taxlvlPalette,
        na.value = NA)
}

if (set$unify_colors | exists("highlight", envir = set) | set$fuse_ASVs) {
    set$my_scale_fill <- scale_fill_manual(values = set$taxlvlPalette[sort(unique(phyloseq::tax_table(set$ps.topnASVs)[,
        set$taxlvl]))], na.value = "grey")
}
plots$topn_ASVs <- plot_bar(set$ps.topnASVs, x = set$x_axis_value, fill = set$taxlvl,
    title = paste0("Top", set$topASVs, "_ASVs")) + facet_grid(paste0("~", set$panel_by),
    scales = "free_x", space = "free") + set$my_scale_fill + ylab(set$y_axis_label) +
    xlab("Sample") + theme(strip.background = element_blank())



# save
save_plot(plots$topn_tax, plot_name = paste0("Top", set$top_n, "_", set$taxlvl),
    filetype = tmp$out)
save_plot(plots$topn_ASVs, plot_name = paste0("Top", set$topASVs, "_ASVs"), filetype = tmp$out)

# Clean up plot parameters
rm(list = ls(set), envir = set)

# Print to standard out
plots$topn_tax

plots$topn_ASVs

Customized Top N Genus Bar plot

This chunk plots abundance of the Top n ASVs or taxa at a given level as a bar plot, giving an insight into the presence of the n ASV and most common taxa for the primary and secondary parameters. The default for n is set at 20, a larger n may lead to delay/skipping of the plot in standard out, but it should be saved as a PDF regardless for ASVs. For taxa, a large n may lead to unreadable plots. The chunk does not require any input, but it is possible to adjust the default ‘n’, and to change width, height and resolution of the PDF-output if necessary.

# CHANGE ME to the desired sample categories on the x-axis. 
# Accepted values are the column headers in the descriptor file.
set$x_axis_value = "ndvi"

# CHANGE ME to the taxonomic level of interest (color coding). Accepted values 
# are the column headers in your descriptor file.
set$taxlvl = "Genus"

# CHANGE ME to change the number of Top n taxa to be plotted at 
# taxlvl.
set$top_n = 10

# Can be changed to include (FALSE) or exclude (TRUE) NA values in the barplot
set$ignore_na = FALSE

# CHANGE ME to an entry at the chosen taxonomic level you want to highlight. 
# Comment out to not highlight anything.
# set$highlight = 

##### Optional settings (sensible defaults) #####

# Can be changed to change the width (in cm) of the saved plot.
set$wp = 20
# Can be changed to change the height (in cm) of the saved plot.
set$hp = 13
# Can be changed to change the resolution (in dpi) of the saved plot.
set$res = 300

# Can be changed to change the y-axis label
set$y_axis_label = "Relative abundance"

# Can be changed to change the x-axis label
set$x_axis_label = "Sample"

############### NO NEED FOR CHANGES BELOW ###############
# Estimate Alpha-diversity (Shannon)
set$alpha_div_ps_trans <- estimate_richness(ps.trans, measures = "Shannon") %>%
  as_tibble(rownames = "Sample")
# Make physeq objects of top n taxa and top n ASVs
set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl, 
                                              top = set$top_n, 
                                              ignore_na = set$ignore_na)

# Plot
set$my_scale_fill <- my_scale_fill


set$topntax_tbl <- psmelt(set$ps.topnTax) %>% 
                    as_tibble() %>%
                    left_join(set$alpha_div_ps_trans, by = "Sample") %>% 
                    select(Genus, Alias, ndvi, ndvi_july, Abundance, Shannon) %>%
                    filter(Abundance > 0) %>%
                    group_by(Genus, Alias, ndvi, ndvi_july, Shannon) %>%
                    summarise(Abundance = sum(Abundance)) %>%
                    arrange(ndvi) %>%
                    mutate(ndvi_rank = c(1:length(ndvi))) 
                    

plots$topn_tax_custom <- ggplot(set$topntax_tbl, aes(x = fct_reorder(Alias, ndvi),
                           y = Abundance,
                           fill = Genus)) + 
                           #title = paste0("Top ", set$top_n, " ", set$taxlvl))) +
  geom_col(color = "black") +
  set$my_scale_fill + 
  ylab(set$y_axis_label) +
  xlab(set$x_axis_label) +
  theme(strip.background = element_blank(),
        #strip.text = element_text(size = 12),
        #axis.title=element_text(size=12),
        #legend.text = element_text(size=12), 
        legend.position = "bottom")

plots$ndvi_dot_plot <- ggplot(set$topntax_tbl, aes(fct_reorder(Alias, ndvi),
                           y = ndvi)) +
                             geom_point() +
    theme(strip.background = element_blank(),
         # strip.text = element_text(size = 12),
         # axis.title=element_text(size=12),
         # legend.text = element_text(size=12),
          axis.title.x=element_blank()) +
  ylab("NDVI")

plots$shannon_dot_plot <- ggplot(set$topntax_tbl, 
                                 aes(fct_reorder(Alias, ndvi),
                           y = Shannon)) +
                             geom_point() +
    theme(strip.background = element_blank(),
         # strip.text = element_text(size = 12),
         # axis.title=element_text(size=12),
         # legend.text = element_text(size=12),
          axis.title.x=element_blank()) +
  ylab("Shannon")




plots$combo_topn_custom <- ggarrange(plots$ndvi_dot_plot,
                                     plots$shannon_dot_plot,
                                     plots$topn_tax_custom,
                                     nrow = 3,
                                     heights = c(1, 1, 3),
                                     align = "v")

plots$combo_topn_custom

save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"), 
          filetype = tmp$out)

NDVI+Shannon regression

set$my_formula <- y ~ x
set$plot_title <- "Nematodes"

topntax_data <- set$topntax_tbl %>%
  mutate(Taxa = 'nematodes') %>%
  ungroup() %>%
  select(Alias, ndvi, Shannon, Taxa) %>%
  distinct()

write.csv(topntax_data, file = "../topntax_all_taxa/topntax_data_nematodes.csv")

Molecular and morphological data

Mol+morph, relative abundance

# Excel file with field data
morphological_id <- file.path("2020-patch-larvik-a-counts.csv")

# Reduce abundance per sample and genus data to genera of interest
genera_of_interest_mol_morph <- c("Globodera", "Meloidogyne", "Pratylenchus")
genus_abundance_tbl_per_sample_mm <- genus_abundance_tbl_per_sample %>%
  filter(Genus %in% genera_of_interest_mol_morph)

# read in and parse morphological count data
 morph_data <- read_delim(morphological_id) %>% 
  mutate(genus = str_replace(genus, "cyst", "Globodera"),
         genus = str_replace(genus, "mel", "Meloidogyne"),
         genus = str_replace(genus, "prat", "Pratylenchus")) %>%
   dplyr::rename(Sample = rute, Genus = genus)

# Combine morphological and metabarcoding data
set$data_mol_morph <- genus_abundance_tbl_per_sample_mm %>%
  left_join(morph_data)

### Plotting
# New facet label names for Genus variable


genus_names <- list(
  'Globodera'=expression(paste(italic("Globodera "))), #"spp.")),
  'Meloidogyne'=expression(paste(italic("Meloidogyne "))), #"spp.")),
  'Pratylenchus'=expression(paste(italic("Pratylenchus ")))#, "spp."))
)

genus_labeller <- function(variable,value){
  return(genus_names[value])
}

signif.labs <- c("pval > 0.05", "pval <= 0.05")
names(signif.labs) <- c("p value > 0.05", "p value <= 0.05")

# Subset data for modeling

set$glob_data <- subset(set$data_mol_morph, Genus == "Globodera")
set$mel_data <- subset(set$data_mol_morph, Genus == "Meloidogyne")
set$prat_data <- subset(set$data_mol_morph, Genus == "Pratylenchus")



# Quasi-binomial model for Globodera

model_glob = glm(
  Genus_Sample_Abundance ~ total_count,
  data = set$glob_data,
  family = quasibinomial
)

# Quasi-binomial model for Meloidogyne

model_mel = glm(
  Genus_Sample_Abundance ~ total_count,
  data = set$mel_data,
  family = quasibinomial
)


# Quasi-binomial model for Pratylenchus

model_prat = glm(
  Genus_Sample_Abundance ~ total_count,
  data = set$prat_data,
  family = quasibinomial
)

pval_glm <- function(glm){
  coef(summary(glm))[,4][2]
}

set$data_mol_morph <- set$data_mol_morph %>% 
  mutate(pval = ifelse(Genus == "Globodera", pval_glm(model_glob), NA)) %>% 
  mutate(pval = ifelse(Genus == "Pratylenchus", pval_glm(model_prat), pval)) %>% 
  mutate(pval = ifelse(Genus == "Meloidogyne", pval_glm(model_mel), pval)) %>% 
  mutate(signif = ifelse(pval <= 0.05, "pval <= 0.05", "pval > 0.05"))
  
# Other plotting variables
# Can be changed to change the width (in cm) of the saved plot.
set$wp = 20
# Can be changed to change the height (in cm) of the saved plot.
set$hp = 13
# Can be changed to change the resolution (in dpi) of the saved plot.
set$res = 300


set$my_formula <- y ~ x
set$plot_title <- paste("Molecular analysis vs",
               "morpological analysis", sep = "\n")

# Plotting quasibinomial model

plots$mol_morph_quasi <- ggplot(set$data_mol_morph, 
                             aes(x=total_count, 
                                 y = Genus_Sample_Abundance)) +
  geom_point(alpha = 0.7) +
  #ggtitle(set$plot_title) +
  theme(plot.title = element_text(hjust = 0.5, size = 20), 
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        #axis.line = element_line(colour = "dark grey"),
        strip.background = element_blank(), 
        strip.text = element_text(face = "italic", size = 16),
        axis.text = element_text(),
        text = element_text()) +
  xlab("Nematodes / 250 ml soil") + 
  ylab("Relative abundance") +
  geom_smooth(method = "glm", formula = set$my_formula, se = F,
              method.args = list(family = quasibinomial), 
              aes(color = signif, linetype = signif)) +
   scale_color_manual(values=c('black', 'lightgrey'),
                     name= 'Significance',
                     labels = names(signif.labs)) +
  scale_linetype_discrete(name= 'Significance',
                     labels = names(signif.labs)) +
  facet_wrap(~Genus, scales = "free", 
              #labeller = labeller(Genus = genus_labs)) +
             labeller = genus_labeller)
  
#Print and save plot

plots$mol_morph_quasi

save_plot(plots$mol_morph_quasi, plot_name = paste0("Molecular_and_Morphological_Plot"), 
          filetype = ".pdf")


# Generate table overview of morphological counts for manuscript
morph_table_manuscript <- pivot_wider(set$data_mol_morph %>% 
                                        select(-Genus_Sample_Abundance,
                                               -ndvi), 
                                      names_from = Genus, 
                                      values_from = total_count) %>%
  arrange(Alias)
write.xlsx(morph_table_manuscript, file = "t1_morph_table_manuscript.xlsx")

NDVI regression

# Create properly formatted tibble with columns Sample, ndvi_01 (ndvi translated to (0, 1) interval) and one column for each genus
# containing the sample abundances for that genus.
ldf <- data.frame(genus_abundance_tbl_per_sample %>% pivot_wider(id_cols = c('Sample', 'ndvi'), names_from = 'Genus', values_from = 'Genus_Sample_Abundance'))
ldf_genus_data <- data.frame(ldf) %>% select(!c('Sample', 'ndvi'))
colnames(ldf_genus_data) <- gsub(' ', '.', colnames(ldf_genus_data))
ldf <- cbind.data.frame(
Sample = ldf$Sample,
ndvi_01 = (ldf$ndvi + 1) / 2.0
)
ldf <- tibble(cbind(ldf, ldf_genus_data))

n_samples_by_genus <- data.frame(ldf_genus_data > 0) %>% mutate_if(is.logical, as.numeric) %>% colSums() %>% sort(decreasing = TRUE)
keep_n <- 100 # Maximum number of genera to include in the analysis
top_n_occurence_genuses <- names(n_samples_by_genus[1:keep_n])
top_n_occurence_genuses <- top_n_occurence_genuses[!is.na(top_n_occurence_genuses)]

l_genus_ldf <- ldf %>% select(all_of(top_n_occurence_genuses))
l_genus_ldf_transposed <- data.frame(t(l_genus_ldf))
l_meta_ldf <- ldf %>% select('ndvi_01')

l_model <- linda(
l_genus_ldf_transposed,
l_meta_ldf,
formula = '~ ndvi_01',
feature.dat.type = 'proportion',
is.winsor = FALSE,
alpha = 0.05
)
## 0  features are filtered!
## The filtered data has  18  samples and  53  features will be tested!
## Fit linear models ...
## Completed.
# Print model info
l_model
## $variables
## [1] "ndvi_01"
## 
## $bias
## [1] -0.01789055
## 
## $output
## $output$ndvi_01
##                             baseMean log2FoldChange      lfcSE         stat
## Globodera               754634.19865  -4.559618e-01 0.29935505 -1.523147257
## Meloidogyne              61866.79371   2.765057e+00 0.40120028  6.891961655
## Pristionchus             67346.31537   3.169910e-01 0.33017787  0.960061242
## Rhabditis                56521.12829   4.432402e-01 0.27148299  1.632662775
## Nygolaimus                3165.10477  -8.427746e-01 0.36100641 -2.334514200
## Acrobeloides              4388.62890   7.941938e-01 0.24592277  3.229443800
## Aporcelaimellus           8752.47207  -3.406609e-01 0.16569033 -2.056009379
## Pellioditis              16832.59394  -2.604002e-01 0.43525867 -0.598265365
## Cephaloboides             2025.06777   5.911949e-01 0.59646282  0.991168138
## Eucephalobus               646.22070  -4.151353e-01 0.45558400 -0.911215723
## Acrobeles                  651.64733   5.235050e-01 0.59599188  0.878375980
## Mesorhabditis              524.38406   6.847116e-01 0.42269495  1.619871742
## Pratylenchus               392.39406   6.840229e-01 0.35193863  1.943585597
## Hypsibius                  242.94694  -2.893259e-01 0.35082408 -0.824703697
## Aphelenchus                316.56727   2.529986e-02 0.48480642  0.052185488
## Cruznema                  1363.79265   8.024877e-01 0.49336009  1.626575985
## Aphelenchoides             822.11300  -2.162205e-01 0.38616715 -0.559914237
## Anaplectus                 458.84418  -5.849614e-05 0.41156785 -0.000142130
## Metateratocephalus         536.81600  -7.507380e-01 0.33206049 -2.260847143
## Plectus                    434.97545  -6.856073e-01 0.42590207 -1.609776919
## Paramphidelus              498.11205  -3.340229e-01 0.36976266 -0.903343935
## Filenchus                  259.63928  -3.615399e-01 0.34704143 -1.041777350
## Ditylenchus                425.99207  -5.460422e-01 0.29454627 -1.853841900
## Sectonema                  233.31224  -8.387025e-01 0.47130542 -1.779530807
## Chiloplacus                758.90167   2.180144e-01 0.18503697  1.178220939
## Bastiania                   98.23107  -3.367691e-01 0.28834536 -1.167936648
## Clarkus                    119.63544  -5.583309e-01 0.23586714 -2.367141657
## Trischistoma               275.44460  -8.092726e-02 0.37115882 -0.218039431
## Tylencholaimus             353.94743  -6.167086e-02 0.25399021 -0.242808008
## Zeldia                     800.30996   6.173047e-02 0.28823133  0.214169867
## Zeatylenchus               214.31405   6.287060e-02 0.31691865  0.198380869
## Prismatolaimus             355.13517   2.221236e-01 0.15762989  1.409146273
## Diploscapter               691.90325   3.177631e-01 0.25758203  1.233638597
## Prodesmodora               199.12220   1.613313e-01 0.17248893  0.935314184
## Panagrolaimus              411.24634   7.120651e-02 0.10241779  0.695255342
## Diphascon                  142.12094   1.333432e-02 0.11281091  0.118200620
## Mesaphorura                211.59911   7.592354e-02 0.08824782  0.860344677
## Tullbergia                  64.19880  -1.033518e-01 0.16089301 -0.642363814
## Spelobia                  6776.13632   2.047921e-02 0.08477302  0.241577026
## Bunonema                  1135.86360  -8.197451e-02 0.10298133 -0.796013368
## Aquatides                  950.11625  -1.370781e-01 0.11024072 -1.243443740
## Myolaimus                  607.64266   2.047921e-02 0.08477302  0.241577026
## Altainella                 526.06316   8.944697e-04 0.12485257  0.007164207
## Dicyrtomina                393.04080  -6.957390e-02 0.11101082 -0.626730773
## Anguina                    262.10103  -1.370781e-01 0.11024072 -1.243443740
## Deladenus                  222.46410   2.879846e-02 0.10715623  0.268752044
## Geobacter                  221.88520  -1.354813e-01 0.12565904 -1.078166078
## NA.                        221.38501   1.493595e-02 0.12460371  0.119867621
## Odontocepheus              217.59550   1.596974e-02 0.13517441  0.118141742
## Theristus                  158.90293   2.879846e-02 0.10715623  0.268752044
## Thonus                     116.90292   8.944697e-04 0.12485257  0.007164207
## Candidatus.Acetothermum    116.90292   8.944697e-04 0.12485257  0.007164207
## Sellnickochthonius          36.82683   2.047921e-02 0.08477302  0.241577026
##                               pvalue         padj reject df
## Globodera               1.472409e-01 0.5574120890  FALSE 16
## Meloidogyne             3.623613e-06 0.0001920515   TRUE 16
## Pristionchus            3.513092e-01 0.7352513393  FALSE 16
## Rhabditis               1.220616e-01 0.5177548997  FALSE 16
## Nygolaimus              3.292834e-02 0.4034160983  FALSE 16
## Acrobeloides            5.242908e-03 0.1389370590  FALSE 16
## Aporcelaimellus         5.647602e-02 0.4988715484  FALSE 16
## Pellioditis             5.580376e-01 0.8450283790  FALSE 16
## Cephaloboides           3.363572e-01 0.7352513393  FALSE 16
## Eucephalobus            3.757063e-01 0.7352513393  FALSE 16
## Acrobeles               3.927397e-01 0.7352513393  FALSE 16
## Mesorhabditis           1.247991e-01 0.5177548997  FALSE 16
## Pratylenchus            6.974921e-02 0.5177548997  FALSE 16
## Hypsibius               4.216652e-01 0.7449418642  FALSE 16
## Aphelenchus             9.590269e-01 0.9998883537  FALSE 16
## Cruznema                1.233578e-01 0.5177548997  FALSE 16
## Aphelenchoides          5.832927e-01 0.8587364852  FALSE 16
## Anaplectus              9.998884e-01 0.9998883537  FALSE 16
## Metateratocephalus      3.805812e-02 0.4034160983  FALSE 16
## Plectus                 1.269965e-01 0.5177548997  FALSE 16
## Paramphidelus           3.797431e-01 0.7352513393  FALSE 16
## Filenchus               3.130015e-01 0.7352513393  FALSE 16
## Ditylenchus             8.229094e-02 0.5177548997  FALSE 16
## Sectonema               9.415207e-02 0.5177548997  FALSE 16
## Chiloplacus             2.559357e-01 0.6888466043  FALSE 16
## Bastiania               2.599421e-01 0.6888466043  FALSE 16
## Clarkus                 3.086977e-02 0.4034160983  FALSE 16
## Trischistoma            8.301549e-01 0.9955117434  FALSE 16
## Tylencholaimus          8.112394e-01 0.9955117434  FALSE 16
## Zeldia                  8.331202e-01 0.9955117434  FALSE 16
## Zeatylenchus            8.452458e-01 0.9955117434  FALSE 16
## Prismatolaimus          1.779308e-01 0.6286888072  FALSE 16
## Diploscapter            2.351534e-01 0.6888466043  FALSE 16
## Prodesmodora            3.635293e-01 0.7352513393  FALSE 16
## Panagrolaimus           4.968695e-01 0.8229401169  FALSE 16
## Diphascon               9.073799e-01 0.9998883537  FALSE 16
## Mesaphorura             4.023073e-01 0.7352513393  FALSE 16
## Tullbergia              5.297345e-01 0.8412595983  FALSE 16
## Spelobia                8.121767e-01 0.9955117434  FALSE 16
## Bunonema                4.376758e-01 0.7482844797  FALSE 16
## Aquatides               2.316162e-01 0.6888466043  FALSE 16
## Myolaimus               8.121767e-01 0.9955117434  FALSE 16
## Altainella              9.943724e-01 0.9998883537  FALSE 16
## Dicyrtomina             5.396760e-01 0.8412595983  FALSE 16
## Anguina                 2.316162e-01 0.6888466043  FALSE 16
## Deladenus               7.915551e-01 0.9955117434  FALSE 16
## Geobacter               2.969467e-01 0.7352513393  FALSE 16
## NA.                     9.060803e-01 0.9998883537  FALSE 16
## Odontocepheus           9.074258e-01 0.9998883537  FALSE 16
## Theristus               7.915551e-01 0.9955117434  FALSE 16
## Thonus                  9.943724e-01 0.9998883537  FALSE 16
## Candidatus.Acetothermum 9.943724e-01 0.9998883537  FALSE 16
## Sellnickochthonius      8.121767e-01 0.9955117434  FALSE 16
## 
## 
## $covariance
## NULL
## 
## $feature.dat.use
##                                    1            2            3            4
## Globodera               9.555057e-01 8.863991e-01 7.903606e-01 7.858771e-01
## Meloidogyne             2.861367e-04 3.180478e-04 1.298566e-01 1.009443e-02
## Pristionchus            1.449759e-02 7.745909e-02 1.233878e-02 4.214542e-02
## Rhabditis               7.916448e-03 6.129648e-03 3.989139e-02 3.940085e-02
## Nygolaimus              1.096857e-03 7.054878e-03 1.920696e-02 3.246965e-02
## Acrobeloides            2.146025e-03 7.517493e-04 1.677115e-03 7.442899e-04
## Aporcelaimellus         3.719777e-03 5.002024e-03 2.675398e-03 1.079220e-02
## Pellioditis             4.816634e-03 8.702943e-03 6.799946e-04 5.312369e-02
## Cephaloboides           1.047296e-04 3.180478e-03 2.795192e-04 7.442899e-04
## Eucephalobus            1.573752e-03 1.047296e-04 1.047296e-04 1.442062e-03
## Acrobeles               4.768945e-04 4.555394e-05 4.555394e-05 1.162953e-03
## Mesorhabditis           6.199628e-04 8.247649e-05 8.247649e-05 2.791087e-04
## Pratylenchus            7.100659e-05 7.100659e-05 1.118077e-03 5.582174e-04
## Hypsibius               3.815156e-04 8.095761e-04 2.795192e-04 6.833090e-05
## Aphelenchus             7.100659e-05 1.330018e-03 6.389011e-04 3.721450e-04
## Cruznema                2.816901e-04 2.816901e-04 2.816901e-04 2.816901e-04
## Aphelenchoides          3.099814e-03 5.493552e-04 2.414224e-04 1.674652e-03
## Anaplectus              1.099687e-04 1.099687e-04 1.099687e-04 3.349305e-03
## Metateratocephalus      3.338261e-04 4.337015e-04 1.669131e-04 1.669131e-04
## Plectus                 1.011970e-04 2.023940e-04 7.187637e-04 4.651812e-03
## Paramphidelus           1.597253e-04 1.597253e-04 3.194505e-04 5.116993e-04
## Filenchus               9.237753e-05 2.891343e-04 9.237753e-05 3.628413e-03
## Ditylenchus             1.559495e-04 5.204418e-04 1.559495e-04 1.721170e-03
## Sectonema               7.918074e-05 3.469612e-04 7.918074e-05 7.918074e-05
## Chiloplacus             3.416545e-04 3.416545e-04 3.416545e-04 1.535098e-03
## Bastiania               4.189184e-05 4.189184e-05 4.189184e-05 3.256268e-04
## Clarkus                 2.861367e-04 1.156537e-04 5.782687e-05 6.977718e-04
## Trischistoma            5.722734e-04 1.156337e-04 1.156337e-04 8.838443e-04
## Tylencholaimus          1.924452e-04 1.924452e-04 6.389011e-04 1.924452e-04
## Zeldia                  2.670609e-03 4.189184e-04 4.189184e-04 4.189184e-04
## Zeatylenchus            1.047296e-04 1.047296e-04 1.047296e-04 1.047296e-04
## Prismatolaimus          2.111486e-04 2.111486e-04 2.111486e-04 2.111486e-04
## Diploscapter            4.118382e-04 4.118382e-04 4.118382e-04 4.118382e-04
## Prodesmodora            1.246417e-04 1.246417e-04 1.246417e-04 1.246417e-04
## Panagrolaimus           2.804437e-04 2.804437e-04 2.804437e-04 2.804437e-04
## Diphascon               9.303624e-05 9.303624e-05 9.303624e-05 1.860725e-04
## Mesaphorura             1.451647e-04 1.451647e-04 1.451647e-04 1.451647e-04
## Tullbergia              4.337015e-05 8.674030e-05 4.337015e-05 4.337015e-05
## Spelobia                4.856419e-03 4.856419e-03 4.856419e-03 4.856419e-03
## Bunonema                8.140671e-04 8.140671e-04 8.140671e-04 1.628134e-03
## Aquatides               6.809430e-04 6.809430e-04 6.809430e-04 6.809430e-04
## Myolaimus               4.354941e-04 4.354941e-04 4.354941e-04 4.354941e-04
## Altainella              3.770265e-04 3.770265e-04 3.770265e-04 3.770265e-04
## Dicyrtomina             2.816901e-04 2.816901e-04 2.816901e-04 2.816901e-04
## Anguina                 1.878463e-04 1.878463e-04 1.878463e-04 1.878463e-04
## Deladenus               1.594388e-04 1.594388e-04 1.594388e-04 1.594388e-04
## Geobacter               1.590239e-04 3.180478e-04 1.590239e-04 1.590239e-04
## NA.                     1.586654e-04 1.586654e-04 1.586654e-04 1.586654e-04
## Odontocepheus           1.559495e-04 1.559495e-04 1.559495e-04 1.559495e-04
## Theristus               1.138848e-04 1.138848e-04 1.138848e-04 1.138848e-04
## Thonus                  8.378367e-05 8.378367e-05 8.378367e-05 8.378367e-05
## Candidatus.Acetothermum 8.378367e-05 8.378367e-05 8.378367e-05 8.378367e-05
## Sellnickochthonius      2.639358e-05 2.639358e-05 2.639358e-05 2.639358e-05
##                                    5            6            7            8
## Globodera               7.743274e-01 7.720015e-01 7.663992e-01 7.303019e-01
## Meloidogyne             5.805581e-02 2.442002e-03 4.451698e-02 1.048001e-01
## Pristionchus            3.955396e-02 2.855264e-02 1.336869e-01 2.243361e-02
## Rhabditis               7.550755e-02 9.711656e-02 2.180516e-02 6.367185e-02
## Nygolaimus              2.100210e-03 1.131774e-02 5.893286e-04 1.044702e-03
## Acrobeloides            1.700170e-03 1.737579e-03 1.994651e-03 1.814483e-03
## Aporcelaimellus         6.650665e-03 1.709402e-02 5.802620e-03 6.983010e-03
## Pellioditis             1.105111e-02 2.503053e-02 1.359989e-03 4.701160e-02
## Cephaloboides           1.200120e-03 1.784540e-03 4.487964e-03 2.749216e-04
## Eucephalobus            2.200220e-03 6.574622e-04 1.047296e-04 1.110683e-02
## Acrobeles               1.600160e-03 4.555394e-05 3.173308e-03 4.555394e-05
## Mesorhabditis           8.247649e-05 4.696159e-04 1.178657e-03 1.649530e-04
## Pratylenchus            3.500350e-04 2.817695e-04 8.159935e-04 7.100659e-05
## Hypsibius               3.500350e-04 2.348079e-04 1.813319e-04 6.833090e-05
## Aphelenchus             3.000300e-04 7.100659e-05 7.100659e-05 7.100659e-05
## Cruznema                2.816901e-04 3.052503e-03 1.128791e-02 1.209655e-03
## Aphelenchoides          2.000200e-03 2.414224e-04 1.133324e-03 3.848903e-03
## Anaplectus              3.500350e-03 1.099687e-04 1.269323e-03 2.199373e-04
## Metateratocephalus      7.150715e-03 3.287311e-03 1.669131e-04 1.669131e-04
## Plectus                 1.900190e-03 6.574622e-04 1.011970e-04 1.011970e-04
## Paramphidelus           5.500550e-04 1.690617e-03 1.597253e-04 1.597253e-04
## Filenchus               9.237753e-05 9.237753e-05 9.237753e-05 9.237753e-05
## Ditylenchus             3.650365e-03 1.559495e-04 1.559495e-04 3.848903e-04
## Sectonema               7.918074e-05 3.057199e-02 7.918074e-05 7.918074e-05
## Chiloplacus             8.500850e-04 3.416545e-04 3.416545e-04 1.264640e-03
## Bastiania               4.189184e-05 9.392317e-05 4.189184e-05 4.189184e-05
## Clarkus                 5.782687e-05 1.878463e-04 5.782687e-05 5.782687e-05
## Trischistoma            1.156337e-04 1.156337e-04 1.156337e-04 3.079122e-03
## Tylencholaimus          3.050305e-03 1.924452e-04 1.924452e-04 3.848903e-04
## Zeldia                  4.189184e-04 4.189184e-04 4.189184e-04 4.189184e-04
## Zeatylenchus            2.400240e-03 1.047296e-04 1.047296e-04 1.047296e-04
## Prismatolaimus          2.111486e-04 2.111486e-04 2.111486e-04 2.111486e-04
## Diploscapter            4.118382e-04 4.118382e-04 4.118382e-04 4.118382e-04
## Prodesmodora            1.246417e-04 1.246417e-04 1.246417e-04 1.246417e-04
## Panagrolaimus           2.804437e-04 2.804437e-04 2.804437e-04 2.804437e-04
## Diphascon               9.303624e-05 9.303624e-05 9.303624e-05 9.303624e-05
## Mesaphorura             1.451647e-04 1.451647e-04 1.451647e-04 1.451647e-04
## Tullbergia              4.337015e-05 4.337015e-05 4.337015e-05 4.337015e-05
## Spelobia                4.856419e-03 4.856419e-03 4.856419e-03 4.856419e-03
## Bunonema                8.140671e-04 8.140671e-04 8.140671e-04 8.140671e-04
## Aquatides               6.809430e-04 1.361886e-03 6.809430e-04 6.809430e-04
## Myolaimus               4.354941e-04 4.354941e-04 4.354941e-04 4.354941e-04
## Altainella              3.770265e-04 3.770265e-04 3.770265e-04 3.770265e-04
## Dicyrtomina             2.816901e-04 2.816901e-04 2.816901e-04 2.816901e-04
## Anguina                 1.878463e-04 3.756927e-04 1.878463e-04 1.878463e-04
## Deladenus               1.594388e-04 1.594388e-04 1.594388e-04 1.594388e-04
## Geobacter               1.590239e-04 1.590239e-04 1.590239e-04 1.590239e-04
## NA.                     1.586654e-04 1.586654e-04 3.173308e-04 1.586654e-04
## Odontocepheus           1.559495e-04 1.559495e-04 1.559495e-04 1.559495e-04
## Theristus               1.138848e-04 1.138848e-04 1.138848e-04 1.138848e-04
## Thonus                  8.378367e-05 8.378367e-05 8.378367e-05 8.378367e-05
## Candidatus.Acetothermum 8.378367e-05 8.378367e-05 8.378367e-05 8.378367e-05
## Sellnickochthonius      2.639358e-05 2.639358e-05 2.639358e-05 2.639358e-05
##                                    9           10           11           12
## Globodera               7.288732e-01 7.262720e-01 6.823507e-01 6.584559e-01
## Meloidogyne             3.880282e-02 1.998612e-01 1.409697e-01 1.735998e-01
## Pristionchus            1.004225e-01 2.835338e-02 8.288670e-02 1.135269e-02
## Rhabditis               6.035211e-02 1.845513e-02 5.421912e-02 3.682292e-02
## Nygolaimus              1.901408e-03 1.433858e-03 9.971332e-04 1.675673e-03
## Acrobeloides            5.070423e-03 2.543941e-03 4.424779e-03 1.390809e-02
## Aporcelaimellus         2.014085e-02 7.493062e-03 6.855291e-03 5.990532e-03
## Pellioditis             2.894366e-02 5.134135e-03 5.733516e-03 9.174312e-02
## Cephaloboides           1.971831e-03 8.325624e-04 1.283809e-02 2.094592e-04
## Eucephalobus            9.154930e-04 4.162812e-04 3.739250e-04 2.094592e-04
## Acrobeles               2.535211e-03 6.197965e-03 6.855291e-04 5.864857e-04
## Mesorhabditis           3.521127e-04 8.247649e-05 9.348124e-04 8.247649e-05
## Pratylenchus            7.100659e-05 1.850139e-04 9.971332e-04 7.100659e-05
## Hypsibius               6.833090e-05 1.850139e-04 6.833090e-05 6.833090e-05
## Aphelenchus             2.816901e-04 4.162812e-04 7.100659e-05 5.864857e-04
## Cruznema                5.633803e-04 2.816901e-04 2.816901e-04 2.816901e-04
## Aphelenchoides          2.414224e-04 2.414224e-04 2.414224e-04 2.414224e-04
## Anaplectus              9.859155e-04 1.099687e-04 6.855291e-04 1.099687e-04
## Metateratocephalus      6.338028e-04 4.625347e-04 1.669131e-04 3.770265e-04
## Plectus                 3.028169e-03 1.011970e-04 4.362458e-04 1.011970e-04
## Paramphidelus           1.126761e-03 1.597253e-04 1.597253e-04 1.885133e-03
## Filenchus               9.154930e-04 2.775208e-04 3.116041e-04 2.513510e-04
## Ditylenchus             8.450704e-04 1.559495e-04 1.559495e-04 1.559495e-04
## Sectonema               7.918074e-05 2.775208e-04 7.918074e-05 7.918074e-05
## Chiloplacus             3.416545e-04 3.416545e-04 3.416545e-04 3.416545e-04
## Bastiania               7.746479e-04 1.387604e-04 4.189184e-05 8.378367e-05
## Clarkus                 5.782687e-05 5.782687e-05 5.782687e-05 5.782687e-05
## Trischistoma            1.156337e-04 2.312673e-04 1.156337e-04 1.156337e-04
## Tylencholaimus          1.924452e-04 1.924452e-04 1.924452e-04 1.924452e-04
## Zeldia                  4.189184e-04 4.189184e-04 2.929079e-03 8.378367e-04
## Zeatylenchus            1.047296e-04 3.700278e-04 1.047296e-04 2.094592e-04
## Prismatolaimus          2.111486e-04 4.625347e-04 5.608874e-04 2.111486e-04
## Diploscapter            4.118382e-04 4.118382e-04 4.118382e-04 4.118382e-04
## Prodesmodora            1.246417e-04 1.246417e-04 2.492833e-04 1.246417e-04
## Panagrolaimus           2.804437e-04 2.804437e-04 5.608874e-04 2.804437e-04
## Diphascon               9.303624e-05 9.303624e-05 9.303624e-05 9.303624e-05
## Mesaphorura             1.451647e-04 1.451647e-04 1.451647e-04 1.451647e-04
## Tullbergia              4.337015e-05 4.337015e-05 4.337015e-05 1.256755e-04
## Spelobia                4.856419e-03 4.856419e-03 4.856419e-03 4.856419e-03
## Bunonema                8.140671e-04 8.140671e-04 8.140671e-04 8.140671e-04
## Aquatides               6.809430e-04 6.809430e-04 6.809430e-04 6.809430e-04
## Myolaimus               4.354941e-04 4.354941e-04 4.354941e-04 4.354941e-04
## Altainella              3.770265e-04 3.770265e-04 3.770265e-04 7.540530e-04
## Dicyrtomina             5.633803e-04 2.816901e-04 2.816901e-04 2.816901e-04
## Anguina                 1.878463e-04 1.878463e-04 1.878463e-04 1.878463e-04
## Deladenus               1.594388e-04 1.594388e-04 1.594388e-04 1.594388e-04
## Geobacter               1.590239e-04 1.590239e-04 1.590239e-04 1.590239e-04
## NA.                     1.586654e-04 1.586654e-04 1.586654e-04 1.586654e-04
## Odontocepheus           1.559495e-04 1.559495e-04 1.559495e-04 1.559495e-04
## Theristus               1.138848e-04 1.138848e-04 1.138848e-04 1.138848e-04
## Thonus                  8.378367e-05 8.378367e-05 8.378367e-05 1.675673e-04
## Candidatus.Acetothermum 8.378367e-05 8.378367e-05 8.378367e-05 1.675673e-04
## Sellnickochthonius      2.639358e-05 2.639358e-05 2.639358e-05 2.639358e-05
##                                   13           14           15           16
## Globodera               6.070910e-01 5.876176e-01 5.180925e-01 6.273754e-02
## Meloidogyne             2.026938e-02 3.679888e-01 2.289820e-01 6.050728e-01
## Pristionchus            2.396012e-01 9.356968e-03 7.322200e-02 1.390942e-01
## Rhabditis               6.727849e-02 1.398347e-02 1.427800e-01 7.242399e-02
## Nygolaimus              1.716625e-03 1.299579e-03 3.976369e-04 3.035262e-03
## Acrobeloides            9.573485e-03 1.871394e-03 5.850943e-03 2.190667e-02
## Aporcelaimellus         4.489634e-03 5.926080e-03 1.334924e-03 1.470122e-02
## Pellioditis             4.417008e-02 8.785154e-03 1.448534e-02 9.976774e-03
## Cephaloboides           3.961442e-04 1.047296e-04 9.259259e-03 1.805321e-02
## Eucephalobus            2.640961e-04 2.599158e-04 1.047296e-04 6.598395e-04
## Acrobeles               1.254457e-03 1.507512e-03 4.555394e-05 3.827069e-03
## Mesorhabditis           5.281923e-04 8.247649e-05 1.050898e-03 5.225929e-03
## Pratylenchus            9.243365e-04 7.100659e-05 1.420132e-04 2.111486e-03
## Hypsibius               2.640961e-04 6.833090e-05 3.976369e-04 1.821157e-03
## Aphelenchus             7.100659e-05 7.100659e-05 1.420132e-04 6.070524e-04
## Cruznema                1.320481e-03 2.816901e-04 1.107703e-03 9.633657e-03
## Aphelenchoides          2.414224e-04 2.414224e-04 4.828448e-04 1.055743e-03
## Anaplectus              1.099687e-04 1.099687e-04 1.099687e-04 4.750845e-04
## Metateratocephalus      1.669131e-04 1.669131e-04 1.669131e-04 1.583615e-03
## Plectus                 1.011970e-04 1.011970e-04 1.011970e-04 1.011970e-04
## Paramphidelus           1.597253e-04 7.797474e-04 1.597253e-04 6.519215e-03
## Filenchus               9.237753e-05 9.237753e-05 9.237753e-05 1.847551e-04
## Ditylenchus             5.942163e-04 3.118989e-04 1.559495e-04 6.334459e-04
## Sectonema               2.640961e-04 7.918074e-05 7.918074e-05 1.583615e-04
## Chiloplacus             3.416545e-04 3.416545e-04 1.278119e-03 1.847551e-03
## Bastiania               4.189184e-05 4.189184e-05 4.189184e-05 4.486909e-04
## Clarkus                 5.782687e-05 5.782687e-05 1.704158e-04 5.782687e-05
## Trischistoma            1.156337e-04 1.156337e-04 1.156337e-04 1.741976e-03
## Tylencholaimus          1.924452e-04 1.924452e-04 1.924452e-04 5.278716e-04
## Zeldia                  4.189184e-04 4.189184e-04 4.189184e-04 4.189184e-04
## Zeatylenchus            1.047296e-04 1.047296e-04 1.047296e-04 1.047296e-04
## Prismatolaimus          2.111486e-04 2.111486e-04 2.111486e-04 4.222973e-04
## Diploscapter            4.118382e-04 4.118382e-04 8.236764e-04 4.118382e-04
## Prodesmodora            1.246417e-04 1.246417e-04 1.246417e-04 1.425253e-03
## Panagrolaimus           2.804437e-04 2.804437e-04 2.804437e-04 6.862331e-04
## Diphascon               9.303624e-05 9.303624e-05 9.303624e-05 4.750845e-04
## Mesaphorura             1.451647e-04 1.451647e-04 1.451647e-04 2.903294e-04
## Tullbergia              4.337015e-05 4.337015e-05 4.337015e-05 4.337015e-05
## Spelobia                4.856419e-03 4.856419e-03 4.856419e-03 9.712838e-03
## Bunonema                8.140671e-04 8.140671e-04 8.140671e-04 8.140671e-04
## Aquatides               6.809430e-04 6.809430e-04 6.809430e-04 6.809430e-04
## Myolaimus               4.354941e-04 4.354941e-04 4.354941e-04 8.709882e-04
## Altainella              3.770265e-04 3.770265e-04 3.770265e-04 3.770265e-04
## Dicyrtomina             2.816901e-04 2.816901e-04 2.816901e-04 2.816901e-04
## Anguina                 1.878463e-04 1.878463e-04 1.878463e-04 1.878463e-04
## Deladenus               1.594388e-04 1.594388e-04 1.594388e-04 1.594388e-04
## Geobacter               1.590239e-04 1.590239e-04 1.590239e-04 1.590239e-04
## NA.                     1.586654e-04 1.586654e-04 1.586654e-04 1.586654e-04
## Odontocepheus           1.559495e-04 3.118989e-04 1.559495e-04 1.559495e-04
## Theristus               1.138848e-04 1.138848e-04 1.138848e-04 1.138848e-04
## Thonus                  8.378367e-05 8.378367e-05 8.378367e-05 8.378367e-05
## Candidatus.Acetothermum 8.378367e-05 8.378367e-05 8.378367e-05 8.378367e-05
## Sellnickochthonius      2.639358e-05 2.639358e-05 2.639358e-05 5.278716e-05
##                                   17           18
## Globodera               2.338695e-01 2.761935e-01
## Meloidogyne             1.566616e-01 3.619716e-01
## Pristionchus            3.462822e-01 9.648324e-02
## Rhabditis               5.256449e-02 1.953808e-01
## Nygolaimus              5.827011e-03 1.002187e-03
## Acrobeloides            7.465857e-03 6.195335e-03
## Aporcelaimellus         8.376328e-03 6.741983e-03
## Pellioditis             4.564492e-02 1.093294e-02
## Cephaloboides           8.758725e-02 3.325437e-03
## Eucephalobus            3.095599e-03 1.047296e-04
## Acrobeles               9.711684e-04 9.110787e-05
## Mesorhabditis           4.309560e-03 2.186589e-03
## Pratylenchus            8.497724e-04 8.655248e-04
## Hypsibius               6.833090e-05 1.366618e-04
## Aphelenchus             1.396055e-02 7.100659e-05
## Cruznema                1.566009e-02 2.291363e-02
## Aphelenchoides          2.414224e-04 4.145408e-03
## Anaplectus              9.711684e-04 1.685496e-03
## Metateratocephalus      1.669131e-04 1.138848e-03
## Plectus                 6.069803e-04 2.049927e-03
## Paramphidelus           1.597253e-04 1.597253e-04
## Filenchus               9.237753e-05 8.199708e-04
## Ditylenchus             1.559495e-04 1.559495e-04
## Sectonema               4.855842e-04 4.555394e-04
## Chiloplacus             1.760243e-03 6.833090e-04
## Bastiania               4.189184e-05 4.189184e-05
## Clarkus                 1.213961e-04 5.782687e-05
## Trischistoma            1.156337e-04 1.156337e-04
## Tylencholaimus          1.924452e-04 1.924452e-04
## Zeldia                  4.189184e-04 2.687682e-03
## Zeatylenchus            1.274659e-03 1.047296e-04
## Prismatolaimus          2.111486e-04 1.047741e-03
## Diploscapter            1.165402e-02 4.118382e-04
## Prodesmodora            1.246417e-04 1.246417e-04
## Panagrolaimus           2.804437e-04 2.804437e-04
## Diphascon               9.303624e-05 9.303624e-05
## Mesaphorura             1.451647e-04 3.188776e-04
## Tullbergia              4.337015e-05 4.337015e-05
## Spelobia                4.856419e-03 4.856419e-03
## Bunonema                8.140671e-04 8.140671e-04
## Aquatides               6.809430e-04 6.809430e-04
## Myolaimus               4.354941e-04 4.354941e-04
## Altainella              3.770265e-04 3.770265e-04
## Dicyrtomina             2.816901e-04 2.816901e-04
## Anguina                 1.878463e-04 1.878463e-04
## Deladenus               1.594388e-04 3.188776e-04
## Geobacter               1.590239e-04 1.590239e-04
## NA.                     1.586654e-04 1.586654e-04
## Odontocepheus           1.559495e-04 1.559495e-04
## Theristus               1.138848e-04 2.277697e-04
## Thonus                  8.378367e-05 8.378367e-05
## Candidatus.Acetothermum 8.378367e-05 8.378367e-05
## Sellnickochthonius      2.639358e-05 2.639358e-05
## 
## $meta.dat.use
##       ndvi_01
## 1  -1.1410253
## 2  -1.9625407
## 3   0.5747102
## 4  -1.0529250
## 5  -0.7571646
## 6  -1.9896865
## 7   0.5945529
## 8   0.3130208
## 9  -0.8421145
## 10  0.5095020
## 11  0.6619353
## 12  0.3558477
## 13  0.6228720
## 14  0.6121273
## 15  0.9980715
## 16  0.6887884
## 17  0.9838132
## 18  0.8302155
## 
## $wald
## $wald$beta
##              Globodera Meloidogyne Pristionchus Rhabditis Nygolaimus
## (Intercept) 10.1047233    6.496183    6.6186168 6.3658080  2.2073429
## ndvi_01     -0.4738524    2.747166    0.2991004 0.4253496 -0.8606651
##             Acrobeloides Aporcelaimellus Pellioditis Cephaloboides Eucephalobus
## (Intercept)    2.6788599       3.6747802   4.6182753     1.5630598  -0.08481149
## ndvi_01        0.7763032      -0.3585514  -0.2782907     0.5733044  -0.43302585
##               Acrobeles Mesorhabditis Pratylenchus  Hypsibius  Aphelenchus
## (Intercept) -0.07274706    -0.3862146   -0.8045352 -1.4961972 -1.114326359
## ndvi_01      0.50561441     0.6668211    0.6661323 -0.3072165  0.007409314
##              Cruznema Aphelenchoides  Anaplectus Metateratocephalus    Plectus
## (Intercept) 0.9927140      0.2624983 -0.57883414         -0.3524108 -0.6559045
## ndvi_01     0.7845971     -0.2341110 -0.01794904         -0.7686285 -0.7034979
##             Paramphidelus  Filenchus Ditylenchus  Sectonema Chiloplacus
## (Intercept)    -0.4603681 -1.4003298  -0.6860119 -1.5545764   0.1470745
## ndvi_01        -0.3519134 -0.3794304  -0.5639328 -0.8565931   0.2001239
##              Bastiania    Clarkus Trischistoma Tylencholaimus     Zeldia
## (Intercept) -2.8025871 -2.5181936   -1.3150763     -0.9533033 0.22372041
## ndvi_01     -0.3546597 -0.5762215   -0.0988178     -0.0795614 0.04383992
##             Zeatylenchus Prismatolaimus Diploscapter Prodesmodora Panagrolaimus
## (Intercept)  -1.67711201     -0.9484702   0.01373187   -1.7831843   -0.73683560
## ndvi_01       0.04498005      0.2042330   0.29987259    0.1434408    0.05331597
##                Diphascon Mesaphorura Tullbergia    Spelobia    Bunonema
## (Intercept) -2.269719357 -1.69550491 -3.4162203 3.305552544  0.72887925
## ndvi_01     -0.004556226  0.05803299 -0.1212424 0.002588669 -0.09986506
##              Aquatides    Myolaimus  Altainella Dicyrtomina    Anguina
## (Intercept)  0.4712656 -0.173615293 -0.38160243 -0.80215936 -1.3867154
## ndvi_01     -0.1549687  0.002588669 -0.01699608 -0.08746444 -0.1549687
##               Deladenus  Geobacter          NA. Odontocepheus   Theristus
## (Intercept) -1.62326589 -1.6270250 -1.630280895  -1.655189754 -2.10869272
## ndvi_01      0.01090791 -0.1533719 -0.002954595  -0.001920806  0.01090791
##                  Thonus Candidatus.Acetothermum Sellnickochthonius
## (Intercept) -2.55152743             -2.55152743       -4.218009412
## ndvi_01     -0.01699608             -0.01699608        0.002588669
## 
## $wald$sig
##               Globodera             Meloidogyne            Pristionchus 
##               1.2342725               1.6541912               1.3613582 
##               Rhabditis              Nygolaimus            Acrobeloides 
##               1.1193531               1.4884675               1.0139656 
##         Aporcelaimellus             Pellioditis           Cephaloboides 
##               0.6831587               1.7946175               2.4592792 
##            Eucephalobus               Acrobeles           Mesorhabditis 
##               1.8784209               2.4573375               1.7428159 
##            Pratylenchus               Hypsibius             Aphelenchus 
##               1.4510802               1.4464847               1.9989081 
##                Cruznema          Aphelenchoides              Anaplectus 
##               2.0341758               1.5922080               1.6969377 
##      Metateratocephalus                 Plectus           Paramphidelus 
##               1.3691205               1.7560392               1.5245705 
##               Filenchus             Ditylenchus               Sectonema 
##               1.4308885               1.2144454               1.9432420 
##             Chiloplacus               Bastiania                 Clarkus 
##               0.7629270               1.1888784               0.9725051 
##            Trischistoma          Tylencholaimus                  Zeldia 
##               1.5303270               1.0472285               1.1884082 
##            Zeatylenchus          Prismatolaimus            Diploscapter 
##               1.3066891               0.6499247               1.0620379 
##            Prodesmodora           Panagrolaimus               Diphascon 
##               0.7111901               0.4222793               0.4651313 
##             Mesaphorura              Tullbergia                Spelobia 
##               0.3638551               0.6633789               0.3495281 
##                Bunonema               Aquatides               Myolaimus 
##               0.4246029               0.4545341               0.3495281 
##              Altainella             Dicyrtomina                 Anguina 
##               0.5147803               0.4577093               0.4545341 
##               Deladenus               Geobacter                     NA. 
##               0.4418165               0.5181055               0.5137543 
##           Odontocepheus               Theristus                  Thonus 
##               0.5573384               0.4418165               0.5147803 
## Candidatus.Acetothermum      Sellnickochthonius 
##               0.5147803               0.3495281 
## 
## $wald$X
##    (Intercept)    ndvi_01
## 1            1 -1.1410253
## 2            1 -1.9625407
## 3            1  0.5747102
## 4            1 -1.0529250
## 5            1 -0.7571646
## 6            1 -1.9896865
## 7            1  0.5945529
## 8            1  0.3130208
## 9            1 -0.8421145
## 10           1  0.5095020
## 11           1  0.6619353
## 12           1  0.3558477
## 13           1  0.6228720
## 14           1  0.6121273
## 15           1  0.9980715
## 16           1  0.6887884
## 17           1  0.9838132
## 18           1  0.8302155
## attr(,"assign")
## [1] 0 1
## 
## $wald$bias
## [1] -1.00756447 -0.01789055
# Show effect size and significance plots
linda.plot(
l_model,
variables.plot = c('ndvi_01'),
alpha = 0.05,
lfc.cut = 1,
legend = TRUE
)
## $plot.lfc
## $plot.lfc[[1]]

## 
## 
## $plot.volcano
## $plot.volcano[[1]]

# Write supplementary table for manuscript


l_model_df <- as.data.frame(l_model$output)

write.xlsx(l_model_df, file = "supplementary_table_ndvi_regression_nematodes.xlsx", rowNames = TRUE, colnames = TRUE)

Morph count and NDVI

# Prat

set$prat_data$ndvi_temp <- (set$prat_data$ndvi+1)/2

model_prat_count_ndvi = glm(
  ndvi_temp ~ total_count,
  data = set$prat_data,
  family = quasibinomial 
)

summary(model_prat_count_ndvi)
## 
## Call:
## glm(formula = ndvi_temp ~ total_count, family = quasibinomial, 
##     data = set$prat_data)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept) 0.263912   0.203506   1.297   0.2131  
## total_count 0.011331   0.004609   2.459   0.0257 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 0.0613813)
## 
##     Null deviance: 1.4028  on 17  degrees of freedom
## Residual deviance: 1.0038  on 16  degrees of freedom
## AIC: NA
## 
## Number of Fisher Scoring iterations: 4
# Glob

set$glob_data$ndvi_temp <- (set$glob_data$ndvi+1)/2

model_glob_count_ndvi = glm(
  ndvi_temp ~ total_count,
  data = set$glob_data,
  family = quasibinomial 
)

summary(model_glob_count_ndvi)
## 
## Call:
## glm(formula = ndvi_temp ~ total_count, family = quasibinomial, 
##     data = set$glob_data)
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  1.149679   0.287632   3.997  0.00104 **
## total_count -0.004626   0.002444  -1.893  0.07662 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 0.07214207)
## 
##     Null deviance: 1.4028  on 17  degrees of freedom
## Residual deviance: 1.1402  on 16  degrees of freedom
## AIC: NA
## 
## Number of Fisher Scoring iterations: 4
# Mel

set$mel_data$ndvi_temp <- (set$mel_data$ndvi+1)/2

model_mel_count_ndvi = glm(
  ndvi_temp ~ total_count,
  data = set$mel_data,
  family = quasibinomial 
)

summary(model_mel_count_ndvi)
## 
## Call:
## glm(formula = ndvi_temp ~ total_count, family = quasibinomial, 
##     data = set$mel_data)
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.1416789  0.1490480   0.951 0.355967    
## total_count 0.0024307  0.0005518   4.405 0.000443 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 0.0369228)
## 
##     Null deviance: 1.40277  on 17  degrees of freedom
## Residual deviance: 0.59886  on 16  degrees of freedom
## AIC: NA
## 
## Number of Fisher Scoring iterations: 4
data_mol_morph_long_temp <- pivot_longer(set$data_mol_morph, 
                                        cols = c(Genus_Sample_Abundance, 
                                                 total_count),
                                        names_to = "type", 
                                        values_to = "value")

data_mol_morph_long_temp$ndvi <- (data_mol_morph_long_temp$ndvi+1)/2
  

pval_glm <- function(glm){
  coef(summary(glm))[,4][2]
}

set$data_mol_morph_long <- data_mol_morph_long_temp %>% 
  mutate(pval = ifelse(Genus == "Globodera", pval_glm(model_glob), NA)) %>% 
  mutate(pval = ifelse(Genus == "Pratylenchus", pval_glm(model_prat), pval)) %>% 
  mutate(pval = ifelse(Genus == "Meloidogyne", pval_glm(model_mel), pval)) %>% 
  mutate(signif = ifelse(pval <= 0.05, "pval <= 0.05", "pval > 0.05"))



# Count data vs NDVI

plots$morph_count_ndvi <- ggplot(set$data_mol_morph_long, 
                                 aes(x = value, 
                                     y = ndvi)) +
  geom_point(alpha = 0.7) +
  #ggtitle(set$plot_title) +
  theme(plot.title = element_text(hjust = 0.5, size = 20), 
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        axis.line = element_line(colour = "dark grey"),
        strip.background = element_blank(), 
        strip.text.x = element_text(face = "italic")#,
        #axis.text = element_text(size = 12),
        #text = element_text(size = 14)
        ) +
  #xlab("Nematodes / 250 ml soil") + 
  #ylab("NDVI") +
  geom_smooth(method = "glm", formula = set$my_formula, se = F, color = "dark grey",
              method.args = list(family = quasibinomial)) +
  facet_wrap(~Genus, scales = "free_x") 



plots$morph_count_ndvi

# Print and save plot
plots$morph_count_ndvi

save_plot(plots$morph_count_ndvi, plot_name = paste0("morph_count_ndvi"), 
          filetype = tmp$out)

Plotting mol+morph+NDVI

set$data_mol_morph_long <- data_mol_morph_long_temp %>% 
  mutate(pval = ifelse(Genus == "Globodera", pval_glm(model_glob_count_ndvi), NA)) %>% 
  mutate(pval = ifelse(Genus == "Pratylenchus", pval_glm(model_prat_count_ndvi), pval)) %>% 
  mutate(pval = ifelse(Genus == "Meloidogyne", pval_glm(model_mel_count_ndvi), pval)) %>%
  mutate(pval = ifelse(Genus == "Globodera" & type == "Genus_Sample_Abundance", 0.5574120890, pval)) %>%
  mutate(pval = ifelse(Genus == "Pratylenchus" & type == "Genus_Sample_Abundance", 0.5177548997, pval)) %>%
  mutate(pval = ifelse(Genus == "Meloidogyne" & type == "Genus_Sample_Abundance", 0.0001920515, pval)) %>%
  mutate(signif = ifelse(pval <= 0.05, "pval <= 0.05", "pval > 0.05"))



# Morph data

set$data_morph <- set$data_mol_morph_long[set$data_mol_morph_long$type == 'total_count',]
set$data_morph <- set$data_morph %>%
  dplyr::rename("Number_of_nematodes" = value)

# Relative abundance data

set$data_relabu <- set$data_mol_morph_long[set$data_mol_morph_long$type == 'Genus_Sample_Abundance',]
set$data_relabu <- set$data_relabu %>%
  dplyr::rename("Relative_abundance" = value)

Morph and metabarcoding vs NDVI plotting

signif.labs <- c("pval > 0.05", "pval <= 0.05")
names(signif.labs) <- c("p value > 0.05", "p value <= 0.05")
breaks_morph <- function(x) { if (max(x) < 200) seq (0, 100, 100) else seq(0, 600, 50)}
breaks_mb <- function(x) { if (max(x) < 0.1) seq(0, 0.002, 3) else seq(0, 3, 1) }

breaks_fun_morph <- function(x) {
if (max(x) > 500) {
    seq(0, 800, 200)
} else if (max(x) > 150) {
    seq(0, 200, length.out = 5)
} else {
    seq(0, 100, length.out = 5)
}}



# MORPHOLOGIAL AND NDVI PLOT


# Relative abundance and NDVI plotting

# Axis ticks MB

breaks_fun_mb <- function(x) {
if (max(x) > 0.8) {
    seq(0, 0.9, length.out = 4)
} else if (max(x) > 0.2) {
    seq(0, 0.6, 0.2)
} else {
    seq(0, 0.003, length.out = 4)
}}


p1 <- ggplot(set$data_relabu,
             aes(x = Relative_abundance,
                 y = ndvi)) +
  geom_point(alpha = 0.7, color = "black") +
  ggtitle("a)") +
  theme(plot.title = element_text(hjust = 0, size = 12), 
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        strip.background = element_blank(), 
        axis.title = element_text(size = 9),
        strip.text.x = element_text(face = "italic"),
        plot.caption = element_text(size = 7, hjust = 0, face = "italic", 
                                    margin = margin(t = 0.2, unit = "cm")),
        plot.caption.position = "plot",
        plot.subtitle = element_text(size = 10, hjust = 0, vjust = 0.5, 
                                     margin = margin(b = 0.8, unit = "cm"))) +
  xlab("Relative abundance") + 
  ylab("NDVI") +
  geom_smooth(method = "glm", formula = set$my_formula, se = FALSE,
              method.args = list(family = quasibinomial), 
              aes(color = signif, linetype = signif)) +
  scale_color_manual(values=c('black', 'lightgrey'),
                     name= 'Significance',
                     labels = names(signif.labs)) +
  scale_linetype_discrete(name= 'Significance',
                     labels = names(signif.labs)) +
  facet_wrap(~Genus, scales = "free_x") +
  scale_x_continuous(breaks = breaks_fun_mb, limits = c(0, NA))


p1

# Plotting NDVI vs metabarcoding

p2 <- ggplot(set$data_morph,
              aes(x = Number_of_nematodes,
                  y = ndvi)) +
   geom_point(alpha = 0.7, color = "black") +
   ggtitle("b)") +
   theme(plot.title = element_text(hjust = 0, size = 12), 
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        strip.background = element_blank(), 
        axis.title = element_text(size = 9),
        panel.spacing=unit(2, "lines"),
        strip.text.x = element_text(face = "italic"),
        plot.caption = element_text(size = 7, hjust = 0, face = "italic", 
                                    margin = margin(t = 0.2, unit = "cm")),
        plot.caption.position = "plot",
        plot.subtitle = element_text(size = 10, hjust = 0, vjust = 0.5, 
                                     margin = margin(b = 0.8, unit = "cm"))) +
  xlab("Nematodes / 250 ml soil") + 
  ylab("NDVI") +
  geom_smooth(method = "glm", formula = set$my_formula, se = FALSE,
              method.args = list(family = quasibinomial), 
              aes(color = signif, linetype = signif)) +
  
  scale_color_manual(values=c('black', 'lightgrey'),
                     name= 'Significance',
                     labels = names(signif.labs)) +
  scale_linetype_discrete(name= 'Significance',
                     labels = names(signif.labs)) +
  facet_wrap(~Genus, scales = "free_x") + 
  scale_x_continuous(breaks = breaks_fun_morph, limits = c(0, NA))


p2

# Combining the two plots

plots$combo_morph_metab_ndvi <- plot_grid(p1, p2,
                                          ncol = 1,
                                          align = "hv")

plots$combo_morph_metab_ndvi

# Print and save plot
save_plot(plots$combo_morph_metab_ndvi, plot_name = paste0("morph_relabu_ndvi"), 
          filetype = tmp$out)

Pratylenchus Mann-Whitney U test

found <- c(40, 24, 16, 37, 10, 27, 74, 100, 100, 78, 32, 28)
not_found <- c(24,12, 7, 7, 24, 52)

wilcox.test(found, not_found)
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  found and not_found
## W = 58, p-value = 0.04339
## alternative hypothesis: true location shift is not equal to 0
Credit

This script is based on ideas and code from the dada2 Tutorial by Benjamin Callahan, the publication “Bioconductor Workflow for Microbiome Data Analysis: from raw reads to community analyses” by Callahan et al. (2016) and various pages of the official phyloseq website by Paul J. McMurdie.

sessionInfo()
## R version 4.4.2 (2024-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.5 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
##  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
##  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
## [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
## 
## time zone: Europe/Oslo
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] MicrobiomeStat_1.2  aod_1.3.3           BBmisc_1.13        
##  [4] betareg_3.2-1       ggpmisc_0.6.1       ggpp_0.5.8-1       
##  [7] openxlsx_4.2.7.1    readxl_1.4.3        lubridate_1.9.4    
## [10] forcats_1.0.0       stringr_1.5.1       dplyr_1.1.4        
## [13] purrr_1.0.2         readr_2.1.5         tidyr_1.3.1        
## [16] tibble_3.2.1        tidyverse_2.0.0     cowplot_1.1.3      
## [19] ggpubr_0.6.0        viridis_0.6.5       viridisLite_0.4.2  
## [22] phangorn_2.12.1     biomformat_1.34.0   vegan_2.6-8        
## [25] lattice_0.22-6      permute_0.9-7       scales_1.3.0       
## [28] gridExtra_2.3       ape_5.8-1           reshape2_1.4.4     
## [31] phyloseq_1.50.0     ggplot2_3.5.1       cuphyr_0.3         
## [34] DECIPHER_3.2.0      Biostrings_2.74.0   GenomeInfoDb_1.42.1
## [37] XVector_0.46.0      IRanges_2.40.0      S4Vectors_0.44.0   
## [40] BiocGenerics_0.52.0 dada2_1.34.0        Rcpp_1.0.13-1      
## 
## loaded via a namespace (and not attached):
##   [1] fs_1.6.5                    matrixStats_1.4.1          
##   [3] bitops_1.0-9                devtools_2.4.5             
##   [5] httr_1.4.7                  RColorBrewer_1.1-3         
##   [7] numDeriv_2016.8-1.1         profvis_0.4.0              
##   [9] tools_4.4.2                 backports_1.5.0            
##  [11] utf8_1.2.4                  R6_2.5.1                   
##  [13] mgcv_1.9-1                  rhdf5filters_1.18.0        
##  [15] urlchecker_1.0.1            withr_3.0.2                
##  [17] quantreg_5.99.1             cli_3.6.3                  
##  [19] Biobase_2.66.0              textshaping_0.4.1          
##  [21] formatR_1.14                sandwich_3.1-1             
##  [23] labeling_0.4.3              sass_0.4.9                 
##  [25] Rsamtools_2.22.0            systemfonts_1.1.0          
##  [27] sessioninfo_1.2.2           rstudioapi_0.17.1          
##  [29] generics_0.1.3              hwriter_1.3.2.1            
##  [31] vroom_1.6.5                 car_3.1-3                  
##  [33] zip_2.3.1                   Matrix_1.7-1               
##  [35] interp_1.1-6                abind_1.4-8                
##  [37] lifecycle_1.0.4             yaml_2.3.10                
##  [39] carData_3.0-5               SummarizedExperiment_1.36.0
##  [41] rhdf5_2.50.0                SparseArray_1.6.0          
##  [43] grid_4.4.2                  promises_1.3.2             
##  [45] crayon_1.5.3                pwalign_1.2.0              
##  [47] miniUI_0.1.1.1              pillar_1.10.0              
##  [49] knitr_1.49                  GenomicRanges_1.58.0       
##  [51] statip_0.2.3                boot_1.3-31                
##  [53] codetools_0.2-20            fastmatch_1.1-4            
##  [55] glue_1.8.0                  ShortRead_1.64.0           
##  [57] data.table_1.16.4           remotes_2.5.0              
##  [59] vctrs_0.6.5                 png_0.1-8                  
##  [61] cellranger_1.1.0            gtable_0.3.6               
##  [63] cachem_1.1.0                xfun_0.49                  
##  [65] S4Arrays_1.6.0              mime_0.12                  
##  [67] modeest_2.4.0               survival_3.8-3             
##  [69] timeDate_4041.110           iterators_1.0.14           
##  [71] statmod_1.5.0               ellipsis_0.3.2             
##  [73] nlme_3.1-166                usethis_3.1.0              
##  [75] bit64_4.5.2                 fBasics_4041.97            
##  [77] bslib_0.8.0                 rpart_4.1.23               
##  [79] colorspace_2.1-1            DBI_1.2.3                  
##  [81] nnet_7.3-19                 ade4_1.7-22                
##  [83] tidyselect_1.2.1            timeSeries_4041.111        
##  [85] bit_4.5.0.1                 compiler_4.4.2             
##  [87] curl_6.0.1                  SparseM_1.84-2             
##  [89] DelayedArray_0.32.0         checkmate_2.3.2            
##  [91] lmtest_0.9-40               quadprog_1.5-8             
##  [93] spatial_7.3-17              digest_0.6.37              
##  [95] minqa_1.2.8                 rmarkdown_2.29             
##  [97] htmltools_0.5.8.1           pkgconfig_2.0.3            
##  [99] jpeg_0.1-10                 lme4_1.1-35.5              
## [101] MatrixGenerics_1.18.0       stabledist_0.7-2           
## [103] fastmap_1.2.0               rlang_1.1.4                
## [105] htmlwidgets_1.6.4           UCSC.utils_1.2.0           
## [107] shiny_1.10.0                farver_2.1.2               
## [109] jquerylib_0.1.4             zoo_1.8-12                 
## [111] jsonlite_1.8.9              BiocParallel_1.40.0        
## [113] magrittr_2.0.3              polynom_1.4-1              
## [115] modeltools_0.2-23           Formula_1.2-5              
## [117] GenomeInfoDbData_1.2.13     Rhdf5lib_1.28.0            
## [119] munsell_0.5.1               stringi_1.8.4              
## [121] stable_1.1.6                zlibbioc_1.52.0            
## [123] MASS_7.3-61                 plyr_1.8.9                 
## [125] pkgbuild_1.4.5              flexmix_2.3-19             
## [127] ggrepel_0.9.6               deldir_2.0-4               
## [129] splines_4.4.2               multtest_2.62.0            
## [131] hms_1.1.3                   igraph_2.1.2               
## [133] ggsignif_0.6.4              rmutil_1.1.10              
## [135] pkgload_1.4.0               evaluate_1.0.1             
## [137] latticeExtra_0.6-30         RcppParallel_5.1.9         
## [139] nloptr_2.1.1                tzdb_0.4.0                 
## [141] foreach_1.5.2               httpuv_1.6.15              
## [143] MatrixModels_0.5-3          clue_0.3-66                
## [145] broom_1.0.7                 xtable_1.8-4               
## [147] rstatix_0.7.2               later_1.4.1                
## [149] ragg_1.3.3                  lmerTest_3.1-3             
## [151] memoise_2.0.1               GenomicAlignments_1.42.0   
## [153] cluster_2.1.8               timechange_0.3.0