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")
lpq <- list_phyloseq(list(
  fung = data_fungi,
  fung_mini = data_fungi_mini,
  fung_rarefy = rarefy_even_depth(data_fungi),
  enterotype = enterotype
))
#> You set `rngseed` to FALSE. Make sure you've set & recorded
#>  the random seed of your session for reproducibility.
#> See `?set.seed`
#> ...
#> 1016OTUs were removed because they are no longer 
#> present in any sample after random subsampling
#> ...
#>  Building summary table for 4 phyloseq objects...
#>  Computing comparison characteristics...
#>  Checking sample and taxa overlap...
#>  Detected comparison type: NESTED_ROBUSTNESS
#>  0 common samples, 0 common taxa
#>  Skipping refseq comparison (not all objects have refseq)
#>  list_phyloseq created (NESTED_ROBUSTNESS)
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,
  fung_mini = data_fungi_mini
))
#>  Building summary table for 2 phyloseq objects...
#>  Computing comparison characteristics...
#>  Checking sample and taxa overlap...
#>  Detected comparison type: NESTED_ROBUSTNESS
#>  137 common samples, 45 common taxa
#>  list_phyloseq created (NESTED_ROBUSTNESS)
upset_lpq(lpq2, tax_rank = "Family")