How fanglab/nanodisco works
Project type and purpose
• nanodisco is a command-line bioinformatics toolbox (an open-source tool), packaged as a Docker/Singularity image.
• It orchestrates a series of R and shell scripts to perform (a) *de novo* DNA methylation discovery, (b) methylation motif typing/fine-mapping, and (c) methylation-based metagenomic binning from nanopore sequencing data.
File structure
• Top-level:
• Container specs: Dockerfile, Singularity
• Executable wrapper: code/nanodisco (CLI entry point)
• Processing scripts: code/*.R and *.sh
• Documentation: docs/ (Sphinx sources)
• Protocols: protocol/ (PDF lab protocols)
• Scripts implement a modular pipeline:
• Pre-processing & alignment (preprocess.sh, realign_events.sh)
• Signal difference calling (difference.sh, difference_chunks.R, difference_functions.R)
• Motif discovery & characterization (run_meme.sh, motif.R, characterize.R, score.R)
• Methylation profiling & binning (profile.R, filter_profile.R, select_feature.R, binning.R, plot_binning.R)
README for architectural hints
• The CLI exposes subcommands: difference, characterize, profile, binning, plot_binning, score, etc.
• Dependencies: R (packages), MEME suite, nanopore event realignment tools, Singularity/Docker.
Main components and their interactions
a. User & CLI
• The user invokes nanodisco <subcommand> [options] inside a container (Docker/Singularity).
b. Container layer
• Encapsulates all dependencies: R interpreter, shell utilities, MEME, nanopolish/event realigner.
c. Pipeline modules (scripts)
1. Pre-processing
• preprocess.sh → realign_events.sh → raw signal and reference FASTA → aligned signals
2. Difference calling
• difference.sh → difference_chunks.R → RDS files of current differences
3. Motif discovery & fine mapping
• run_meme.sh → motif.R → characterize.R → score.R → motif classification outputs (PDF, TSV)
4. Profiling & binning
• profile.R → filter_profile.R → select_feature.R → methylation profile RDS
• binning.R → plot_binning.R → bin assignments and visualizations (PDF, RDS)
d. Data store
• Intermediate files (RDS, TSV), final outputs (PDF, plots), logs—all on the container’s filesystem, mountable to host.
Architectural patterns & design principles
• Modular pipeline: each subcommand encapsulates a distinct analysis step.
• Stateless scripts: data flows through files (RDS/TSV) rather than in-memory objects across steps.
• Containerization: ensures reproducibility and isolates dependencies.
• Extensibility: new subcommands and R scripts can be added to code/ and exposed via the CLI launcher script.
Elements
• Clear labels: script names and command names (nanodisco difference, nanodisco profile, etc.)
• Blue for preprocessing & alignment
• Green for methylation discovery
• Orange for profiling & binning
• Gray for external tools (MEME, realigner)
Capturing essential details without over-splitting
• Data artifacts (RDS, motifs.tsv, binning.pdf) rather than every intermediate file.
• Extensibility: show that adding a new subcommand plugs into the CLI launcher and the container.