Updated 2021-05-17

Run Bedtools on the Cluster

Summary

  • Bedtools contains a multitude of tools used for genomic analysis and allows for functionality such as shuffling, merging, and intersecting genomic intervals.
  • Use module avail bedtools to see all the available versions of bedtools on the cluster
  • To load bedtools in your PBS script:
    • Load its dependent module first with module load gcc/4.9.0
    • Load bedtools with module load bedtools/2.25. Replace the version number with any version you prefer that is available on the cluster (found with module avail)
  • To run bedtools:
    • In your PBS script, put all lines executing bedtools after the module load lines that load bedtools
    • Example: using the intersect tool, the line bedtools intersect -a <filename>.bed -b genes.bed would go in the PBS script after the lines that load the correct modules for bedtools.

Example PBS Script

#PBS -N bedtoolsTest
#PBS -A [Account] 
#PBS -l nodes=2:ppn=4
#PBS -l walltime=20:00
#PBS -q inferno
#PBS -j oe
#PBS -o bedtoolsResult.out

cd $PBS_O_WORKDIR
module load gcc/4.9.0
module load bedtools/2.25
bedtools intersect -a reads.bed -b genes.bed
  • The #PBS directives are standard, requesting 20 min of walltime and 2 nodes with 4 cores per node. More on #PBS directives can be found in the PBS guide

Note

If using $PBS_O_WORKDIR,the .bed files, as well as any other files required for the job, must be stored in the same folder as the PBS script

  • $PBS_O_WORKDIR is simply a variable that represents the directory you submit the PBS script from. Make sure the .bed files, and any other files you need are in the same directory you put the PBS script in. This line tells the cluster to enter this directory where you have stored the PBS script, and look for all the files for the job. If you use $PBS_O_WORKDIR, you need to have all your files in the same folder as your PBS script otherwise the cluster won't be able to find the files it needs.
  • Output Files: Any files generated by the job will also show up in the same directory as the PBS script.
  • The module load lines load bedtools and its dependent module
  • The bedtools intersect line is just a general example showing how bedtools might be executed. The line is from the bedtools documentation which includes much more information on the capabilities of bedtools. The point is to show that the execution lines must be included after:
    • Entering the correct folder with all the files and PBS script, in this case achieved with cd $PBS_O_WORKDIR
    • bedtools is loaded with the module load lines

Submit Job and Check Status

  • Make sure you're in the directory that contains the PBS script, the sequence files, and any other files you need.
  • Submit with qsub <pbs script name>. In this case qsub bedtools.pbs or whatever you called the PBS script. You can name the PBS scripts whatever you want, just keep the .pbs at the end
  • Check job status with qstat -u username3 -n, replacing "username3" with your gt username
  • You can delete the job with qdel 22182721, replacing the number with the jobid returned after running qsub
  • Depending on the resources requested and queue the job is run on, it may take varying amounts of time for the job to start. To estimate the time until the job executes, run showstart 22182721, replacing the number with the jobid returned after running qsub. More helpful commands can be found in this guide

Collecting Results

  • All files created will be in the same folder where your PBS script is (same directory you ran qsub from)
  • The .out file will be found here as well. It contains the results of the job, as well as diagnostics and a report of resources used during the job. If the job fails or doesn't produce the result your were hoping for, the .out file is a great debugging tool.
  • You can transfer the resulting files off the cluster using scp or a file transfer service