library(dplyr)
library(ggplot2)
library(ggrepel)
library(knitr)
library(readr)
library(scales)
library(tidyr)

knit_print.data.frame <- function(x, ...) kable(x) %>% paste(collapse = "\n") %>% asis_output
input_tsv <- params$input_tsv
metrics <- read_tsv(input_tsv) %>%
    mutate(Directory = dirname(File)) %>%
    separate(Directory, c("Trimmer", "Assembler", "k"),
        fill = "left", remove = FALSE) %>%
    mutate(Trimmer = sub("nxtrim", "NxTrim", Trimmer)) %>%
    replace_na(list(Trimmer = "None")) %>%
    mutate(k = as.integer(sub("k", "", k))) %>%
    select(Directory, Trimmer, k,
        starts_with("Scaffold"), starts_with("Contig"), starts_with("Total"),
        everything(), -File, -Assembler)

Scaffold NG50 and NGA50 vs Breakpoints

ggplot(metrics) +
    aes(label = k, x = Total_breakpoints, colour = Trimmer, group = Trimmer) +
    geom_errorbar(aes(ymin = Scaffold_NGA50, ymax = Scaffold_NG50), width = 10) +
    geom_path(aes(y = Scaffold_NGA50), alpha = 0.2) +
    geom_text_repel(aes(y = Scaffold_NG50), segment.color = "#cccccc") +
    scale_x_continuous(name = "Breakpoints", labels = comma) +
    scale_y_continuous(name = "Scaffold NG50 and NGA50", labels = unit_format(unit = "kbp", scale = 1e-3)) +
    scale_colour_brewer(palette = "Set1") +
    expand_limits(y = 0) +
    theme_grey(24)

Contig NGA50 vs breakpoints

ggplot(metrics) +
    aes(label = k, x = Contig_breakpoints, y = Contig_NGA50, colour = Trimmer, group = Trimmer) +
    geom_path() +
    geom_text_repel(segment.color = "#cccccc") +
    scale_x_continuous(name = "Contig breakpoints", labels = comma) +
    scale_y_continuous(name = "Contig NGA50", labels = unit_format(unit = "kbp", scale = 1e-3)) +
    scale_colour_brewer(palette = "Set1") +
    expand_limits(y = 0) +
    theme_grey(24)

Table of assembly metrics

metrics
LS0tCnRpdGxlOiBQbG90IGFzc2VtYmx5IG1ldHJpY3MKYXV0aG9yOiBTaGF1biBKYWNrbWFuCm91dHB1dDoKICBodG1sX25vdGVib29rOgogICAgY29kZV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