-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameters.rmd
82 lines (73 loc) · 2.22 KB
/
parameters.rmd
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: Determine sensitivity to parameters of Tigmint
author: Shaun Jackman
output:
html_document:
keep_md: true
params:
abyss_fac_tsv:
label: "Input TSV file of parameters and abyss-fac metrics"
value: "abyss-fac.tsv"
input: text
samtobreak_tsv:
label: "Input TSV file of parameters and abyss-samtobreak metrics"
value: "samtobreak.tsv"
input: text
output_tsv:
label: "Output TSV file of parameters and assembly metrics"
value: "parameters.out.tsv"
input: text
---
```{r setup, message=FALSE}
library(dplyr)
library(ggplot2)
library(ggrepel)
library(knitr)
library(readr)
library(scales)
library(stringr)
library(tidyr)
knit_print.data.frame <- function(x, ...) kable(x) %>% paste(collapse = "\n") %>% asis_output
abyss_fac_tsv <- params$abyss_fac_tsv
samtobreak_tsv <- params$samtobreak_tsv
output_tsv <- params$output_tsv
abyss_fac_tsv
samtobreak_tsv
output_tsv
```
# Read the data
```{r read-data}
abyss_fac <- read_tsv(abyss_fac_tsv)
samtobreak <- read_tsv(samtobreak_tsv)
metrics <- left_join(abyss_fac, samtobreak, by = c("Depth", "Starts")) %>%
mutate(Label = ifelse(is.na(Depth), "ABySS + ARCS",
paste0("d=", Depth, " s=", Starts)))
```
# Plot parameters and assembly metrics
```{r parameters}
ggplot(metrics) +
aes(x = Total_breakpoints, y = Scaffold_NGA50, label = Label) +
geom_point() +
geom_text_repel(nudge_x = 20, nudge_y = 100e3) +
scale_x_continuous(name = "Breakpoints", labels = comma) +
scale_y_continuous(name = "Scaffold NGA50 (Mbp)", labels = unit_format(unit = "Mbp", scale = 1e-6)) +
expand_limits(x = c(4400, 4900), y = c(0, 10e6)) +
theme_minimal(base_size = 20)
```
# Table of parameters and assembly metrics
```{r parameters-table}
parameters_table <- metrics %>%
arrange(Scaffold_NGA50) %>%
transmute(
Depth,
Starts,
`NG50 (Mbp)` = round(NG50 / 1e6, 2),
`NGA50 (Mbp)` = round(Scaffold_NGA50 / 1e6, 2),
Breakpoints = comma(Total_breakpoints),
Reduction = max(Total_breakpoints) - Total_breakpoints,
Reduction = str_c(Reduction, " (", percent(Reduction / max(Total_breakpoints)), ")"),
Reduction = ifelse(is.na(Depth), NA, Reduction)) %>%
replace_na(list(Depth = "Original", Starts = "Original"))
parameters_table
write_tsv(parameters_table, output_tsv)
```