Skip to content

Latest commit

 

History

History
250 lines (202 loc) · 4.75 KB

README.md

File metadata and controls

250 lines (202 loc) · 4.75 KB

ATAC-seq Tracks API

Docker R License

A RESTful API service for retrieving and visualizing ATAC-seq genomic tracks data. Built with R and Docker for scalable deployment and integration with genome browsers.

Table of Contents

Overview

This API provides programmatic access to ATAC-seq track data, enabling seamless integration with genome browsers and visualization tools. It processes and serves data generated by the ATACseq_Pipeline.

Features

  • RESTful API endpoints for track data access
  • Query by genomic coordinates
  • Multiple data format support (bigWig, bedGraph)
  • Gene ID lookup functionality
  • Scalable Docker deployment
  • Comprehensive error handling
  • Cross-origin resource sharing (CORS)
  • Request rate limiting

Quick Start

Using Docker:

docker pull yourusername/atac-tracks-api
docker run -p 8000:8000 yourusername/atac-tracks-api

Access the API at: http://localhost:8000

Installation

Local Installation

  1. Clone the repository:
git clone https://github.com/yourusername/atac_tracks_api.git
cd atac_tracks_api
  1. Install R dependencies:
install.packages(c(
  "plumber",
  "GenomicRanges",
  "rtracklayer",
  "data.table"
))
  1. Run the API:
Rscript server.R

API Documentation

Endpoints

GET /tracks/{sample}/{chrom}/{start}/{end}

Retrieve track data for a specific genomic region.

Parameters:

  • sample: Sample identifier
  • chrom: Chromosome number/name
  • start: Start position
  • end: End position

Response:

{
  "track_data": [
    {
      "position": 1000,
      "score": 5.2
    },
    ...
  ]
}

GET /genes/{gene_id}

Get genomic coordinates for a gene.

Parameters:

  • gene_id: Gene identifier

Response:

{
  "gene_info": {
    "chrom": "chr1",
    "start": 1000,
    "end": 5000,
    "strand": "+"
  }
}

Error Responses

{
  "error": "Error message",
  "status": 400
}

Docker Deployment

Dockerfile

FROM rocker/r-ver:4.1.0

# Install system dependencies
RUN apt-get update && apt-get install -y \
    libcurl4-gnutls-dev \
    libssl-dev \
    libxml2-dev

# Install R packages
RUN R -e 'install.packages(c("plumber", "GenomicRanges", "rtracklayer", "data.table"))'

# Copy application files
COPY . /app
WORKDIR /app

# Expose port
EXPOSE 8000

# Start API server
CMD ["Rscript", "server.R"]

Building and Running

# Build image
docker build -t atac-tracks-api .

# Run container
docker run -d \
  -p 8000:8000 \
  -v /path/to/data:/app/data \
  --name atac-tracks-api \
  atac-tracks-api

Configuration

Server Configuration

Edit server.R:

# API configuration
options(
  plumber.port = 8000,
  plumber.host = "0.0.0.0"
)

# Data paths
TRACK_DATA_DIR = "data/tracks"
GENE_INFO_FILE = "data/gene_info.txt"

Rate Limiting

# Configure rate limits
pr$filter("rate-limit", function(req, res) {
  rate_limit(
    rate = 100,  # requests
    per = 60     # seconds
  )
})

Data Requirements

Track Files

  • bigWig or bedGraph format
  • Chromosome-specific files
  • Consistent naming convention

Gene Information

Tab-delimited file with columns:

  • gene_id
  • chrom
  • start
  • end
  • strand

Error Handling

The API implements comprehensive error handling for:

  • Invalid genomic coordinates
  • Missing data files
  • Rate limit exceedance
  • Malformed requests
  • Server errors

Performance Optimization

  1. Data Access

    • File caching
    • Query optimization
    • Response compression
  2. Resource Management

    • Connection pooling
    • Memory optimization
    • Request queuing

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Development Guidelines

  • Follow R code style guidelines
  • Add unit tests
  • Update API documentation
  • Test Docker deployment

License

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

Citation

If you use this API in your research, please cite:

Author et al. (Year). ATAC-seq Tracks API: A RESTful service for ATAC-seq data retrieval.
Repository: https://github.com/yourusername/atac_tracks_api

Related Projects

Acknowledgments

  • Built with R Plumber
  • Data processing: ATACseq_Pipeline
  • Supporting institutions and funding