Plots all connected scaffolds in a network plot. Scaffolds can then be highlighted and extracted using the locator and selection features.

mmnetwork(
  mm,
  network,
  min_connections = 1,
  color_by = NULL,
  color_scale_log10 = FALSE,
  locator = FALSE,
  selection = NULL,
  highlight_labels = NULL,
  highlight_color = "darkred",
  links_scale = 1,
  scaffold_labels = FALSE,
  print_nolinks = FALSE,
  seed = 0
)

Arguments

mm

(required) A dataframe loaded with mmload.

network

(required) 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.

min_connections

Filter all scaffold pairs with equal to or less than this number of connections. (Default: 2)

color_by

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

color_scale_log10

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

locator

(Logical) When TRUE, left-clicks in the plot are captured and the exact x/y-coordinates of the mouse clicks are captured and returned. These coordinates can be used to highlight a selection of scaffolds in the plot, and to extract all scaffolds within the selection. (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)

highlight_labels

A dataframe or vector of scaffold names whose labels to highlight in the plot (colored by highlight_color). (Default: NULL)

highlight_color

The color with which to highlight the scaffold labels defined by highlight_labels. (Default: "darkred")

links_scale

A factor to scale the sizes of the links plotted between scaffolds. (Default: 1)

scaffold_labels

Add labels with the scaffold names of all scaffolds.

print_nolinks

(Logical) Print the names of all scaffolds with no links to other scaffolds to the console. (Default: FALSE)

seed

Network plots are based on Random Number Generation, and this is used to set a specific random seed (with set.seed) allowing for reproducible network plots. Set to NULL to generate a unique network plot with each run of mmnetwork. (Default: 0)

Value

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

Using the locator with mmnetwork

Unlike a plot generated by mmplot, the coordinates of points in each dimension in a mmnetwork plot is not contained within the provided dataframe mm itself. As such mmnetwork does not have a corresponding extract function like mmextract is for mmplot. Instead, a subset of mm containing all scaffolds within the selection polygon is available in the returned ggplot object with plot$data_in_selection.

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) data(paired_ends) 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>
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) ) mmgenome2_extraction <- mmextract(mmgenome2, selection = selection)
#> 61 scaffolds (or 1.34% of the scaffolds in mm, weighted by length) remain after 97224 of 97285 scaffolds have been filtered.
mmgenome2_extraction
#> # A tibble: 61 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 180 22093 74.0 0.298 12.0 7.34 37.9 #> 2 181 2970 68.0 0.34 13.9 7.37 38.6 #> 3 227 190826 65.4 0.348 13.0 6.91 38.5 #> 4 253 296715 70.2 1.06 15.2 7.00 41.1 #> 5 315 218862 71.7 0.366 12.6 7.17 38.8 #> 6 343 27203 57.6 0.235 10.7 5.07 32.0 #> 7 381 6128 67.2 8.11 22.6 5.89 48.7 #> 8 386 164942 68.2 0.359 12.3 6.73 37.2 #> 9 396 7448 72.6 0.329 13.0 7.59 41.0 #> 10 423 100199 68.7 1.40 15.3 6.71 40.0 #> # … with 51 more rows, and 6 more variables: PC1 <dbl>, PC2 <dbl>, PC3 <dbl>, #> # geneID <chr>, taxonomy <fct>, rRNA16S <fct>
p <- mmnetwork(mmgenome2_extraction, network = paired_ends, min_connections = 1, color_by = "taxonomy" ) p