Skip to contents

[Experimental] Note that this function use a sqrt of the read numbers in the linear model in order to correct for uneven sampling depth.

Usage

hill_pq(
  physeq,
  variable,
  color_fac = NA,
  letters = FALSE,
  add_points = FALSE,
  add_info = TRUE,
  one_plot = FALSE,
  correction_for_sample_size = TRUE
)

Arguments

physeq

(required): a phyloseq-class object obtained using the phyloseq package.

variable

(required): The variable to test. Must be present in the sam_data slot of the physeq object.

color_fac

(optional): The variable to color the barplot

letters

(optional, default=FALSE): If set to TRUE, the plot show letters based on p-values for comparison. Use the multcompLetters function from the package multcompLetters. BROKEN for the moment. Note that na values in The variable param need to be removed (see examples) to use letters.

add_points

(logical): add jitter point on boxplot

add_info

(logical, default TRUE) Do we add a subtitle with information about the number of samples per modality ?

one_plot

(logical, default FALSE) If TRUE, return a unique plot with the four plot inside using the patchwork package. Note that if letters and one_plot are both TRUE, tuckey HSD results are discarded from the unique plot. In that case, use one_plot = FALSE to see the tuckey HSD results in the fourth plot of the resulting list.

correction_for_sample_size

(logical, default TRUE) This function use a sqrt of the read numbers in the linear model in order to correct for uneven sampling depth.

Value

Either an unique ggplot2 object (if one_plot is TRUE) or a list of 4 ggplot2 plot:

  • plot_Hill_0 : the boxplot of Hill number 0 (= species richness) against the variable

  • plot_Hill_1 : the boxplot of Hill number 1 (= Shannon index) against the variable

  • plot_Hill_2 : the boxplot of Hill number 2 (= Simpson index) against the variable

  • plot_tuckey : plot the result of the Tuckey HSD test

Author

Adrien Taudière

Examples


p <- hill_pq(data_fungi, "Height")
#> Taxa are now in rows.
#> Cleaning suppress 0 taxa and 0 samples.
p_h1 <- p[[1]] + theme(legend.position = "none")
p_h2 <- p[[2]] + theme(legend.position = "none")
p_h3 <- p[[3]] + theme(legend.position = "none")
multiplot(plotlist = list(p_h1, p_h2, p_h3, p[[4]]), cols = 4)


# Artificially modify data_fungi to force alpha-diversity effect
data_fungi_modif <- clean_pq(subset_samples_pq(data_fungi, !is.na(data_fungi@sam_data$Height)))
#> Cleaning suppress 144 taxa and 0 samples.
data_fungi_modif@otu_table[data_fungi_modif@sam_data$Height == "High", ] <-
  data_fungi_modif@otu_table[data_fungi_modif@sam_data$Height == "High", ] +
  sample(c(rep(0, ntaxa(data_fungi_modif) / 2), rep(100, ntaxa(data_fungi_modif) / 2)))
p2 <- hill_pq(data_fungi_modif, "Height", letters = TRUE)
#> Taxa are now in rows.
#> Cleaning suppress 0 taxa and 0 samples.
#> Joining with `by = join_by(Height)`
#> Joining with `by = join_by(Height)`
#> Joining with `by = join_by(Height)`