Skip to content

Commit cb8919c

Browse files
committed
Document Docker comparative workflow
1 parent 2d42002 commit cb8919c

2 files changed

Lines changed: 91 additions & 3 deletions

File tree

README.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ What this does:
102102
- keeps raw InterProScan TSV outputs inside `dnmb_interproscan/`
103103
- on Linux, runs as your current host UID/GID in the direct `docker run` examples so output and cache files stay writable by you
104104
- on arm64 hosts, add `--platform linux/amd64` to the direct `docker run` command because the published image is currently `amd64`
105-
- lets you control module selection through `DNMB_MODULES`, `DNMB_SKIP_MODULES`, `DNMB_MODULE_CPU`, `DNMB_PROPHAGE_BACKEND`, and `DNMB_CLEAN_PREVIOUS`
105+
- lets you control module selection through `DNMB_MODULES`, `DNMB_SKIP_MODULES`, `DNMB_MODULE_CPU`, `DNMB_PROPHAGE_BACKEND`, `DNMB_CLEAN_PREVIOUS`, `DNMB_COMPARATIVE`, and `DNMB_COMPARATIVE_DATA_ROOT`
106106

107107
## Optional Shell Launcher
108108

@@ -343,6 +343,56 @@ the per-genome pipeline finishes (it calls each plotter below against
343343
`dirname(getwd())`, or `comparative_data_root` when supplied). The
344344
individual plotters stay useful when you want a subset or custom colors.
345345

346+
Run the comparative suite directly with Docker, without opening R, after
347+
per-genome DNMB runs have already produced one genome folder per GenBank file:
348+
349+
```text
350+
data/
351+
├── genome_1/
352+
│ └── input_1.gbff
353+
├── genome_2/
354+
│ └── input_2.gbff
355+
└── genome_3/
356+
└── input_3.gbff
357+
```
358+
359+
From the parent directory that contains `data/`:
360+
361+
```bash
362+
docker run --rm \
363+
--platform linux/amd64 \
364+
--user "$(id -u):$(id -g)" \
365+
-e DNMB_MODULE_CPU=8 \
366+
-v "$PWD/data:/data" \
367+
-v "$HOME/.dnmb-cache:/opt/dnmb/cache" \
368+
ghcr.io/jaeyoonsung/dnmbsuite:latest \
369+
comparative /data
370+
```
371+
372+
This writes comparative PDFs and count matrices under:
373+
374+
```text
375+
data/comparative/
376+
```
377+
378+
To run a per-genome DNMB analysis and render the comparative suite at the end
379+
from a focal genome folder, use:
380+
381+
```bash
382+
cd /path/to/data/genome_1
383+
384+
docker run --rm \
385+
--platform linux/amd64 \
386+
--user "$(id -u):$(id -g)" \
387+
-e DNMB_COMPARATIVE=1 \
388+
-e DNMB_COMPARATIVE_DATA_ROOT=/data \
389+
-e DNMB_MODULE_CPU=8 \
390+
-v "$(dirname "$PWD"):/data" \
391+
-v "$HOME/.dnmb-cache:/opt/dnmb/cache" \
392+
ghcr.io/jaeyoonsung/dnmbsuite:latest \
393+
/data/$(basename "$PWD")
394+
```
395+
346396
After per-genome DNMB runs finish, render across-genome heatmaps for
347397
defense-module families as well as enzyme/CAZyme modules. Each plotter
348398
treats every GenBank-bearing subfolder of `data_root` as one genome,
@@ -392,7 +442,7 @@ Pass `auto_run_missing = FALSE` to render only what already exists.
392442
to the direct `docker run` command after creating that host folder once with:
393443
`mkdir -p "$HOME/.dnmb-cache/padloc-bootstrap"`
394444
- Advanced launcher environment variables:
395-
`DNMB_MODULES`, `DNMB_SKIP_MODULES`, `DNMB_MODULE_CPU`, `DNMB_PROPHAGE_BACKEND`, `DNMB_CLEAN_PREVIOUS`, `DNMB_AUTO_UPDATE`, `DNMB_AUTO_UPDATE_BRANCH`
445+
`DNMB_MODULES`, `DNMB_SKIP_MODULES`, `DNMB_MODULE_CPU`, `DNMB_PROPHAGE_BACKEND`, `DNMB_CLEAN_PREVIOUS`, `DNMB_COMPARATIVE`, `DNMB_COMPARATIVE_DATA_ROOT`, `DNMB_AUTO_UPDATE`, `DNMB_AUTO_UPDATE_BRANCH`
396446

397447
## Compose
398448

@@ -476,4 +526,3 @@ If you need to override the build-time core ref, use `DNMB_REF`:
476526
docker build --build-arg DNMB_REF=master -t ghcr.io/jaeyoonsung/dnmbsuite:latest .
477527
docker build --build-arg DNMB_REF=<commit-sha> -t ghcr.io/jaeyoonsung/dnmbsuite:dev .
478528
```
479-

docker/entrypoint.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ build_r_arg_string() {
291291
local clean_previous="${DNMB_CLEAN_PREVIOUS:-TRUE}"
292292
local module_cpu="${DNMB_MODULE_CPU:-}"
293293
local prophage_backend="${DNMB_PROPHAGE_BACKEND:-}"
294+
local comparative="${DNMB_COMPARATIVE:-}"
295+
local comparative_data_root="${DNMB_COMPARATIVE_DATA_ROOT:-}"
294296
local modules="${DNMB_MODULES:-}"
295297
local skip_modules="${DNMB_SKIP_MODULES:-}"
296298

@@ -356,6 +358,13 @@ build_r_arg_string() {
356358
r_args+=("module_Prophage_backend = \"${prophage_backend}\"")
357359
fi
358360

361+
if dnmb_truthy "$comparative"; then
362+
r_args+=("comparative = TRUE")
363+
if [ -n "$comparative_data_root" ]; then
364+
r_args+=("comparative_data_root = \"${comparative_data_root}\"")
365+
fi
366+
fi
367+
359368
local arg_string=""
360369
local arg
361370
for arg in "${r_args[@]}"; do
@@ -412,13 +421,43 @@ run_dnmb_default() {
412421
run_dnmb_in_dir /data
413422
}
414423

424+
run_dnmb_comparative() {
425+
local data_root="${1:-${DNMB_COMPARATIVE_DATA_ROOT:-/data}}"
426+
local module_cpu="${DNMB_MODULE_CPU:-}"
427+
local module_install="${DNMB_MODULE_INSTALL:-TRUE}"
428+
429+
if [ ! -d "$data_root" ]; then
430+
echo "Error: comparative data root not found: $data_root" >&2
431+
exit 1
432+
fi
433+
434+
dnmb_rscript -e '
435+
library(DNMB)
436+
data_root <- normalizePath(Sys.getenv("DNMB_COMPARATIVE_DATA_ROOT", unset = commandArgs(TRUE)[1]), mustWork = TRUE)
437+
module_cpu_raw <- Sys.getenv("DNMB_MODULE_CPU", unset = "")
438+
module_cpu <- if (nzchar(module_cpu_raw)) suppressWarnings(as.integer(module_cpu_raw)) else NULL
439+
module_install_raw <- Sys.getenv("DNMB_MODULE_INSTALL", unset = "TRUE")
440+
module_install <- module_install_raw %in% c("1", "true", "TRUE", "yes", "YES", "on", "ON")
441+
DNMB:::.dnmb_run_comparative_suite(
442+
data_root = data_root,
443+
module_cache_root = Sys.getenv("DNMB_CACHE_ROOT", unset = "/opt/dnmb/cache"),
444+
module_install = module_install,
445+
module_cpu = module_cpu
446+
)
447+
' "$data_root"
448+
}
449+
415450
maybe_drop_privileges "$@"
416451

417452
if [ "$#" -eq 0 ]; then
418453
run_dnmb_default
419454
fi
420455

421456
case "$1" in
457+
comparative)
458+
shift
459+
run_dnmb_comparative "${1:-${DNMB_COMPARATIVE_DATA_ROOT:-/data}}"
460+
;;
422461
run|auto)
423462
shift
424463
if [ "$#" -eq 0 ]; then

0 commit comments

Comments
 (0)