Learn R Programming

LorMe (version 1.1.0)

differential_bar: Generate Differential Bar Plot and Error bar Plot

Description

Generate Differential Bar Plot and Error bar Plot

Usage

differential_bar(
  taxobj,
  taxlevel,
  comparison = NULL,
  rel_threshold = 0.005,
  anno_row = "taxonomy",
  aes_col = NULL,
  limit_num = NULL
)

Value

A list containing the bar plot, source data for the bar plot, difference plot, and source data for the difference plot.

Arguments

taxobj

Configured tax summary objects.See in object_config.

taxlevel

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

comparison

A vector of conditions to compare. Default: NULL, all unique conditions are compared (only for Two groups).

rel_threshold

Threshold filtering taxa for differential analysis. Default:0.005

anno_row

Default: 'taxonomy'. Rownames for visualization. Options are 'taxonomy' for showing taxonomic information and 'ID' for showing taxonomic ID.

aes_col

A named vector of colors to be used in the plots.

limit_num

Numeric. The maximum number of significant results to display. Default: NULL, showing all differential taxa.

Examples

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

  # Simple mode
  diff_results <- differential_bar(
    taxobj = Two_group,
    taxlevel = "Genus"
  )
  print(diff_results$Barplot)  # Print Barplot
  head(diff_results$Barplot_sourcedata)  # Show source data of barplot
  print(diff_results$Differenceplot)  # Print Differential errorbar plot
  head(diff_results$Differenceplot_sourcedata)  # Show source data of Differential errorbar plot

  require(patchwork)
  diff_results$Barplot|diff_results$Differenceplot
  # Displaying ID
  diff_results <- differential_bar(
    taxobj = Two_group,
    taxlevel = "Base",
    anno_row = "ID"
  )
  print(diff_results$Barplot)

  # Threshold adjustment
  diff_results <- differential_bar(
    taxobj = Two_group,
    taxlevel = "Base",
    rel_threshold = 0.001
  )
  print(diff_results$Barplot)

  # Limit the displaying number
  diff_results <- differential_bar(
    taxobj = Two_group,
    taxlevel = "Base",
    rel_threshold = 0.001,
    limit_num = 10
  )
  print(diff_results$Barplot)

  # For object with more than two groups
  # Data preparation
  data("Three_group")

  # Specific comparison
  Three_group_col <- Three_group$configuration$treat_col
  diff_results <- differential_bar(
    taxobj = Three_group,
    taxlevel = "Genus",
    comparison = c("BF", "CF"),
    aes_col = Three_group_col
  )
  print(diff_results$Barplot)
}

Run the code above in your browser using DataLab