mmplot: Visualise metagenomes in various ways

Description Usage Arguments Value Author(s) Examples

View source: R/mmplot.R

Description

Plots any information about the scaffolds contained in the given mm object as a scatterplot, for example different coverage variables, scaffold length, GC content, or anything else that were loaded with mmload. Scaffolds can then be highlighted and extracted using the locator and selection features.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mmplot(
  mm,
  x,
  y,
  min_length = 0,
  color_by = NULL,
  locator = FALSE,
  selection = NULL,
  network = NULL,
  shared_genes = FALSE,
  label_scaffolds = FALSE,
  label_scaffolds_by = "scaffold",
  label_bins = NULL,
  highlight_scaffolds = NULL,
  highlight_color = "darkred",
  x_scale = NULL,
  x_limits = NULL,
  y_scale = NULL,
  y_limits = NULL,
  alpha = 0.1,
  fixed_size = NULL,
  size_scale = 1,
  factor_shape = "outline",
  color_vector = c("blue", "green", "red"),
  color_scale_log10 = FALSE
)

Arguments

mm

(required) A dataframe loaded with mmload.

x

(required) The variable from mm to plot on the first axis.

y

(required) The variable from mm to plot on the second axis.

min_length

Remove scaffolds with a length at or below this value before plotting. (Default: 0)

color_by

Color the scaffolds by a variable in mm. (Default: NULL)

locator

(Logical) When TRUE, left-clicks in the plot are captured and the exact x/y-coordinates of the mouse clicks are returned. These coordinates can be used to highlight a selection of scaffolds in the plot, and also be used with mmextract to extract all scaffolds within the selection from the data. (Default: FALSE)

selection

A 2-column dataframe with the x and y coordinates of points with which to draw a polygon onto the plot to highlight a selected region. A selection can be obtained by using the locator feature (by locator = TRUE). (Default: NULL)

network

Paired-end or mate-pair connections between scaffolds in long format. The first and second columns must contain all connected scaffold pairs and the third column the number of connections.

shared_genes

(Logical) If TRUE, lines will be drawn between scaffolds with any shared gene(s). (Default: FALSE)

label_scaffolds

Add text labels (with text from the variable in mm defined by label_scaffolds_by) to a selection of scaffolds by providing either a character vector of scaffold names, or a dataframe with scaffold names in the first column. If set to TRUE then all scaffolds will be labelled. (Default: FALSE)

label_scaffolds_by

The variable in mm by which to label the scaffolds defined by label_scaffolds. (Default: "scaffold")

label_bins

Add labels at the centroids of bins (groups of scaffolds) defined by a variable in mm. (Default: NULL)

highlight_scaffolds

A vector of scaffold names or a dataframe loaded with mmload containing scaffolds to highlight in the plot with the color set by highlight_color. (Default: NULL)

highlight_color

The color with which to highlight the scaffolds set by highlight. (Default: "darkred")

x_scale

Log10-scale ("log10") or square-root scale "sqrt" the x axis. (Default: NULL)

x_limits

Axis limits of the x axis. Must be a vector of length 2 where the first number is the lower limit and the second number is the upper limit. Use NA to automatically detect the lowest and highest values, respectively. (Default: NULL)

y_scale

Log10-scale ("log10") or square-root scale "sqrt" the y axis. (Default: NULL)

y_limits

Axis limits of the y axis. Must be a vector of length 2 where the first number is the lower limit and the second number is the upper limit. Use NA to automatically detect the lowest and highest values, respectively. (Default: NULL)

alpha

The transparancy of the scaffold points, where 0 is invisible and 1 is opaque. (Default: 0.1)

fixed_size

A fixed size for all scaffolds if set. If NULL then the scaffolds are scaled by length. (Default: NULL)

size_scale

A factor to scale the sizes of the scaffolds plotted. Only applies when fixed_size is set to NULL and the scaffolds are scaled by length. (Default: 1)

factor_shape

When color_by is a categorical variable (factor or character) then set the shape of the scaffolds to either "solid" or "outline". (Default: "outline")

color_vector

The colors from which to generate a color gradient when color_by is set and the variable is continuous. Any number of colors can be used. (Default: c("blue", "green", "red"))

color_scale_log10

(Logical) Log10-scale the color gradient when color_by is set and the variable is continuous. (Default: FALSE)

Value

A ggplot object. Note that mmgenome2 hides all warnings produced by ggplot objects.

Author(s)

Kasper Skytte Andersen ksa@bio.aau.dk

Soren M. Karst smk@bio.aau.dk

Mads Albertsen MadsAlbertsen85@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library(mmgenome2)
data(mmgenome2)
mmgenome2
mmplot(mmgenome2,
  min_length = 3000,
  x = "cov_C13.11.25",
  y = "cov_C14.01.09",
  color_by = "taxonomy",
  # locator = TRUE,
  x_scale = "log10",
  y_scale = "log10"
)
# Set "locator = TRUE" to interactively capture the coordinates of
# mouse clicks in an mmplot, or provide coordinates with "selection":
selection <- data.frame(
  cov_C13.11.25 = c(7.2, 16.2, 25.2, 23.3, 10.1),
  cov_C14.01.09 = c(47, 77, 52.8, 29.5, 22.1)
)
mmplot(mmgenome2,
  min_length = 10000,
  x = "cov_C13.11.25",
  y = "cov_C14.01.09",
  color_by = "taxonomy",
  x_scale = "log10",
  y_scale = "log10",
  x_limits = c(1, NA), # zoom in at minimum 1x coverage
  y_limits = c(1, NA), # zoom in at minimum 1x coverage
  selection = selection
) # highlight the selection marked with locator

KasperSkytte/mmgenome2 documentation built on Dec. 14, 2021, 12:11 a.m.