Mercurial > repos > stef > qdnaseq
changeset 72:fb2dfd8ba417 draft
Uploaded
author | stef |
---|---|
date | Fri, 05 Sep 2014 11:10:27 -0400 |
parents | a93649056969 |
children | 4db025c51b6e |
files | QDNAseq.R QDNAseq.sh QDNAseq.xml static/binannotation/1000kbp_binAnnotations.rds static/binannotation/100kbp_binAnnotations.rds static/binannotation/15kbp_binAnnotations.rds static/binannotation/30kbp_binAnnotations.rds static/images/LGG150_copynumber.png static/images/LGG150_copynumberSegmented.png static/images/LGG150_copynumber_example.png tool_dependencies.xml |
diffstat | 11 files changed, 176 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/QDNAseq.R Wed Aug 27 04:56:37 2014 -0400 +++ b/QDNAseq.R Fri Sep 05 11:10:27 2014 -0400 @@ -38,6 +38,8 @@ l1 <- length(paths) l2 <- length(names) if ( l1 != l2 ) stop( "Unequal amount of bam-paths (", l1, ") and -names (", l2, ") in makeBamFileList!!!\n" ) + if ( l1 == 0 ){ return(tmp) } # empty list in debug mode + for ( i in 1:length(paths) ){ path <- paths[i] name <- names[i] @@ -155,9 +157,6 @@ ## desparate tries to make png text scale well, damn you R...! PLOT_RES <- min( PLOT_WIDTH, PLOT_HEIGHT ) / 6.3 -#PLOT_PS <- min( PLOT_WIDTH, PLOT_HEIGHT ) / 40 -#TXT_FACTOR <- PLOT_WIDTH/480 -#PAR_SET <- list( pch=22, cex.lab=TXT_FACTOR, cex.main=TXT_FACTOR ) PAR_SET <- list( pch=22 ) systemUser <- system("whoami",T) @@ -176,8 +175,8 @@ ## ------------------------ ## DEBUG if ( debug ){ - catMsg( c("Analysis run under user: ", systemUser ) ) - catMsg( c("Here comes sessionInfo: " ) ) + catMsg( c("Analysis run by user: ", systemUser ) ) + catMsg( c("DEBUG SessionInfo: " ) ) print( sessionInfo() ) } ## /DEBUG @@ -189,7 +188,9 @@ } ## copy source config file to output dir to include it in output zip -file.copy( config, paste(outputPath, 'galaxyConfigFile.R', sep='/') ) +if ( inGalaxy ){ + file.copy( config, paste(outputPath, 'galaxyConfigFile.R', sep='/') ) +} ## setup bam filelist for easy retrieval later fileList <- makeBamFileList( bamsPaths, bamsNames ) @@ -233,7 +234,13 @@ igvCopyNrPath <- paste( outputPath, '/', igvCopyNrName, sep='') noiseImgPath <- paste( outputPath, '/', noiseImgName, sep='') - binAnnotations <- getBinAnnotations( binSize=binSize, type=experimentType ) + binAnnFile <- paste( TOOL_PATH, '/static/binannotation/', binSize, 'kbp_binAnnotations.rds', sep="" ) + if ( file.exists(binAnnFile) ){ + binAnnotations <- readRDS( binAnnFile ) + catMsg( c("Using local binAnnotations file" ) ) + }else{ + binAnnotations <- getBinAnnotations( binSize=binSize, type=experimentType ) + } ## in case of debug just use inbuilt LGG data for speedup if ( debug ){ @@ -493,8 +500,9 @@ ## ------------------------ ## creating main html output for galaxy history ## ------------------------ -sink( file = outputHtml, type = "output" ) - +if ( inGalaxy ){ # dont create when running outside Galaxy + sink( file = outputHtml, type = "output" ) + cat( "<head>", "\n") cat( "\t", '<link rel="stylesheet" href="', PURE_CSS, '">', "\n", sep='' ) @@ -509,7 +517,8 @@ cat( '<p>Explore <a href="', htmlOutputName, '" class="button">the results</a> directly within galaxy</p>', "\n", sep="") cat( '<p>Or download a <a href="', gzipOutputName, '" class="button">zipfile</a> with all output (', zippedSize, ')</p>', "\n", sep="" ) -sink() + sink() +} ## ------------------------ ## create final zip and quit with status 0 to tell galaxy all was fine
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QDNAseq.sh Fri Sep 05 11:10:27 2014 -0400 @@ -0,0 +1,148 @@ +#!/bin/sh + +## This script creates a config file for use with the QDNAseq R wrapper +## For use outside Galaxy + +QDNASEQ_R_SCRIPT='/ccagc/home/stef/code/QDNASEQ/QDNAseq.R' +R_LOCATION='/ccagc/lib/R/R-3.1.0/bin/' +OUTPUT_DIR='QDNASEQ' +SCRIPT_DIR=$(dirname $0) +SCRIPT_NAME=$(basename $0) + +binSizesString='1000,100,15' +outputName=`basename $PWD` +doSegment='TRUE' +debug='FALSE' + +usage() +{ +cat<<EOF + This script creates a QDNAseq wrapper config. + + Experiment name and/or output dir are optional + $SCRIPT_NAME [-n myExperiment] [-o outputDir] *.bam + + Debug mode for working with build in LGG150 data + $SCRIPT_NAME -d + + OPTIONS: + -n [s] provide analysis name [$outputName] + -o [s] output dir [$OUTPUT_DIR] + -d debug mode (only create config) + +EOF +} + +PARAM_COUNT=0 +if [ $# -eq 0 ] || [ "$1" == "-h" ] +then + usage + exit 1 +else + while getopts "n:o:d" opt; do + case $opt in + n) + #echo "$opt was triggered, Parameter: $OPTARG" >&2 + outputName=$OPTARG + PARAM_COUNT=`bc <<< $PARAM_COUNT+2` + ;; + o) + OUTPUT_DIR=$OPTARG + PARAM_COUNT=`bc <<< $PARAM_COUNT+2` + ;; + d) + debug='TRUE' + PARAM_COUNT=`bc <<< $PARAM_COUNT+1` + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac + done +fi + +## set param dependent variables +printf '%s\n' "[INFO] --- QDNAseq wrapper config creator ---" +CONFIG_FILE=$OUTPUT_DIR'/qdnaseqConfig.R' + +## remove the params from input string leaving only the BAMs +shift $PARAM_COUNT + +## sanity checks +if [ -e $CONFIG_FILE ]; then + echo "[ERR] Config file ($CONFIG_FILE) already exists, exit.."; + exit 0 +fi +if [ -d $OUTPUT_DIR ]; then + echo "[ERR] Output dir ($OUTPUT_DIR) already exists, exit.."; + exit 0 +else + mkdir $OUTPUT_DIR +fi + +## variables setup +CONFIG_TXT="## ========== +## QDNAseq pipeline config file +## ========== + +## ---------- +inGalaxy <- FALSE +binSizesString <- '$binSizesString' +experimentType <- 'SR50' +outputName <- '$outputName' + +## ---------- +outputHtml <- 'galaxyIndex.html' +outputId <- NA +newFilePath <- '$OUTPUT_DIR' +outputPath <- '$OUTPUT_DIR' +doSegment <- as.logical( $doSegment ) +debug <- as.logical( $debug ) +undoSD <- as.double( 1.0 ) +binAnnotations <- '' + +## ---------- +filterBlacklistedBins <- as.logical( 'TRUE' ) +mappabilityCutoff <- as.integer( 0 ) +undoSplits <- 'sdundo' +doOutputCopynumbersIgv <- FALSE + +## ---------- +PLOT_WIDTH <- as.integer( 1440 ) +PLOT_HEIGHT <- as.integer( 720 ) +excludeChrsString <- 'X,Y' + +## ---------- +bamsPaths <- c() +bamsNames <- c() +" + +## create config file +printf '%s\n' "$CONFIG_TXT" > $CONFIG_FILE + +## add bam files to config file +BAMS=$@ +for bam_path in $BAMS; do + + if [ ! -e $bam_path ]; then + echo "[ERR] Bam file does not exist ($bam_path), exit.."; + exit 0 + fi + + bam_name=`basename "$bam_path"` + printf '%s\n' "bamsPaths <- c( bamsPaths, \"$bam_path\" )" >> $CONFIG_FILE + printf '%s\n' "bamsNames <- c( bamsNames, \"$bam_name\" )" >> $CONFIG_FILE + printf '%s\n' "[INFO] BAM: $bam_name" +done + +## done +printf '%s\n' "[INFO] OUTPUT DIR: $OUTPUT_DIR" +printf '%s\n' "[INFO] OUTPUT NAME: $outputName" +printf '%s\n' "[INFO] CONFIG FILE can be found in $CONFIG_FILE" +printf '%s\n' "[INFO] Run with: $R_LOCATION/Rscript $QDNASEQ_R_SCRIPT $CONFIG_FILE" +printf '%s\n' "[INFO] Done" \ No newline at end of file
--- a/QDNAseq.xml Wed Aug 27 04:56:37 2014 -0400 +++ b/QDNAseq.xml Fri Sep 05 11:10:27 2014 -0400 @@ -10,7 +10,6 @@ <description>Quantitative copy number abberation detection</description> - <!-- command block to call script with default R installation --> <!-- change to /full/path/to/Rscript if required (eg /ccagc/lib/R/R-3.1.0/bin/Rscript) --> <command interpreter="Rscript"> QDNAseq.R @@ -38,9 +37,9 @@ <!-- Bin Size: only certain sizes are supported by QDNAseq package --> <param name="binSizes" type="select" optional="false" multiple="true" label="Select bin-sizes to use (kb)" help="Larger bin sizes provide faster analysis but lower resolution"> <option value="1000" selected="true">1Mb</option> - <option value="100">100kb</option> + <option value="100" selected="true">100kb</option> <option value="30">30kb</option> - <option value="15">15kb</option> + <option value="15" selected="true">15kb</option> <option value="5">5kb</option> <option value="1">1kb</option> </param> @@ -166,6 +165,7 @@ ## ----- ## required params ## ----- +TRUE -> inGalaxy "${binSizes}" -> binSizesString "${experimentType}" -> experimentType "${jobName}" -> outputName
--- a/tool_dependencies.xml Wed Aug 27 04:56:37 2014 -0400 +++ b/tool_dependencies.xml Fri Sep 05 11:10:27 2014 -0400 @@ -5,19 +5,21 @@ <repository changeset_revision="c0f72bdba484" name="package_samtools_0_1_18" owner="devteam" toolshed="https://testtoolshed.g2.bx.psu.edu" prior_installation_required="TRUE" /> </package> - <!-- As soon as R 3_1_0 package works, all QDNAseq dependencies will be set via "package_qdnaseq_1_0_5" --> - <!-- Now this depency has to be manually installed by installing Bioconductor package "QDNAseq" --> + <!-- As soon as R 3_1_0 package works good, all dependencies will be set via "package_qdnaseq_1_0_5" --> + <!-- Currently these have to be manually installed by installing Bioconductor package "QDNAseq" --> + <!-- <package name="R" version="3.1.0"> <repository changeset_revision="a6cc7706ea14" name="package_r_3_1_0" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" prior_installation_required="TRUE" /> </package> - + --> + + <!-- <package name="qdnaseq" version="1.0.5"> <repository name="package_qdnaseq_1_0_5" owner="stef"/> </package> --> - <!-- environment variable not in use now --> <!-- <action type="set_environment"> <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR</environment_variable>