bwbioinfo · GitHub
Last updated:2026-03-11 02:45
Detection Threshold Boxplot
This script isolates the detection-threshold boxplot panel, matching the read-level detection timing view from the full analysis workflow. This code reproduces the base graphic reported in the article Single-workflow Nanopore whole genome sequencing with adaptive sampling for accelerated and comprehensive pediatric cancer profiling.
Data setup
library(dplyr)
library(tidyr)
library(ggplot2)
set.seed(99)
first_hits_long <- tidyr::crossing(
sample_name = paste0("sample_", LETTERS[1:8]),
variant_group_id = paste0("var", sprintf("%03d", 1:40)),
detection_level = c(1, 5, 8, 10)
) %>%
mutate(
vaf_bin = sample(
c("<5%", "5-10%", "10-25%", ">25%"),
n(),
replace = TRUE
),
variant_type = sample(
c("SNV", "INDEL", "BND"),
n(),
replace = TRUE
),
panel = sample(
c(TRUE, FALSE),
n(),
replace = TRUE,
prob = c(0.7, 0.3)
),
time_h = pmin(
72,
rgamma(n(), shape = detection_level / 2, scale = 3.5)
)
)
Isolated plot
p_detection <- first_hits_long %>%
ggplot() +
geom_boxplot(
aes(
x = time_h,
y = detection_level,
group = interaction(detection_level, variant_type),
color = variant_type
)
) +
scale_x_continuous(
breaks = seq(0, 72, by = 12),
minor_breaks = seq(0, 72, by = 6)
) +
scale_y_continuous(breaks = c(1, 5, 8, 10)) +
facet_grid(
panel ~ vaf_bin,
labeller = labeller(
panel = function(x) {
ifelse(x, "In Panel Genes", "Out of Panel Genes")
},
vaf_bin = function(x) paste("VAF:", x)
)
) +
labs(
x = "Sequencing Time (Hours)",
y = "Detection Support (Number of Reads)",
title = "Detection Time by Variant Type and VAF"
) +
theme_bw(base_size = 12) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
p_detection

Session Info
## R version 4.5.2 (2025-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Linux Mint 22.2
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0 LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
## [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
## [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
##
## time zone: America/Toronto
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] digest_0.6.39 R6_2.6.1 bookdown_0.46 fastmap_1.2.0
## [5] xfun_0.56 blogdown_1.23 cachem_1.1.0 knitr_1.51
## [9] htmltools_0.5.9 rmarkdown_2.30 lifecycle_1.0.5 cli_3.6.5
## [13] sass_0.4.10 jquerylib_0.1.4 compiler_4.5.2 tools_4.5.2
## [17] evaluate_1.0.5 bslib_0.10.0 yaml_2.3.12 otel_0.2.0
## [21] jsonlite_2.0.0 rlang_1.1.7
361 Words
2026-03-08 19:00 (Last updated: 2026-03-11 02:45)