This tutorial explore a phyloseq version of the dataset from Tengeler et al. (2020) available in the mia package.

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  fig.width = 10
)

Load library

library("MicrobiotaProcess")
library("MiscMetabar")
library("ggplot2")
library("patchwork")
library("iNEXT")
?Tengeler2020

Import dataset in phyloseq format

data(Tengeler2020_pq)
ten <- Tengeler2020_pq
summary_plot_pq(ten)

Alpha-diversity analysis

hill_pq(ten, "patient_status", one_plot = TRUE)
res_inext <-
  iNEXT_pq(ten,
    datatype = "abundance",
    merge_sample_by = "patient_status_vs_cohort",
    nboot = 5
  )
ggiNEXT(res_inext)
accu_plot(
  ten,
  fact = "sample_name",
  add_nb_seq = TRUE,
  by.fact = TRUE,
  step = 100
) + theme(legend.position = c(.8, .6))

Explore taxonomy

library(metacoder)
heat_tree_pq(ten,
  node_size = n_obs,
  node_color = nb_sequences,
  node_label = taxon_names,
  tree_label = taxon_names,
  node_size_trans = "log10 area"
)
treemap_pq(ten, lvl1 = "Order", lvl2 = "Family")

Beta-diversity analysis : effect of patient status and cohort

circle_pq(ten, "patient_status")
upset_pq(ten, "patient_status_vs_cohort")
ggvenn_pq(clean_pq(ten, force_taxa_as_columns = TRUE),
  "cohort",
  rarefy_before_merging = TRUE
) +
  theme(legend.position = "none")
ten_control <- clean_pq(subset_samples(ten, patient_status == "Control"))
p_control <- heat_tree_pq(ten_control,
  node_size = n_obs,
  node_color = nb_sequences,
  node_label = taxon_names,
  tree_label = taxon_names,
  node_size_trans = "log10 area"
)

ten_ADHD <- clean_pq(subset_samples(ten, patient_status == "ADHD"))
p_ADHD <- heat_tree_pq(ten_ADHD,
  node_size = n_obs,
  node_color = nb_sequences,
  node_label = taxon_names,
  tree_label = taxon_names,
  node_size_trans = "log10 area"
)

p_control + ggtitle("Control") + p_ADHD + ggtitle("ADHD")
knitr::kable(track_wkflow(list(
  "All samples" = ten,
  "Control samples" = ten_control,
  "ADHD samples" = ten_ADHD
)))
adonis_pq(ten, "cohort + patient_status")
ten@tax_table <- phyloseq::tax_table(cbind(
  ten@tax_table,
  "Species" = taxa_names(ten)
))

biplot_pq(subset_taxa_pq(ten, taxa_sums(ten) > 3000),
  merge_sample_by = "patient_status",
  fact = "patient_status",
  nudge_y = 0.4
)
multitax_bar_pq(ten, "Phylum", "Class", "Order", "patient_status")
multitax_bar_pq(ten, "Phylum", "Class", "Order", "patient_status",
  nb_seq = FALSE, log10trans = FALSE
)

Differential abundance analysis

plot_deseq2_pq(ten,
  contrast = c("patient_status", "ADHD", "Control"),
  taxolev = "Genus"
)
LEfSe <- diff_analysis(
  ten,
  classgroup = "patient_status",
  mlfun = "lda",
  ldascore = 2,
  p.adjust.methods = "bh"
)
library(ggplot2)
ggeffectsize(LEfSe) +
  scale_color_manual(values = c(
    "#00AED7",
    "#FD9347"
  )) +
  theme_bw()

Session information

sessionInfo()

References

Tengeler, A.C., Dam, S.A., Wiesmann, M. et al. Gut microbiota from persons with attention-deficit/hyperactivity disorder affects the brain in mice. Microbiome 8, 44 (2020). https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-020-00816-x



adrientaudiere/MiscMetabar documentation built on July 6, 2024, 7:02 p.m.