Skip to contents

Visualize prevalence proportions computed by count.feature.carriers() or basin.feature.carriers(). The input carriers.df must have columns k and p, with feature names in rownames(carriers.df).

The function can use either base R graphics or ggplot2, controlled by use.ggplot. Features can be restricted to the top top.m by prevalence or filtered by min.p.

Usage

# S3 method for class 'feature.prevalence'
plot(
  x,
  top.m = NULL,
  min.p = NULL,
  sort.by = c("p", "k"),
  decreasing = TRUE,
  use.ggplot = FALSE,
  plot.type = c("lollipop", "bar", "dot"),
  title = NULL,
  xlab = NULL,
  show.values = FALSE,
  cex.labels = 0.8,
  stick.col = "grey30",
  point.col = "black",
  bar.fill = "grey70",
  label.col = "black",
  label.font = 1,
  label.face = c("plain", "bold", "italic", "bold.italic"),
  ...
)

Arguments

x

A data.frame with columns k (integer) and p (numeric in \([0,1]\)) and row names corresponding to feature/phylotype names.

top.m

Optional integer; if provided, plot only the top.m most prevalent features by p.

min.p

Optional numeric in \([0,1]\); if provided, plot only features with p >= min.p. Applied after top.m if both are provided.

sort.by

Character string specifying sort key. One of "p" (default) or "k".

decreasing

Logical; if TRUE (default), sort decreasing.

use.ggplot

Logical; if TRUE use ggplot2 (requires ggplot2 installed), otherwise use base R graphics.

plot.type

Character string; one of "lollipop" (default), "bar", or "dot".

title

Optional plot title.

xlab

Optional x-axis label.

show.values

Logical; if TRUE, annotate prevalence values on the plot (ggplot2 only).

cex.labels

Numeric; base R only, label size for y-axis feature names.

stick.col

Color for stick/segment lines (lollipop only). Default "grey30".

point.col

Color for points (lollipop and dot). Default "black".

bar.fill

Fill color for bars (bar plot only). Default "grey70".

label.col

Color for feature (y-axis) labels. Default "black".

label.font

Base R only: font for y-axis labels (1=plain, 2=bold, 3=italic, 4=bold.italic). Default 1.

label.face

ggplot2 only: face for y-axis labels. One of "plain", "bold", "italic", "bold.italic". Default "plain".

...

Additional arguments passed to base plotting functions (base R) or ignored (ggplot2) except where supported.

Value

Invisibly returns the (possibly filtered/reordered) data.frame used for plotting. If use.ggplot=TRUE, also returns the ggplot object as attribute "plot".