Skip to content

Commit

Permalink
add Singularity container
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekm committed Oct 30, 2019
1 parent e24d53c commit d32f178
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ ENV/
IGV_Snapshots*
bin*
test.py
target.bed
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# IGV Snapshot Automator
A script to automatically create and run [IGV snapshot batchscripts](http://software.broadinstitute.org/software/igv/batch). This script will first write an IGV batch script for the supplied input files, then load all supplied files for visualization (.bam, etc) in a headless IGV session and take snapshots at the locations defined in the `regions.bed` file.
A script to automatically create and run [IGV snapshot batchscripts](http://software.broadinstitute.org/software/igv/batch). This script will first write an IGV batch script for the supplied input files, then load all supplied files for visualization (.bam, etc) in a headless IGV session and take snapshots at the locations defined in the `regions.bed` file.

Designed for use on Linux systems, and intended to be used as a component of sequencing analysis pipelines.
Designed for use on Linux systems, and intended to be used as a component of sequencing analysis pipelines.

# Usage

Expand Down Expand Up @@ -54,11 +54,11 @@ $ python make_IGV_snapshots.py /path/to/alignments1.bam /path/to/alignments2.bam
- `-g`: Genome to use, e.g. `hg19`
- `-ht`: Height of the snapshot, default is 500
- `-o`: Name of the output directory to save the snapshots in.
- `-bin`: Path to the IGV jar binary to run
- `-bin`: Path to the IGV jar binary to run
- `-mem`: Memory to allocate to IGV (MB)
- `-suffix`: Filename suffix to place before '.png' in the snapshots
- `-onlysnap`: Skip batchscript creation and only run IGV using the supplied batchscript file
- `-nf4`: "Name field 4" mode, uses values saved in 4th field of the `regions.bed` file as the output filename of the PNG snapshot. Use this when you have pre-made filenames you wish to use for each snapshot.
- `-nf4`: "Name field 4" mode, uses values saved in 4th field of the `regions.bed` file as the output filename of the PNG snapshot. Use this when you have pre-made filenames you wish to use for each snapshot.
- `-s` or `-group_by_strand`: Group alignment(s) by read strand with forward on top and reverse on the bottom.


Expand All @@ -69,9 +69,23 @@ $ python make_IGV_snapshots.py /path/to/alignments1.bam /path/to/alignments2.bam

# Notes

Default memory allotment is set at 4GB; this can be changed with the `-mem` argument (e.g. `-mem 1000` sets memory to 1GB).
Default memory allotment is set at 4GB; this can be changed with the `-mem` argument (e.g. `-mem 1000` sets memory to 1GB).

IGV may take several minutes to run, depending on the number of input files and regions to snapshot. Stdout messages from the program may not appear immediately in the console.
IGV may take several minutes to run, depending on the number of input files and regions to snapshot. Stdout messages from the program may not appear immediately in the console.

# Singularity Container

An example Singularity container recipe file to run the IGV Snapshot Automator script is included (`Singularity`). If you have Singularity installed, it can be built with a command such as:

```
sudo singularity build IGV.simg Singularity
```

If you do not have root access or do not have Singularity installed on your system, you can refer to the repo [here](https://github.com/NYU-Molecular-Pathology/containers) for some examples of how to build Singularity containers using Vagrant or Docker.

An example wrapper script that can be used to launch the Singularity container and run the IGV Snapshot Automator can be found in `run.Singularity.sh`. You should update this with the commands you wish to use and make necessary changes to it in order to run on your system.

Tested with Singularity 2.4 and 2.5.2.

# Software Requirements
- Python 2.7 or 3+
Expand Down
28 changes: 28 additions & 0 deletions Singularity
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BootStrap: docker
From: ubuntu:16.04

%post
apt-get update && \
apt-get install -y wget \
unzip \
default-jdk \
xvfb \
xorg \
python

wget http://data.broadinstitute.org/igv/projects/downloads/2.4/IGV_2.4.10.zip && \
unzip IGV_2.4.10.zip && \
rm -f unzip IGV_2.4.10.zip

export PATH="/IGV_2.4.10/:${PATH}"

# make a dummy batch script in order to load the hg19 genome into the container
# https://software.broadinstitute.org/software/igv/PortCommands
printf 'new\ngenome hg19\nexit\n' > /genome.bat
xvfb-run --auto-servernum --server-num=1 igv.sh -b /genome.bat

%test
which igv.sh

%environment
export PATH="/IGV_2.4.10/:${PATH}"
22 changes: 22 additions & 0 deletions run.Singularity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# example wrapper script to launch the snapshot script inside a Singularity container (needed if xvfb is not installed)

# default path to Singularity container file
container="${1:-IGV.simg}"

# need to load Singularity if running on Big Purple HPC
if [ "$(hostname | grep -q 'bigpurple' ; echo $?)" -eq 0 ]; then
module load singularity/2.5.2

# command to launch Singularity container and run commands inside the container
# NOTE: you may need to make sure that the directory filesystem root and the current dir are bound to the container with `-B`
singularity exec \
-B /gpfs \
-B "${PWD}" \
"${container}" \
/bin/bash -c " \
cd ${PWD}
python make_IGV_snapshots.py test_data/test_alignments.bam test_data/test_alignments2.bam
"
fi

0 comments on commit d32f178

Please sign in to comment.