An advanced end-to-end system for identifying taxonomic diversity and assessing biological richness in deep-sea environmental DNA (eDNA) datasets using state-of-the-art machine learning, continual learning, and bioinformatics techniques.
HTML
0
84 commits
updated Sep 24, 2026
An advanced end-to-end system for identifying taxonomic diversity and assessing biological richness in deep-sea environmental DNA (eDNA) datasets using state-of-the-art machine learning, continual learning, and bioinformatics techniques.
Avalanche eDNA is a comprehensive platform for deep-sea eDNA analysis that combines cutting-edge deep learning with robust bioinformatics workflows. The system features:
run_taxonomy_pipeline_v2.py
ACTIVE_REPLAY_SUCCESS.md for simulation resultsTAXONOMY_PIPELINE_V2_GUIDE.md for usage guideMajor Features:
Continual Learning Infrastructure
Enhanced Pipeline
--resume, --fine-tune, --checkpoint-everyTraining Dashboard
DNABERT-2 Optimization
Technical Improvements:
config.yamlβββ data/ # Sample datasets and test data
β βββ synthetic_edna/ # π Test datasets (2.5K, 5K sequences)
βββ src/ # Source code
β βββ analysis/ # Dataset analysis utilities
β βββ api/ # Report management API
β βββ clustering/ # Clustering algorithms and taxonomy
β βββ dashboards/ # Streamlit dashboard modules
β βββ database/ # Database models and manager
β βββ models/ # π Model implementations
β β βββ checkpoint_manager.py # Training checkpoint management
β β βββ continual_learning.py # π₯ Active replay + EWC (89% accuracy)
β β βββ dnabert.py # DNABERT/DNABERT-2 wrapper
β β βββ embeddings.py # Embedding generation
β β βββ finetuner.py # Fine-tuning functionality
β β βββ model_registry.py # Version tracking & lineage
β β βββ tokenizer.py # DNA tokenization
β β βββ trainer.py # Model training loops
β βββ novelty/ # Novelty detection logic
β βββ organism_profiling/ # Organism profiling modules
β βββ preprocessing/ # Data cleaning and preparation
β βββ report_management/ # Report/catalogue management
β βββ similarity/ # Cross-analysis engine
β βββ ui/ # π Streamlit UI pages
β β βββ pages/
β β βββ progress_updates.py # Pipeline monitoring
β β βββ model_training_dashboard.py # Training visualization
β β βββ ...
β βββ utils/ # Shared utilities and config
β βββ visualization/ # Plotting and dashboard utilities
βββ models/ # π Pre-trained models
β βββ dnabert2_cpu/ # DNABERT-2-117M (CPU-optimized)
βββ notebooks/ # Jupyter notebooks for analysis
βββ tests/ # Unit and integration tests
βββ docs/ # Documentation
β βββ ACTIVE_REPLAY_SUCCESS.md # π Simulation results
β βββ TAXONOMY_PIPELINE_V2_GUIDE.md # π Usage guide
β βββ PIPELINE_MIGRATION_GUIDE.md # π v1 β v2 migration
βββ scripts/ # Pipeline and automation scripts
β βββ run_pipeline.py # Original pipeline
β βββ run_taxonomy_pipeline_v2.py # π Revised pipeline (active replay)
β βββ launch_dashboard.py # Streamlit dashboard launcher
β βββ ...
βββ config/ # Configuration files
β βββ config.yaml # Main config (with continual_learning section)
βββ streamlit_app.py # Streamlit UI entrypoint
βββ demo_taxonomy_pipeline_v2.py # π Quick demo script
βββ requirements*.txt # Python dependencies
See Installation Guide for detailed setup instructions including prerequisites, environment setup, and optional dependencies.
The system uses DNABERT-2 as the default embedding model. The first run will automatically download model weights (~894MB) to your local HuggingFace cache.
# Create sample eDNA dataset
python scripts/run_pipeline.py --create-sample --input data/sample --output results/demo
# Run complete analysis pipeline
python scripts/run_pipeline.py \
--input data/sample/sample_edna_sequences.fasta \
--output results/demo
# Start the main dashboard
python scripts/launch_dashboard.py
# Or directly with streamlit
streamlit run streamlit_app.py --server.port=8504
Then open http://localhost:8504 in your browser to access:
Results are automatically saved in your output directory:
results/demo/
βββ pipeline_results.json # Complete analysis summary
βββ preprocessed_sequences.fasta # Cleaned sequences
βββ sequence_embeddings.npy # DNABERT-2 embeddings
βββ clustering/ # Cluster assignments
βββ taxonomy/ # Taxonomic predictions
βββ novelty/ # Novel taxa candidates
βββ visualizations/ # Interactive plots
Train models that grow with your data - accumulating knowledge from multiple eDNA datasets without forgetting.
# Fine-tune DNABERT-2 on your dataset
python scripts/run_pipeline.py \
--input data/marine_dataset \
--output results/marine_run \
--fine-tune \
--checkpoint-every 5 \
--dataset-name "Marine_eDNA_2024" \
--model-version "v1.0"
# Train on a second dataset (model accumulates knowledge)
python scripts/run_pipeline.py \
--input data/freshwater_dataset \
--output results/freshwater_run \
--fine-tune \
--dataset-name "Freshwater_eDNA_2024" \
--model-version "v1.1"
# Resume interrupted training
python scripts/run_pipeline.py \
--resume results/marine_run/checkpoints/checkpoint_epoch_10.pt \
--input data/continue_training \
--output results/continued
Access the Training Dashboard in the Streamlit UI to:
Configure in config/config.yaml:
continual_learning:
strategy:
method: "combined" # Use EWC + Replay + LwF together
experience_replay:
buffer_size: 1000
replay_ratio: 0.2
ewc:
lambda: 0.4
online_ewc: true
lwf:
temperature: 2.0
alpha: 0.5
Available Strategies:
# Complete end-to-end analysis
python scripts/run_pipeline.py \
--input sequences.fasta \
--output results/
# Skip specific steps
python scripts/run_pipeline.py \
--input sequences.fasta \
--output results/ \
--skip-preprocessing \
--skip-clustering
# Fine-tune model on dataset
python scripts/run_pipeline.py \
--input sequences.fasta \
--output results/ \
--fine-tune \
--checkpoint-every 5 \
--dataset-name "MyDataset" \
--model-version "v1.0"
# Resume from checkpoint
python scripts/run_pipeline.py \
--resume results/checkpoints/checkpoint_epoch_10.pt \
--input new_sequences.fasta \
--output results/continued/
--input: Input file (FASTA/FASTQ) or directory--output: Output directory for results--fine-tune: Enable DNABERT-2 fine-tuning--resume: Resume from checkpoint path--checkpoint-every: Save checkpoint every N epochs--dataset-name: Dataset name for registry--model-version: Model version identifier--skip-preprocessing: Skip preprocessing step--skip-embedding: Skip embedding generation--skip-clustering: Skip clustering step--skip-taxonomy: Skip taxonomy assignment--skip-novelty: Skip novelty detection--skip-visualization: Skip visualization generation--create-sample: Create sample datasetLaunch the multi-page Streamlit dashboard:
# Method 1: Using launcher script
python scripts/launch_dashboard.py
# Method 2: Direct streamlit
streamlit run streamlit_app.py --server.port=8504
Available Pages:
from scripts.run_pipeline import eDNABiodiversityPipeline
# Initialize pipeline
pipeline = eDNABiodiversityPipeline()
# Standard analysis
results = pipeline.run_complete_pipeline(
input_data="sequences.fasta",
output_dir="results/analysis"
)
# With continual learning
results = pipeline.run_complete_pipeline(
input_data="sequences.fasta",
output_dir="results/analysis",
enable_fine_tuning=True,
checkpoint_every=5,
dataset_name="MyDataset",
model_version="v1.0"
)
# Access results
print(f"Sequences processed: {results['summary']['total_sequences_processed']}")
print(f"Novel taxa found: {results['summary']['novel_taxa_candidates']}")
print(f"Clusters detected: {results['summary']['clusters_detected']}")
from src.models.model_registry import ModelRegistry
# Initialize registry
registry = ModelRegistry(registry_dir="results/model_registry")
# List all models
models = registry.list_models(status='active')
# Get model lineage
lineage = registry.get_lineage("v1.2")
# Compare two models
comparison = registry.compare_models("v1.0", "v1.2")
# Get best model by metric
best = registry.get_best_model(metric='val_loss', minimize=True)
# config/config.yaml
embedding:
model_id: "zhihan1996/DNABERT-2-117M"
max_sequence_length: 512
transformer:
stride: 256
batch_size: 8
postprocess:
pca_dims: 256
normalize: true
continual_learning:
checkpoint:
enabled: true
save_frequency: 5
max_checkpoints: 10
fine_tuning:
learning_rate: 2e-5
warmup_ratio: 0.1
freeze_strategy: "gradual"
strategy:
method: "combined"
experience_replay:
buffer_size: 1000
ewc:
lambda: 0.4
lwf:
alpha: 0.5
The system includes a comprehensive report management API for cataloging datasets and cross-analysis.
Option 1 β Windows helper (convenience)
start_report_system.bat
This launches two separate command windows:
http://127.0.0.1:8000http://localhost:8504Option 2 β Manual (cross-platform)
Run the FastAPI server:
python -m uvicorn src.api.report_management_api:app --host 127.0.0.1 --port 8000
Run the Streamlit dashboard:
streamlit run streamlit_app.py --server.port=8504 --server.address=localhost
The system includes comprehensive NCBI SRA (Sequence Read Archive) integration for accessing thousands of publicly available eDNA datasets.
1. Using the Web Interface
# Launch dashboard
streamlit run streamlit_app.py
# Navigate to "SRA Browser" page
# Search for datasets, download, and analyze directly
2. Command Line
# Download a specific dataset
python scripts/download_sra_data.py \
--accession SRR12345678 \
--output data/sra
# Search and download multiple datasets
python scripts/download_sra_data.py \
--search "marine eDNA" \
--max-results 10 \
--output data/sra_datasets
3. Python API
from src.utils.sra_integration import SRAIntegrationUI
# Initialize
sra = SRAIntegrationUI()
# Search datasets
results = sra.search_sra_datasets(
keywords=["eDNA", "18S rRNA"],
max_results=50
)
# Download specific dataset
success, file_path = sra.download_sra_dataset(
"SRR12345678",
output_dir="data/sra"
)
# Process downloaded data
pipeline.run_complete_pipeline(
input_data=file_path,
output_dir="results/sra_analysis"
)
For complete SRA integration documentation, see SRA Integration Guide.
Run the test suite:
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_system.py
# Run with coverage
pytest --cov=src tests/
# Run specific test category
pytest tests/ -k "embedding"
Scripts for multi-dataset workflows are available in scripts/:
# Build consolidated reference from all run embeddings
python scripts/consolidate_embeddings.py \
--runs-dir analysis_outputs/runs \
--output consolidated_data/
# Compress embeddings to save storage (~50% reduction)
python scripts/compress_embeddings.py \
--input results/embeddings.npy \
--output results/embeddings_compressed.npz
# Search across all embeddings for similar sequences
python scripts/search_reference.py \
--query sequence.fasta \
--reference consolidated_data/
# Track model versions and tag runs
python scripts/manage_embedding_versions.py \
--registry results/model_registry \
--action list
See EMBEDDING_MANAGEMENT.md for detailed workflows.
The modular architecture allows easy extension:
# Add custom clustering algorithm
from src.clustering.algorithms import EmbeddingClusterer
class MyClusterer(EmbeddingClusterer):
def cluster(self, embeddings):
# Your implementation
return labels
# Add custom taxonomy classifier
from src.clustering.taxonomy import TaxonomyClassifier
class MyClassifier(TaxonomyClassifier):
def predict(self, embeddings):
# Your implementation
return predictions
We welcome contributions! See CONTRIBUTING.md for guidelines.
Areas for Contribution:
MIT License - see LICENSE for details.
This project uses the following key technologies:
For questions, issues, or collaboration:
Built with β€οΈ for deep-sea biodiversity research
An advanced end-to-end system for identifying taxonomic diversity and assessing biological richness in deep-sea environmental DNA (eDNA) datasets using state-of-the-art machine learning, continual learning, and bioinformatics techniques.
HTML
0
84 commits
updated Sep 24, 2026
An advanced end-to-end system for identifying taxonomic diversity and assessing biological richness in deep-sea environmental DNA (eDNA) datasets using state-of-the-art machine learning, continual learning, and bioinformatics techniques.
Avalanche eDNA is a comprehensive platform for deep-sea eDNA analysis that combines cutting-edge deep learning with robust bioinformatics workflows. The system features:
run_taxonomy_pipeline_v2.py
ACTIVE_REPLAY_SUCCESS.md for simulation resultsTAXONOMY_PIPELINE_V2_GUIDE.md for usage guideMajor Features:
Continual Learning Infrastructure
Enhanced Pipeline
--resume, --fine-tune, --checkpoint-everyTraining Dashboard
DNABERT-2 Optimization
Technical Improvements:
config.yamlβββ data/ # Sample datasets and test data
β βββ synthetic_edna/ # π Test datasets (2.5K, 5K sequences)
βββ src/ # Source code
β βββ analysis/ # Dataset analysis utilities
β βββ api/ # Report management API
β βββ clustering/ # Clustering algorithms and taxonomy
β βββ dashboards/ # Streamlit dashboard modules
β βββ database/ # Database models and manager
β βββ models/ # π Model implementations
β β βββ checkpoint_manager.py # Training checkpoint management
β β βββ continual_learning.py # π₯ Active replay + EWC (89% accuracy)
β β βββ dnabert.py # DNABERT/DNABERT-2 wrapper
β β βββ embeddings.py # Embedding generation
β β βββ finetuner.py # Fine-tuning functionality
β β βββ model_registry.py # Version tracking & lineage
β β βββ tokenizer.py # DNA tokenization
β β βββ trainer.py # Model training loops
β βββ novelty/ # Novelty detection logic
β βββ organism_profiling/ # Organism profiling modules
β βββ preprocessing/ # Data cleaning and preparation
β βββ report_management/ # Report/catalogue management
β βββ similarity/ # Cross-analysis engine
β βββ ui/ # π Streamlit UI pages
β β βββ pages/
β β βββ progress_updates.py # Pipeline monitoring
β β βββ model_training_dashboard.py # Training visualization
β β βββ ...
β βββ utils/ # Shared utilities and config
β βββ visualization/ # Plotting and dashboard utilities
βββ models/ # π Pre-trained models
β βββ dnabert2_cpu/ # DNABERT-2-117M (CPU-optimized)
βββ notebooks/ # Jupyter notebooks for analysis
βββ tests/ # Unit and integration tests
βββ docs/ # Documentation
β βββ ACTIVE_REPLAY_SUCCESS.md # π Simulation results
β βββ TAXONOMY_PIPELINE_V2_GUIDE.md # π Usage guide
β βββ PIPELINE_MIGRATION_GUIDE.md # π v1 β v2 migration
βββ scripts/ # Pipeline and automation scripts
β βββ run_pipeline.py # Original pipeline
β βββ run_taxonomy_pipeline_v2.py # π Revised pipeline (active replay)
β βββ launch_dashboard.py # Streamlit dashboard launcher
β βββ ...
βββ config/ # Configuration files
β βββ config.yaml # Main config (with continual_learning section)
βββ streamlit_app.py # Streamlit UI entrypoint
βββ demo_taxonomy_pipeline_v2.py # π Quick demo script
βββ requirements*.txt # Python dependencies
See Installation Guide for detailed setup instructions including prerequisites, environment setup, and optional dependencies.
The system uses DNABERT-2 as the default embedding model. The first run will automatically download model weights (~894MB) to your local HuggingFace cache.
# Create sample eDNA dataset
python scripts/run_pipeline.py --create-sample --input data/sample --output results/demo
# Run complete analysis pipeline
python scripts/run_pipeline.py \
--input data/sample/sample_edna_sequences.fasta \
--output results/demo
# Start the main dashboard
python scripts/launch_dashboard.py
# Or directly with streamlit
streamlit run streamlit_app.py --server.port=8504
Then open http://localhost:8504 in your browser to access:
Results are automatically saved in your output directory:
results/demo/
βββ pipeline_results.json # Complete analysis summary
βββ preprocessed_sequences.fasta # Cleaned sequences
βββ sequence_embeddings.npy # DNABERT-2 embeddings
βββ clustering/ # Cluster assignments
βββ taxonomy/ # Taxonomic predictions
βββ novelty/ # Novel taxa candidates
βββ visualizations/ # Interactive plots
Train models that grow with your data - accumulating knowledge from multiple eDNA datasets without forgetting.
# Fine-tune DNABERT-2 on your dataset
python scripts/run_pipeline.py \
--input data/marine_dataset \
--output results/marine_run \
--fine-tune \
--checkpoint-every 5 \
--dataset-name "Marine_eDNA_2024" \
--model-version "v1.0"
# Train on a second dataset (model accumulates knowledge)
python scripts/run_pipeline.py \
--input data/freshwater_dataset \
--output results/freshwater_run \
--fine-tune \
--dataset-name "Freshwater_eDNA_2024" \
--model-version "v1.1"
# Resume interrupted training
python scripts/run_pipeline.py \
--resume results/marine_run/checkpoints/checkpoint_epoch_10.pt \
--input data/continue_training \
--output results/continued
Access the Training Dashboard in the Streamlit UI to:
Configure in config/config.yaml:
continual_learning:
strategy:
method: "combined" # Use EWC + Replay + LwF together
experience_replay:
buffer_size: 1000
replay_ratio: 0.2
ewc:
lambda: 0.4
online_ewc: true
lwf:
temperature: 2.0
alpha: 0.5
Available Strategies:
# Complete end-to-end analysis
python scripts/run_pipeline.py \
--input sequences.fasta \
--output results/
# Skip specific steps
python scripts/run_pipeline.py \
--input sequences.fasta \
--output results/ \
--skip-preprocessing \
--skip-clustering
# Fine-tune model on dataset
python scripts/run_pipeline.py \
--input sequences.fasta \
--output results/ \
--fine-tune \
--checkpoint-every 5 \
--dataset-name "MyDataset" \
--model-version "v1.0"
# Resume from checkpoint
python scripts/run_pipeline.py \
--resume results/checkpoints/checkpoint_epoch_10.pt \
--input new_sequences.fasta \
--output results/continued/
--input: Input file (FASTA/FASTQ) or directory--output: Output directory for results--fine-tune: Enable DNABERT-2 fine-tuning--resume: Resume from checkpoint path--checkpoint-every: Save checkpoint every N epochs--dataset-name: Dataset name for registry--model-version: Model version identifier--skip-preprocessing: Skip preprocessing step--skip-embedding: Skip embedding generation--skip-clustering: Skip clustering step--skip-taxonomy: Skip taxonomy assignment--skip-novelty: Skip novelty detection--skip-visualization: Skip visualization generation--create-sample: Create sample datasetLaunch the multi-page Streamlit dashboard:
# Method 1: Using launcher script
python scripts/launch_dashboard.py
# Method 2: Direct streamlit
streamlit run streamlit_app.py --server.port=8504
Available Pages:
from scripts.run_pipeline import eDNABiodiversityPipeline
# Initialize pipeline
pipeline = eDNABiodiversityPipeline()
# Standard analysis
results = pipeline.run_complete_pipeline(
input_data="sequences.fasta",
output_dir="results/analysis"
)
# With continual learning
results = pipeline.run_complete_pipeline(
input_data="sequences.fasta",
output_dir="results/analysis",
enable_fine_tuning=True,
checkpoint_every=5,
dataset_name="MyDataset",
model_version="v1.0"
)
# Access results
print(f"Sequences processed: {results['summary']['total_sequences_processed']}")
print(f"Novel taxa found: {results['summary']['novel_taxa_candidates']}")
print(f"Clusters detected: {results['summary']['clusters_detected']}")
from src.models.model_registry import ModelRegistry
# Initialize registry
registry = ModelRegistry(registry_dir="results/model_registry")
# List all models
models = registry.list_models(status='active')
# Get model lineage
lineage = registry.get_lineage("v1.2")
# Compare two models
comparison = registry.compare_models("v1.0", "v1.2")
# Get best model by metric
best = registry.get_best_model(metric='val_loss', minimize=True)
# config/config.yaml
embedding:
model_id: "zhihan1996/DNABERT-2-117M"
max_sequence_length: 512
transformer:
stride: 256
batch_size: 8
postprocess:
pca_dims: 256
normalize: true
continual_learning:
checkpoint:
enabled: true
save_frequency: 5
max_checkpoints: 10
fine_tuning:
learning_rate: 2e-5
warmup_ratio: 0.1
freeze_strategy: "gradual"
strategy:
method: "combined"
experience_replay:
buffer_size: 1000
ewc:
lambda: 0.4
lwf:
alpha: 0.5
The system includes a comprehensive report management API for cataloging datasets and cross-analysis.
Option 1 β Windows helper (convenience)
start_report_system.bat
This launches two separate command windows:
http://127.0.0.1:8000http://localhost:8504Option 2 β Manual (cross-platform)
Run the FastAPI server:
python -m uvicorn src.api.report_management_api:app --host 127.0.0.1 --port 8000
Run the Streamlit dashboard:
streamlit run streamlit_app.py --server.port=8504 --server.address=localhost
The system includes comprehensive NCBI SRA (Sequence Read Archive) integration for accessing thousands of publicly available eDNA datasets.
1. Using the Web Interface
# Launch dashboard
streamlit run streamlit_app.py
# Navigate to "SRA Browser" page
# Search for datasets, download, and analyze directly
2. Command Line
# Download a specific dataset
python scripts/download_sra_data.py \
--accession SRR12345678 \
--output data/sra
# Search and download multiple datasets
python scripts/download_sra_data.py \
--search "marine eDNA" \
--max-results 10 \
--output data/sra_datasets
3. Python API
from src.utils.sra_integration import SRAIntegrationUI
# Initialize
sra = SRAIntegrationUI()
# Search datasets
results = sra.search_sra_datasets(
keywords=["eDNA", "18S rRNA"],
max_results=50
)
# Download specific dataset
success, file_path = sra.download_sra_dataset(
"SRR12345678",
output_dir="data/sra"
)
# Process downloaded data
pipeline.run_complete_pipeline(
input_data=file_path,
output_dir="results/sra_analysis"
)
For complete SRA integration documentation, see SRA Integration Guide.
Run the test suite:
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_system.py
# Run with coverage
pytest --cov=src tests/
# Run specific test category
pytest tests/ -k "embedding"
Scripts for multi-dataset workflows are available in scripts/:
# Build consolidated reference from all run embeddings
python scripts/consolidate_embeddings.py \
--runs-dir analysis_outputs/runs \
--output consolidated_data/
# Compress embeddings to save storage (~50% reduction)
python scripts/compress_embeddings.py \
--input results/embeddings.npy \
--output results/embeddings_compressed.npz
# Search across all embeddings for similar sequences
python scripts/search_reference.py \
--query sequence.fasta \
--reference consolidated_data/
# Track model versions and tag runs
python scripts/manage_embedding_versions.py \
--registry results/model_registry \
--action list
See EMBEDDING_MANAGEMENT.md for detailed workflows.
The modular architecture allows easy extension:
# Add custom clustering algorithm
from src.clustering.algorithms import EmbeddingClusterer
class MyClusterer(EmbeddingClusterer):
def cluster(self, embeddings):
# Your implementation
return labels
# Add custom taxonomy classifier
from src.clustering.taxonomy import TaxonomyClassifier
class MyClassifier(TaxonomyClassifier):
def predict(self, embeddings):
# Your implementation
return predictions
We welcome contributions! See CONTRIBUTING.md for guidelines.
Areas for Contribution:
MIT License - see LICENSE for details.
This project uses the following key technologies:
For questions, issues, or collaboration:
Built with β€οΈ for deep-sea biodiversity research