Learn R Programming

LorMe (version 1.1.0)

community_plot: Generate Community Composition Plot Based on Tax_summary Object

Description

Microbial community composition visualization in format of barplot, areaplot and alluvialplot

Usage

community_plot(
  taxobj,
  taxlevel,
  n = 10,
  palette = "Spectral",
  nrow = NULL,
  rmprefix = NULL
)

Value

community_plot2 returns three ggplot objects, two data frame used in visualization and one character of filled mapping colors

Arguments

taxobj

Configured tax summary objects.See in object_config.

taxlevel

Character. taxonomy levels used for visualization.Must be one of c("Domain","Phylum","Class","Order","Family","Genus","Species","Base").

n

Numeric. Top n taxa remained according to relative abundance. Default:10

palette

Character. Palette for visualization,default:"Spectral",recommended to use "Paired" for more than 15 tax.

nrow

Numeric. Number of rows when wrap panels,default:NULL.

rmprefix

Numeric. Removed prefix character in taxonomy annotation.Default:NULL. See details in example.

Author

Wang Ningqi2434066068@qq.com

Examples

Run this code
{
  require(magrittr)
  ### Data preparation ###
  data("Two_group")

  ## Use taxonomy summary objects
  phylum10 <- community_plot(
    taxobj = Two_group,
    taxlevel = "Phylum",
    n = 10,
    rmprefix = "p__"
  )

  phylum10$barplot  # Check bar plot
  phylum10$areaplot  # Check area plot
  phylum10$alluvialplot  # Check alluvial plot

  phylum10$Top10Phylum %>% head(10)  # Check top taxa data frame
  phylum10$Grouped_Top10Phylum %>% head(10)  # Check grouped top taxa data frame
  print(phylum10$filled_color)  # Check mapping colors

  # Double facet
  data("Facet_group")

  # Using palette by default
  phylum10 <- community_plot(
    taxobj = Facet_group,
    taxlevel = "Phylum",
    n = 10,
    rmprefix = " p__"
  )
  phylum10$barplot
  phylum10$areaplot
  phylum10$alluvialplot

  # Another example
  genus20 <- community_plot(
    taxobj = Facet_group,
    taxlevel = "Genus",
    n = 20,
    palette = "Paired",
    rmprefix = " g__"
  )
  genus20$alluvialplot
}

Run the code above in your browser using DataLab