Skip to contents

Create an UpSet plot (or Venn diagram) showing the shared taxonomic values at a specified rank across all phyloseq objects in a list_phyloseq.

Usage

upset_lpq(x, tax_rank = "Genus", plot_type = "auto", remove_na = TRUE, ...)

Arguments

x

(required) A list_phyloseq object.

tax_rank

(character, required) The name of the taxonomic rank column present in the @tax_table slot of each phyloseq object. For example, "Genus", "Family", or "Species".

plot_type

(character, default "auto") Type of plot to generate. One of "auto", "upset", or "venn". If "auto", uses Venn diagram for 4 or fewer phyloseq objects, UpSet plot otherwise.

remove_na

(logical, default TRUE) If TRUE, remove NA values from the taxonomic rank before computing intersections.

...

Additional arguments passed to ComplexUpset::upset() or ggVennDiagram::ggVennDiagram().

Value

A ggplot2 object (both UpSet and Venn diagrams)

Details

lifecycle-experimental

This function extracts the unique values for the specified taxonomic rank from each phyloseq object and creates a visualization showing the intersections between them. UpSet plots are generally better for visualizing complex intersections with more than 4 sets, while Venn diagrams work well for 2-4 sets.

See also

upset_lpq()

Examples

data("enterotype", package = "phyloseq")
# Subset to the 80 most abundant taxa to keep the example fast
# (the full data_fungi has 1420 taxa).
data_fungi_small <- prune_taxa(
  names(sort(taxa_sums(data_fungi), decreasing = TRUE))[1:80],
  data_fungi
)
data_fungi_small <- clean_pq(prune_samples(
  sample_sums(data_fungi_small) >= 500, data_fungi_small
))
lpq <- list_phyloseq(list(
  fung = data_fungi_small,
  fung_mini = data_fungi_mini,
  fung_rarefy = rarefy_even_depth(data_fungi_small),
  enterotype = enterotype
))
#> You set `rngseed` to FALSE. Make sure you've set & recorded
#>  the random seed of your session for reproducibility.
#> See `?set.seed`
#> ...
#>  Building summary table for 4 phyloseq objects...
#>  Computing comparison characteristics...
#>  Checking sample and taxa overlap...
#>  Detected comparison type: SEPARATE_ANALYSIS
#>  0 common samples, 0 common taxa
#>  Skipping refseq comparison (not all objects have refseq)
#>  list_phyloseq created (SEPARATE_ANALYSIS)
upset_lpq(lpq, plot_type = "upset")
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#>  Please use `linewidth` instead.
#>  The deprecated feature was likely used in the ComplexUpset package.
#>   Please report the issue at
#>   <https://github.com/krassowski/complex-upset/issues>.

lpq2 <- list_phyloseq(list(
  fung = data_fungi_small,
  fung_mini = data_fungi_mini
))
#>  Building summary table for 2 phyloseq objects...
#>  Computing comparison characteristics...
#>  Checking sample and taxa overlap...
#>  Detected comparison type: EXPLORATION
#>  118 common samples, 43 common taxa
#>  list_phyloseq created (EXPLORATION)
upset_lpq(lpq2, tax_rank = "Family")