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.
- Overview
- Features
- Quick Start
- Installation
- API Documentation
- Docker Deployment
- Configuration
- Contributing
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.
- 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
Using Docker:
docker pull yourusername/atac-tracks-api
docker run -p 8000:8000 yourusername/atac-tracks-api
Access the API at: http://localhost:8000
- Clone the repository:
git clone https://github.com/yourusername/atac_tracks_api.git
cd atac_tracks_api
- Install R dependencies:
install.packages(c(
"plumber",
"GenomicRanges",
"rtracklayer",
"data.table"
))
- Run the API:
Rscript server.R
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 genomic coordinates for a gene.
Parameters:
- gene_id: Gene identifier
Response:
{
"gene_info": {
"chrom": "chr1",
"start": 1000,
"end": 5000,
"strand": "+"
}
}
{
"error": "Error message",
"status": 400
}
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"]
# 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
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"
# Configure rate limits
pr$filter("rate-limit", function(req, res) {
rate_limit(
rate = 100, # requests
per = 60 # seconds
)
})
- bigWig or bedGraph format
- Chromosome-specific files
- Consistent naming convention
Tab-delimited file with columns:
- gene_id
- chrom
- start
- end
- strand
The API implements comprehensive error handling for:
- Invalid genomic coordinates
- Missing data files
- Rate limit exceedance
- Malformed requests
- Server errors
-
Data Access
- File caching
- Query optimization
- Response compression
-
Resource Management
- Connection pooling
- Memory optimization
- Request queuing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
- Follow R code style guidelines
- Add unit tests
- Update API documentation
- Test Docker deployment
This project is licensed under the MIT License - see the LICENSE file for details.
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
- Built with R Plumber
- Data processing: ATACseq_Pipeline
- Supporting institutions and funding