Biowulf High Performance Computing at the NIH
snaptools on Biowulf

snaptools is a python application to work with snap (Single Nucleus Accessibility Profile) files. From the authors:

A snap file is a hierarchically structured hdf5 file that is specially designed for storing single nucleus ATAC-seq datasets. A snap file (version 4) contains the following sessions: header (HD), cell-by-bin accessibility matrix (AM), cell-by-peak matrix (PM), cell-by-gene matrix (GM), barcode (BD) and fragment (FM).

Documentation
Important Notes

Interactive job
Interactive jobs should be used for debugging, graphics, or applications that cannot be run as batch jobs.

Allocate an interactive session and run the program.
Sample session (user input in bold):

[user@biowulf]$ sinteractive --gres=lscratach:5 --cpus-per-task=4 --mem=8G
salloc.exe: Pending job allocation 46116226
salloc.exe: job 46116226 queued and waiting for resources
salloc.exe: job 46116226 has been allocated resources
salloc.exe: Granted job allocation 46116226
salloc.exe: Waiting for resource configuration
salloc.exe: Nodes cn3144 are ready for job

[user@cn3144 ~]$ module load snaptools bwa

[user@cn3144 ~]$ tar -zxf $SNAPTOOLS_TEST_DATA/snaptools_test.tar.gz

[user@cn3144 ~]$ gunzip mm10.fa.gz

[user@cn3144 ~]$ snaptools index-genome
                            --input-fasta=mm10.fa \
                            --output-prefix=mm10. \ sdx
                            --aligner=bwa \
                            --num-threads=4

[user@cn3144 ~]$ snaptools align-paired-end
                            --input-reference=mm10.fa \
                            --input-fastq1=demo.R1.fastq.gz \
                            --input-fastq2=demo.R2.fastq.gz \
                            --output-bam=demo.bam \
                            --aligner=bwa \
                            --read-fastq-command=zcat \
                            --min-cov=0 \
                            --num-threads=4 \
                            --if-sort=True \
                            --tmp-folder=/lscratch/$SLURM_JOB_ID \
                            --overwrite=TRUE

[user@cn3144 ~]$ snaptools snap-pre  \
                            --input-file=demo.bam  \
                            --output-snap=demo.snap  \
                            --genome-name=mm10  \
                            --genome-size=mm10.chrom.size  \
                            --min-mapq=30  \
                            --min-flen=0  \
                            --max-flen=1000  \
                            --keep-chrm=TRUE  \
                            --keep-single=TRUE  \
                            --keep-secondary=False  \
                            --overwrite=True  \
                            --max-num=1000000  \
                            --min-cov=100  \
                            --verbose=True

[user@cn3144 ~]$ $ snaptools snap-add-bmat  \
                            --snap-file=demo.snap  \
                            --bin-size-list 5000 10000  \
                            --verbose=True

[user@cn3144 ~]$ exit
salloc.exe: Relinquishing job allocation 46116226

[user@biowulf ~]$

Batch job
Most jobs should be run as batch jobs.

Create a batch input file (e.g. snaptools.sh). For example:

#!/bin/bash
set -e
module load snaptools
snaptools snap-pre --input-file=example.bam --genome-name=refgenome --genome-size=refgenome.size --output=example.snap

Submit this job using the Slurm sbatch command.

sbatch [--cpus-per-task=#] [--mem=#] snaptools.sh
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

Create a swarmfile (e.g. snaptools.swarm). For example:

snaptools snap-add-bmat --snap-file=example1.snap
snaptools snap-add-bmat --snap-file=example2.snap
snaptools snap-add-bmat --snap-file=example3.snap
snaptools snap-add-bmat --snap-file=example4.snap

Submit this job using the swarm command.

swarm -f snaptools.swarm [-g #] [-t #] --module snaptools
where
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)
-t # Number of threads/CPUs required for each process (1 line in the swarm command file).
--module snaptools Loads the snaptools module for each subjob in the swarm