(howto) Debug AnalyzeCovariates Error in R

SheilaSheila Broad InstitutePosts: 1,010Member, GATK Developer, Broadie, Moderator admin
edited June 2014 in Tutorials

When you are running AnalyzeCovariates to analyze your BQSR outputs, you may run into an error starting with this:

org.broadinstitute.sting.utils.R.RScriptExecutorException: RScript exited with 1. Run with -l DEBUG for more info.

The main reason why this error often occurs is simple, and so is the solution. The script depends on some external R libraries, so if you don’t have them installed, the script fails. To find out what libraries are necessary and how to install them, you can refer to this FAQ article.

One other common issue is that the version of ggplot2 you have installed is very recent and is not compatible with the BQSR script. If so, download this file and use it to generate the plots manually according to the instructions below.

If you have already checked that you have all the necessary libraries installed, you’ll need to run the script manually in order to find out what is wrong. To new users, this can seem complicated, but it only takes these 3 simple steps to do it!

1. Re-run AnalyzeCovariates with these additional parameters:

  • -l DEBUG (that's a lowercase L, not an uppercase i, to be clear) and
  • -csv my-report.csv (where you can call the .csv file anything; this is so the intermediate csv file will be saved).

2. Identify the lines in the log output that says what parameters the RScript is given.

The snippet below shows you the components of the R script command line that AnalyzeCovariates uses.

INFO  18:04:55,355 AnalyzeCovariates - Generating plots file 'RTest.pdf' 
DEBUG 18:04:55,672 RecalUtils - R command line: Rscript (resource)org/broadinstitute/gatk/utils/recalibration/BQSR.R /Users/schandra/BQSR_Testing/RTest.csv /Users/schandra/BQSR_Testing/RTest.recal /Users/schandra/BQSR_Testing/RTest.pdf 
DEBUG 18:04:55,687 RScriptExecutor - Executing: 
DEBUG 18:04:55,688 RScriptExecutor -   Rscript 
DEBUG 18:04:55,688 RScriptExecutor -   -e 
DEBUG 18:04:55,688 RScriptExecutor -   tempLibDir = '/var/folders/j9/5qgr3mvj0590pd2yb9hwc15454pxz0/T/Rlib.2085451458391709180';source('/var/folders/j9/5qgr3mvj0590pd2yb9hwc15454pxz0/T/BQSR.761775214345441497.R'); 
DEBUG 18:04:55,689 RScriptExecutor -   /Users/schandra/BQSR_Testing/RTest.csv 
DEBUG 18:04:55,689 RScriptExecutor -   /Users/schandra/BQSR_Testing/RTest.recal 
DEBUG 18:04:55,689 RScriptExecutor -   /Users/schandra/BQSR_Testing/RTest.pdf 

So, your full command line will be:

RScript BQSR.R RTest.csv RTest.recal RTest.pdf

Please note:

  • BQSR.R is the name of the script you want to run. It can be found here
  • RTest.csv is the name of the original csv file output from AnalyzeCovariates.
  • RTest.recal is your original recalibration file.
  • RTest.pdf is the output pdf file; you can name it whatever you want.

3. Run the script manually with the above arguments.

For new users, the easiest way to do this is to do it from within an IDE program like RStudio. Or, you can start up R at the command line and run it that way, whatever you are comfortable with.

Post edited by Geraldine_VdAuwera on


  • ritamichelleritamichelle IndianaPosts: 5Member

    Hi GATK! Would it be possible for you to post an updated link to the BQSR.R script? The link above is no longer working. I spent awhile poking around GitHub looking for it, but seemed to just be going in circles. Best wishes!

  • ritamichelleritamichelle IndianaPosts: 5Member

    Nevermind, link at the top of the page DOES work, I'll try with this script...

  • Geraldine_VdAuweraGeraldine_VdAuwera Posts: 7,165Administrator, GATK Developer admin

    OK - note that the BQSR script is fixed in the latest version, so you may want to simply upgrade your GATK version...

    Geraldine Van der Auwera, PhD

  • vifehevifehe SpainPosts: 25Member

    HI Geraldine!

    I am having some issues with debugging AnalyzeCovariates.
    here is my command line:
    java -Xmx5g -jar /opt/exoma/bin//GATK-v3.3/GenomeAnalysisTK.jar -T AnalyzeCovariates -R reference_files/hg19/ucsc.hg19.fasta -before Bonn_recal_1/recal_1005.table -after Bonn_recal_1/post_recal_1005.table -plots Bonn_recal_1/recalibration_1005.pdf -l DEBUG -csv Bonn_recal_1/my_debug_report.csv

    and this is the error I get:

    `##### ERROR ------------------------------------------------------------------------------------------

    ERROR stack trace

    org.broadinstitute.gatk.utils.R.RScriptExecutorException: RScript exited with 1
    at org.broadinstitute.gatk.utils.R.RScriptExecutor.exec(RScriptExecutor.java:174)
    at org.broadinstitute.gatk.utils.recalibration.RecalUtils.generatePlots(RecalUtils.java:581)
    at org.broadinstitute.gatk.tools.walkers.bqsr.AnalyzeCovariates.generatePlots(AnalyzeCovariates.java:386)
    at org.broadinstitute.gatk.tools.walkers.bqsr.AnalyzeCovariates.initialize(AnalyzeCovariates.java:400)
    at org.broadinstitute.gatk.engine.executive.LinearMicroScheduler.execute(LinearMicroScheduler.java:83)
    at org.broadinstitute.gatk.engine.GenomeAnalysisEngine.execute(GenomeAnalysisEngine.java:319)
    at org.broadinstitute.gatk.engine.CommandLineExecutable.execute(CommandLineExecutable.java:121)
    at org.broadinstitute.gatk.utils.commandline.CommandLineProgram.start(CommandLineProgram.java:248)
    at org.broadinstitute.gatk.utils.commandline.CommandLineProgram.start(CommandLineProgram.java:155)
    at org.broadinstitute.gatk.engine.CommandLineGATK.main(CommandLineGATK.java:107)

    ERROR ------------------------------------------------------------------------------------------
    ERROR A GATK RUNTIME ERROR has occurred (version 3.3-0-g37228af):
    ERROR This might be a bug. Please check the documentation guide to see if this is a known problem.
    ERROR If not, please post the error message, with stack trace, to the GATK forum.
    ERROR Visit our website and forum for extensive documentation and answers to
    ERROR commonly asked questions http://www.broadinstitute.org/gatk
    ERROR MESSAGE: RScript exited with 1
    ERROR ------------------------------------------------------------------------------------------`

    Could you provide me with some indications on how to preoceed to debug it?



  • vifehevifehe SpainPosts: 25Member

    So I figured out what was wrong while reading the log file, right after the R scipt command line that AnalyzeCovariates uses, I got:

    Loading required package: methods
    Error in library(gplots) : there is no package called \u2018gplots\u2019
    Calls: source -> withVisible -> eval -> eval -> library

    So I installed in R gplots.
    Then I got again another R-related error in the same area:

    Error in library("reshape") : there is no package called \u2018reshape\u2019
    Calls: source -> withVisible -> eval -> eval -> library
    Execution halted

    and after installing in R reshape it now runs smoothly


  • gwilymhgwilymh Posts: 20Member

    What exactly is the "original recalibration file" file?

  • gwilymhgwilymh Posts: 20Member

    Is it one or more graph files? Is it one of the table files? If you are comparing the results of three different recalibration runs, can you enter more than one file?

  • Geraldine_VdAuweraGeraldine_VdAuwera Posts: 7,165Administrator, GATK Developer admin

    The original recalibration file is the recal file produced in the very first pass of BaseRecalibrator.

    Geraldine Van der Auwera, PhD

Sign In or Register to comment.