Biowulf High Performance Computing at the NIH
vg on Biowulf

From the vg repository:

Variation graphs provide a succinct encoding of the sequences of many genomes. A variation graph (in particular as implemented in vg) is composed of:

  • nodes, which are labeled by sequences and ids
  • edges, which connect two nodes via either of their respective ends
  • paths, describe genomes, sequence alignments, and annotations (such as gene models and transcripts) as walks through nodes connected by edges

This model is similar to sequence graphs that have been used in assembly and multiple sequence alignment.

Paths provide coordinate systems relative to genomes encoded in the graph, allowing stable mappings to be produced even if the structure of the graph is changed. The variation graph model makes this embedding explicit and essential. Tools in vg maintain paths as immutable during transformations of the graph. They use paths to project graph-relative data into reference-relative coordinate spaces. Paths provide stable coordinates for graphs built in different ways from the same input sequences.

References:

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@biowulf]$ sinteractive --gres=lscratch:10
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 vg graphviz
[user@cn3144]$ cd /lscratch/$SLURM_JOB_ID
[user@cn3144]$ cp -r $VG_TEST_DATA/small .
[user@cn3144]$ vg construct -r small/x.fa -v small/x.vcf.gz > x.vg
[user@cn3144]$ vg view -d x.vg | dot -T png -o x.png

The latter command creates a a visualization of the newly created graph including this section

visualization of genome graph

Align sequences to the graph

[user@cn3144]$ vg index -x x.xg -g x.gcsa -k 16 x.vg
[user@cn3144]$ vg sim -n 1000 -l 150 -x x.xg > x.sim.txt
[user@cn3144]$ vg map -T x.sim.txt -x x.xg -g x.gcsa > aln.gam
[user@cn3144]$ vg surject -x x.xg -b aln.gam > aln.bam

[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. vg.sh), which uses the input file 'vg.in'. For example:

#!/bin/bash
module load vg/1.19.9
vg map --threads $SLURM_CPUS_PER_TASK --fastq sample.fastq.gz -x hg38.vg.xg -g hg38.gcsa > sample.gam

Submit this job using the Slurm sbatch command.

sbatch --cpus-per-task=8 --mem=10g vg.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. vg.swarm). For example:

vg map --threads $SLURM_CPUS_PER_TASK --fastq sample1.fastq.gz -x hg38.vg.xg -g hg38.gcsa > sample1.gam
vg map --threads $SLURM_CPUS_PER_TASK --fastq sample2.fastq.gz -x hg38.vg.xg -g hg38.gcsa > sample2.gam

Submit this job using the swarm command.

swarm -f vg.swarm -g 10 -t 8 --module vg/1.19.0
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 vg Loads the vg module for each subjob in the swarm