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.

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

Kasper Skytte Andersen ksa@bio.aau.dk

Soren M. Karst smk@bio.aau.dk

Mads Albertsen MadsAlbertsen85@gmail.com

Examples

library(mmgenome2) data(mmgenome2) mmgenome2
#> # A tibble: 97,285 x 13 #> scaffold length gc cov_C13.11.14 cov_C13.11.25 cov_C13.12.03 cov_C14.01.09 #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 8264 57.8 1.44 53.6 0 0.066 #> 2 2 1027 57.0 0.625 24.2 0 0 #> 3 3 1665 55.9 13.5 434. 0.166 0.177 #> 4 4 9056 35.9 0.01 23.4 0 0 #> 5 5 3343 64.0 3.20 16.4 0 0 #> 6 6 98207 39.1 0.00966 24.5 3.29 9.85 #> 7 7 6480 63.0 2.61 19.2 1.46 12.3 #> 8 8 15790 61.7 2.78 21.2 1.62 10.3 #> 9 9 1403 70.4 85.1 192. 0 0 #> 10 10 2018 70.2 50.3 101. 0 0 #> # … with 97,275 more rows, and 6 more variables: PC1 <dbl>, PC2 <dbl>, #> # PC3 <dbl>, geneID <chr>, taxonomy <fct>, rRNA16S <fct>
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