Skip to main content

AI-powered automated NGS analysis pipeline

Project description

NGS AI Agent

Python 3.8+ License: MIT PyPI version

AI-powered automated NGS analysis pipeline for Deep Mutational Scanning (DMS) experiments

NGS AI Agent is a comprehensive, intelligent pipeline that automates Next-Generation Sequencing (NGS) data analysis with AI-powered metadata interpretation and experimental design detection. It supports both amplicon-based and barcode-coupled DMS workflows with minimal user configuration.

๐Ÿš€ Quick Start

# 1. Create conda environment from environment.yml
conda env create -f environment.yml
conda activate ai-ngs

# 2. Install the package
pip install ngs-ai-agent

# 3. Run analysis with your data
ngs-ai-agent run --input-dir /path/to/fastq/files --metadata experiment.csv --dry-run

โœจ Features

๐Ÿค– AI-Powered Analysis

  • Intelligent File Matching: Automatically matches FASTQ files to experimental metadata using AI
  • Pipeline Type Detection: Automatically detects amplicon-based vs barcode-coupled DMS experiments
  • Condition Classification: AI-powered classification of samples as input, output, mapping, or control
  • Metadata Interpretation: Supports CSV, TSV, and Excel metadata files with flexible column naming

๐Ÿงฌ Comprehensive DMS Support

  • Amplicon-Based DMS: Direct sequencing of amplicons for variant calling and fitness calculation
  • Barcode-Coupled DMS: Long-read barcode-to-variant mapping with short-read barcode counting
  • Paired-End Support: Full support for paired-end sequencing data
  • Quality Control: Integrated QC metrics and visualization

๐Ÿ”ง Advanced Workflow Management

  • Snakemake Integration: Robust workflow management with automatic dependency resolution
  • Conda Environment: Automated environment setup and dependency management
  • Multi-Core Processing: Efficient parallel processing with configurable core usage
  • Dry Run Mode: Preview pipeline execution before running

๐Ÿ“Š Rich Output and Visualization

  • Interactive Reports: HTML reports with embedded visualizations
  • Fitness Calculations: Comprehensive fitness score calculations and statistical analysis
  • Variant Analysis: Detailed variant calling and annotation
  • Publication-Ready Plots: High-quality figures for manuscripts

๐Ÿ“‹ Requirements

  • Python: 3.8 or higher
  • Conda: For environment management
  • Ollama: For AI capabilities (optional but recommended)
  • Memory: 8GB+ RAM recommended
  • Storage: Varies by dataset size

๐Ÿ› ๏ธ Installation

Prerequisites

  1. Install Conda: Download and install Miniconda or Anaconda

  2. Clone the Repository:

git clone https://github.com/your-org/ngs-ai-agent.git
cd ngs-ai-agent

Step 1: Create Conda Environment

# Create the conda environment with all bioinformatics dependencies
conda env create -f environment.yml

# Activate the environment
conda activate ai-ngs

Step 2: Install the Package

# Install from PyPI (recommended)
pip install ngs-ai-agent

# OR install from source for development
pip install -e .

๐ŸŽฏ Usage

Basic Usage

# Make sure you're in the activated conda environment
conda activate ai-ngs

# Run analysis with CSV metadata
ngs-ai-agent run \
  --input-dir /path/to/fastq/files \
  --reference /path/to/reference.fasta \
  --metadata experiment.csv \
  --outdir /path/to/results \
  --cores 8

# Dry run to preview pipeline
ngs-ai-agent run \
  --input-dir /path/to/fastq/files \
  --metadata experiment.csv \
  --dry-run

Advanced Usage

# High-performance run with many cores
ngs-ai-agent run \
  --input-dir /path/to/fastq/files \
  --reference /path/to/reference.fasta \
  --metadata experiment.xlsx \
  --outdir /path/to/results \
  --cores 32 

# Custom configuration
ngs-ai-agent run \
  --input-dir /path/to/fastq/files \
  --metadata experiment.csv \
  --config /path/to/custom/config.yaml

Command Options

Option Short Description Required
--input-dir -i Directory containing FASTQ files โœ…
--reference -r Reference genome FASTA file โŒ
--metadata -m Experimental metadata file (CSV/TSV/Excel) โŒ
--config -c Configuration file path โŒ
--cores -j Number of cores to use โŒ
--dry-run Show what would be run without executing โŒ
--outdir -o Override output/results directory โŒ

๐Ÿ“ Input Data Format

FASTQ Files

  • Supported formats: .fastq.gz, .fq.gz, .fastq, .fq
  • Paired-end: Automatically detected and handled
  • Naming: Flexible naming conventions supported

Metadata Files

The pipeline supports CSV, TSV, and Excel metadata files with the following columns:

Required Columns

  • Sample identification: filename1, filename, sample_name, or similar
  • Condition: condition, treatment, timepoint, or similar
  • Replication: replication, rep, replicate, or similar

Optional Columns

  • Paired-end: filename2, filename_r2, file_name_r2 for R2 files
  • Library layout: library_layout (single/paired)
  • Description: description, sample_description for AI analysis

Example Metadata (CSV)

filename1,filename2,condition,replication,description
Sample1_R1.fastq.gz,Sample1_R2.fastq.gz,input,1,pre-selection library
Sample2_R1.fastq.gz,Sample2_R2.fastq.gz,output,1,post-selection enriched
Sample3_R1.fastq.gz,Sample3_R2.fastq.gz,mapping,1,PacBio barcode mapping

๐Ÿ”ฌ Pipeline Types

Amplicon-Based DMS

  • Use case: Direct sequencing of PCR amplicons
  • Workflow: Quality control โ†’ Variant calling โ†’ Fitness calculation
  • Output: Variant frequencies, fitness scores, statistical analysis

Barcode-Coupled DMS

  • Use case: Barcode-based variant identification
  • Workflow: Barcode mapping โ†’ Barcode counting โ†’ Fitness calculation
  • Output: Barcode-to-variant maps, fitness scores, enrichment analysis

๐Ÿ“Š Output Structure

results/
โ”œโ”€โ”€ reports/
โ”‚   โ””โ”€โ”€ final_report.html          # Interactive HTML report
โ”œโ”€โ”€ variants/
โ”‚   โ””โ”€โ”€ final_variants.csv         # Variant calling results
โ”œโ”€โ”€ fitness/
โ”‚   โ””โ”€โ”€ fitness_scores.csv         # Fitness calculations
โ”œโ”€โ”€ plots/
โ”‚   โ”œโ”€โ”€ summary_plots.html         # Interactive visualizations
โ”‚   โ””โ”€โ”€ publication_plots/         # High-resolution figures
โ””โ”€โ”€ logs/
    โ””โ”€โ”€ pipeline.log               # Detailed execution log

โš™๏ธ Configuration

The pipeline uses YAML configuration files. Key settings include:

# AI Settings
ai:
  model: "qwen3-coder:latest"
  endpoint: "http://localhost:11434"

# Pipeline Settings
pipeline:
  threads: 8
  memory: "16G"

# Data Paths
data:
  raw: "data/raw"
  processed: "data/processed"
  results: "results"

๐Ÿค– AI Integration

NGS AI Agent integrates with Ollama for intelligent analysis:

Setup Ollama

# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Pull the required model
ollama pull qwen3-coder:latest

# Start Ollama service
ollama serve

AI Capabilities

  • File Matching: Intelligent matching of files to metadata
  • Condition Detection: Automatic classification of experimental conditions
  • Pipeline Selection: Smart detection of appropriate analysis workflow
  • Quality Assessment: AI-powered quality control recommendations

๐Ÿงช Examples

Example 1: Amplicon-Based DMS

ngs-ai-agent run \
  --input-dir data/amplicon_experiment/ \
  --reference reference.fasta \
  --metadata amplicon_metadata.csv \
  --cores 16

Example 2: Barcode-Coupled DMS

ngs-ai-agent run \
  --input-dir data/barcode_experiment/ \
  --reference barcode_reference.gb \
  --metadata barcode_metadata.xlsx \
  --cores 32 \
  --outdir results/barcode_analysis

๐Ÿ› Troubleshooting

Common Issues

1. Ollama Service Not Running

# Start Ollama service
ollama serve

# Check if model is available
ollama list

2. Conda Environment Issues

# Recreate environment
conda env remove -n ai-ngs
conda env create -f environment.yml
conda activate ai-ngs

3. Permission Errors

# Install with user flag
pip install --user ngs-ai-agent

4. Memory Issues

# Reduce cores or increase available memory
ngs-ai-agent run --cores 4 --input-dir /path/to/data --metadata experiment.csv

Getting Help

# Show help
ngs-ai-agent --help
ngs-ai-agent run --help

# Check version
ngs-ai-agent --version

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

# Clone repository
git clone https://github.com/your-org/ngs-ai-agent.git
cd ngs-ai-agent

# Create conda environment
conda env create -f environment.yml
conda activate ai-ngs

# Install in development mode
pip install -e .

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“š Citation

If you use NGS AI Agent in your research, please cite:

@software{ngs_ai_agent,
  title={NGS AI Agent: AI-powered automated NGS analysis pipeline},
  author={NGS AI Agent Team},
  year={2024},
  url={https://github.com/your-org/ngs-ai-agent},
  license={MIT}
}

๐Ÿ”— Links

๐Ÿ™ Acknowledgments


Made with โค๏ธ for the bioinformatics community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ngs_ai_agent-1.1.0.tar.gz (144.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ngs_ai_agent-1.1.0-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

Details for the file ngs_ai_agent-1.1.0.tar.gz.

File metadata

  • Download URL: ngs_ai_agent-1.1.0.tar.gz
  • Upload date:
  • Size: 144.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ngs_ai_agent-1.1.0.tar.gz
Algorithm Hash digest
SHA256 23312dbc331d37cdf80c07cfbc02032415415bd1530da30676a2670a8e951d69
MD5 436abc8fff56bc65b7b7649139fc9e44
BLAKE2b-256 b843b124e7cd6837e1d416418b942df8ac22fc8084d2104d85dd9249f4f47e65

See more details on using hashes here.

File details

Details for the file ngs_ai_agent-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ngs_ai_agent-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ngs_ai_agent-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb18fef8c7f08df6649a4f8feffa0166ab2e6518f3609a73867f589dd7fc69c
MD5 3d46bd153377a2aa6af66d993f67fc83
BLAKE2b-256 e0b2bf16afa563422bb532c4eb1bbd375421e4c1ecb4ae79ace4239bbd0a36f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page