changeset 30:fac55e1121ee draft default tip

Uploaded
author gkumar09
date Wed, 02 Dec 2015 00:04:10 -0500
parents f7c062297fb9
children
files trinityrnaseq_protocol/.___add_to_PATH_setting.txt trinityrnaseq_protocol/EdgeR_differentialExpression.xml trinityrnaseq_protocol/EdgeR_differentialExpression_wrapper.py trinityrnaseq_protocol/__add_to_PATH_setting.txt trinityrnaseq_protocol/abundance_estimation_to_matrix.xml trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py trinityrnaseq_protocol/align_and_estimate_abundance.xml trinityrnaseq_protocol/analyze_diff_exp.xml trinityrnaseq_protocol/analyze_diff_exp_wrapper.py trinityrnaseq_protocol/bash_command_executer.py trinityrnaseq_protocol/concatenate.xml trinityrnaseq_protocol/trinityToolWrapper.py
diffstat 12 files changed, 526 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file trinityrnaseq_protocol/.___add_to_PATH_setting.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/EdgeR_differentialExpression.xml	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,40 @@
+<tool id="EdgeR_differentialExpression" name="EdgeR_differentialExpression" version="0.0.1">
+
+    <description>Identify Differentially Expressed Transcripts Using EdgeR</description>
+    <requirements>
+        <requirement type="package">trinity</requirement>
+    </requirements>
+    <command interpreter="python">
+
+ 		EdgeR_differentialExpression_wrapper.py 
+			$counts_matrix 
+			$dispersion
+			
+    </command>
+    <inputs>
+		
+		<param type="data" format="txt" name="counts_matrix" label="Matrix of RNA-Seq fragment counts for transcripts per condition" />
+		<param type="data" format="fasta" name="transcripts_fasta_file" label="Transcripts fasta file corresponding to matrix" />
+		<param type="float" name="dispersion" value="0.1" min="0" label="dispersion value" help="Dispersion value to be used in the negative binomial" />
+	
+    </inputs>
+    <outputs>
+        
+        <data format="tar.gz" name="EdgeR_Archive" label="${tool.name} on ${on_string}: EdgeR_Results.tar.gz" from_work_dir="edgeR_results.tar.gz" />
+			
+	</outputs>
+    <tests>
+
+		<test>
+			<param name="counts_matrix" value="matrix_text_file" />
+			<param name="transcript_fasta_file" value="fasta_file" />
+			<param name="dispersion" value="0.1" />
+			<output name="EdgeR_Archive" file="EdgeR_Results.tar.gz" />
+        </test>
+	
+
+    </tests>
+    <help>
+         help info here.
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/EdgeR_differentialExpression_wrapper.py	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,40 @@
+import sys, os, subprocess
+
+TRINITY_BASE_DIR = ""
+if os.environ.has_key('TRINITY_HOME'):
+    TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
+else:
+    sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
+    sys.exit(1)
+
+usage= "usage: " + " $counts_matrix" + " $dispersion"
+
+if len(sys.argv)<2:
+    print "Require atleast two parameters"
+else:
+    print "All good- command going ahead"
+print " "
+
+def run_command(cmd):
+    print "The command used: " + cmd
+    pipe=subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
+    pipe.wait()
+    ret= pipe.returncode
+    if ret:
+        print "command died: " + str(ret)
+        print pipe.stderr.readlines()
+        sys.exit(1)
+    else:
+        return
+print " "
+
+countmatrix= "counts_matrix"
+
+cmd= "cp " + sys.argv[1] + " " + countmatrix 
+run_command(cmd)
+
+cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/run_DE_analysis.pl "+ " --matrix "+ countmatrix + " --method edgeR " + " --output edgeR_results "+ " --dispersion " + sys.argv[2] + " --tar_gz_outdir"
+
+run_command(cmd)
+
+sys.exit(0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/__add_to_PATH_setting.txt	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,1 @@
+/usr/local/bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/abundance_estimation_to_matrix.xml	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,42 @@
+<tool id="abundance_estimation_to_matrix" name="abundance_estimation_to_matrix" version="0.0.1">
+
+    <description>Join RSEM estimates from multiple samples into a single matrix</description>
+    <requirements>
+        <requirement type="package">trinity</requirement>
+    </requirements>
+    <command interpreter="python">
+
+        abundance_estimation_to_matrix_wrapper.py 
+		#for $q in $RSEM_samples
+			${q.file} "${q.column_label}"
+		#end for
+
+    </command>
+    <inputs>
+
+       <repeat name="RSEM_samples" title="RSEM abundance estimates for samples">
+              <param name="file" label="Add file" type="data" format="text"/>
+              <param name="column_label" label="column label" type="text" />
+       </repeat>
+
+    </inputs>
+    <outputs>
+        <data format="text" name="counts_matrix" label="${tool.name} on ${on_string}: Counts Matrix" from_work_dir="matrix.counts.matrix"/>
+	</outputs>
+    <tests>
+
+
+		<test>
+			<param name="target" value="trinity/Trinity.fasta" />
+			<param name="aligner" value="bowtie" />
+			<param name="paired_or_single" value="single" />
+			<param name="library_type" value="None" />
+			<param name="input" value="trinity/reads.left.fq" />
+        </test>
+	
+
+    </tests>
+    <help>
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+
+import sys, os, string, subprocess
+
+#aliasing the filenames using the labels
+
+
+def run_command(command):
+    print "Running command: " + command
+    
+    err_capture_file = open("my.stderr", 'w') # writing stderr to a file
+    cmd_run = subprocess.Popen(args=command, shell=True, stderr=err_capture_file, stdout=sys.stdout)
+    err = cmd_run.wait() # get exit code from command execution
+    err_capture_file.close()
+
+    if err:
+        # report the error messages we captured, and exit non-zero
+        sys.stderr.write("Error, cmd: " + command + " died with ret: " + `err`)
+        for line in open(err_capture_file):
+            sys.stderr.write(line)
+        sys.exit(err)
+    return
+
+label_list = []  # symlink files to the labels
+for i in range(1, len(sys.argv), 2):
+    filename=sys.argv[i]
+    label= sys.argv[i+1]
+    cmd= "ln -sf " + filename + " " + label
+    label_list.append(label)
+    run_command(cmd)
+
+
+# run the abundance estimation script
+
+cmd = os.path.dirname(sys.argv[0]) + "/trinityToolWrapper.py " + " util/abundance_estimates_to_matrix.pl --est_method RSEM --cross_sample_norm TMM " + " ".join(label_list)
+
+run_command(cmd)
+
+sys.exit(0)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/align_and_estimate_abundance.xml	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,89 @@
+<tool id="RSEM_abundance_estimation" name="RSEM_abundance_estimation" version="0.0.1">
+
+    <description>run RSEM to estimate transcript abundances</description>
+    <requirements>
+        <requirement type="package">trinity</requirement>
+    </requirements>
+    <command interpreter="python">
+
+        trinityToolWrapper.py util/align_and_estimate_abundance.pl --transcripts $transcripts --est_method RSEM --aln_method bowtie --trinity_mode --prep_reference --output_dir  "subdir" 
+
+        ## Inputs.
+        #if str($inputs.paired_or_single) == "paired":
+            --left $inputs.left_input --right $inputs.right_input
+            #if  $inputs.left_input.ext == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+            
+        #else:
+            --single $inputs.input
+            #if  str($inputs.input.ext) == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+        #end if
+
+
+    </command>
+    <inputs>
+		<param format="fasta" name="transcripts" type="data" label="transcripts_fasta" help="Fasta sequences for which reads are aligned."  />
+
+		<conditional name="inputs">
+                    <param name="paired_or_single" type="select" label="Paired or Single-end data?">
+                <option value="paired">Paired</option>
+                <option value="single">Single</option>
+            </param>
+            <when value="paired">
+                <param format="fasta,fastq" name="left_input" type="data" label="Left/Forward strand reads" help=""/>
+                <param format="fasta,fastq" name="right_input" type="data" label="Right/Reverse strand reads" help=""/>
+                <param name="library_type" type="select" label="Strand-specific Library Type">
+                    <option value="None">None</option>
+                    <option value="FR">FR</option>
+                    <option value="RF">RF</option>
+                </param>
+
+            </when>
+            <when value="single">
+                <param format="fasta,fastq" name="input" type="data" label="Single-end reads" help=""/>
+                <param name="library_type" type="select" label="Strand-specific Library Type">
+                    <option value="None">None</option>
+                    <option value="F">F</option>
+                    <option value="R">R</option>
+                </param>
+
+            </when>
+        </conditional>
+
+	
+    </inputs>
+    <outputs>
+        <data format="text" name="transcript_counts" label="${tool.name} on ${on_string}: Isoform Counts" from_work_dir="subdir/RSEM.isoforms.results"/>
+		<data format="text" name="gene_counts" label="${tool.name} on ${on_string}: Gene counts" from_work_dir="subdir/RSEM.genes.results"/>
+
+
+	</outputs>
+    <tests>
+
+
+		<test>
+			<param name="transcript_file" value="fasta" />
+			<param name="input" value="reads.left.fq" />
+			<output name="transcripts_counts" file="text" />
+		
+        </test>
+	
+
+    </tests>
+    <help>
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/analyze_diff_exp.xml	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,44 @@
+<tool id="Analyze_Diff_Exp" name="Analyze_Differential_Expression" version="0.0.1">
+
+    <description>Analyze differential expression</description>
+    <requirements>
+        <requirement type="package">trinity</requirement>
+    </requirements>
+    <command interpreter="python">
+
+        analyze_diff_exp_wrapper.py $EdgeRTarGz $TMM_Matrix_FPKM $Pvalue $Cvalue 
+	
+    </command>
+    <inputs>
+              <param name="EdgeRTarGz" label="EdgeR tar gz file" type="data" format="file"/>
+              <param name="TMM_Matrix_FPKM" label="TMM Normalized FPKM matrix" type="data" format="file" />
+	      <param name="Pvalue" label="P-value" value="0.05" type="float" />
+	      <param name="Cvalue" label="C-value" value="0" type="float" />
+      
+    </inputs>
+    <outputs>
+        <data format="data" name="diffExpr_matrix" label="${tool.name} on ${on_string}: Matrix" from_work_dir="diffExpr.matrix"/>
+	<data format="data" name="diffExpr_correlation_matrix" label="${tool.name} on ${on_string}: Sample_Correlation_Matrix" from_work_dir="diffExpr.matrix.log2.sample_cor.dat"/>
+	<data format="data" name="diffExpr_correlation_matrix_pdf" label="${tool.name} on ${on_string}: Sample_Correlation_Matrix_PDF" from_work_dir="diffExpr.matrix.log2.sample_cor_matrix.pdf"/>
+	<data format="data" name="Heatmap" label="${tool.name} on ${on_string}: Heatmap" from_work_dir="diffExpr.matrix.log2.centered.genes_vs_samples_heatmap.pdf"/>
+    </outputs>
+    <tests>
+
+
+		<test>
+			<param name="EdgeRtargz" value="EdgeR.tar.gz" />
+			<param name="TMM_matrix" value="matrix_file" />
+			<param name="P_value" value="float" />
+			<param name="C_value" value="float" />
+			<output name="diffExpr_matrix" file="diffExp.matrix" />
+			<output name="SampleCorrelation_matrix" file="diffExp.matrix.log2.dat" />
+			<output name="Correlation_matrix" file="diffExp_matrix.pdf" />
+			<output name="heatmap" file="heatmap.pdf" />
+        </test>
+	
+
+    </tests>
+    <help>
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/analyze_diff_exp_wrapper.py	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,63 @@
+import sys, os, subprocess
+
+TRINITY_BASE_DIR = ""
+if os.environ.has_key('TRINITY_HOME'):
+    TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
+else:
+    sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
+    sys.exit()
+
+usage= "usage: " + sys.argv[0] + " " + "edgeR.tar.gz " + "TMM_normalized_FPKM_matrix " + "P-value " + "C-value"
+print sys.argv 
+print usage 
+print " "
+
+if len(sys.argv)<5:
+	print "Require atleast two parameters"
+else:
+	print "All good- command going ahead"
+print " "
+
+Normalized_Matrix=sys.argv[2]
+Pvalue=sys.argv[3]
+Cvalue=sys.argv[4]
+
+def run_command(cmd):
+	print "The command used: " + cmd
+	pipe= subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
+        pipe.wait()
+	ret= pipe.returncode
+	if ret:
+		print "command died: " + str(ret)
+                print pipe.stderr.readlines()
+                sys.exit(1)
+	else:
+		return
+print " "
+
+Final_tar_gz= "edgeR.tar.gz"
+run_command("cp "+ sys.argv[1] + " " + "Final_tar_gz")
+run_command("tar -xvf " + "Final_tar_gz")
+run_command("mv " + "edgeR_results" + "/* ." )
+
+# run the analyze command
+cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/analyze_diff_expr.pl "+ "--matrix " +  Normalized_Matrix + " -P " +  Pvalue + " -C " + Cvalue
+run_command(cmd)
+
+origMatrixName= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix"
+# diffExpr.P0.001_C2.0.matrix
+run_command("mv " + origMatrixName + " diffExpr.matrix")
+
+SampleCorName= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.sample_cor.dat"
+# diffExpr.P0.001_C2.0.matrix.log2.sample_cor.dat
+run_command("mv " + SampleCorName + " diffExpr.matrix.log2.sample_cor.dat")
+
+CorMatrix= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.sample_cor_matrix.pdf"
+# diffExpr.P0.001_C2.0.matrix.log2.sample_cor_matrix.pdf
+run_command("mv " + CorMatrix + " diffExpr.matrix.log2.sample_cor_matrix.pdf")
+
+Heatmap= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.centered.genes_vs_samples_heatmap.pdf"
+#diffExpr.P0.001_C2.0.matrix.log2.centered.genes_vs_samples_heatmap.pdf
+run_command("mv " + Heatmap + " diffExpr.matrix.log2.centered.genes_vs_samples_heatmap.pdf")
+
+sys.exit(0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/bash_command_executer.py	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+
+import sys, subprocess, os
+
+def stop_err( msg ):
+    sys.stderr.write( "%s\n" % msg )
+    sys.exit()
+
+def __main__():
+    # Get command-line arguments
+    args = sys.argv
+    # Remove name of calling program, i.e. ./stderr_wrapper.py
+    args.pop(0)
+
+    # If there are no arguments left, we're done
+    if len(args) == 0:
+        return
+
+    # If one needs to silence stdout 
+    #args.append( ">" )
+    #args.append( "/dev/null" )
+
+    cmdline = " ".join(args)
+    
+    
+    try:
+        # Run program
+        err_capture = open("stderr.txt", 'w')
+        proc = subprocess.Popen( args=cmdline, shell=True, stderr=err_capture, stdout=sys.stdout )
+        returncode = proc.wait()
+        err_capture.close()
+
+        
+        if returncode != 0:
+            raise Exception
+
+    except Exception:
+        # Running Grinder failed: write error message to stderr
+        err_text = open("stderr.txt").readlines()
+        stop_err( "ERROR:\n" + "\n".join(err_text))
+
+
+if __name__ == "__main__": __main__()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/concatenate.xml	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,41 @@
+<tool id="catbash" name="Concatenate datasets">
+    <description> concatenate datasets from tail to head</description>
+    <command interpreter="python">
+        bash_command_executer.py cat
+        $input1
+        #for $q in $queries
+            ${q.input2}
+        #end for
+        > $out_file1 
+    </command>
+    <inputs>
+        <param name="input1" type="data" label="Concatenate Dataset"/>
+        <repeat name="queries" title="Dataset">
+            <param name="input2" type="data" label="Select" />
+        </repeat>
+    </inputs>
+    <outputs>
+        <data name="out_file1" format="input" metadata_source="input1"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input1" value="1.bed"/>
+            <param name="input2" value="2.bed"/>
+            <output name="out_file1" file="cat_wrapper_out1.bed"/>
+        </test>
+        <!--TODO: if possible, enhance the underlying test code to handle this test
+            the problem is multiple params with the same name "input2"
+        <test>
+            <param name="input1" value="1.bed"/>
+            <param name="input2" value="2.bed"/>
+            <param name="input2" value="3.bed"/>
+            <output name="out_file1" file="cat_wrapper_out2.bed"/>
+        </test>
+        -->
+    </tests>
+    <help>
+
+    no help
+
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/trinityToolWrapper.py	Wed Dec 02 00:04:10 2015 -0500
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+
+# borrowed from: http://wiki.g2.bx.psu.edu/Future/Job%20Failure%20When%20stderr and modified for use with Trinity tools.
+
+"""
+Wrapper that execute a program and its arguments but reports standard error
+messages only if the program exit status was not 0
+Example: ./stderr_wrapper.py myprog arg1 -f arg2
+"""
+
+import sys, subprocess, os
+
+assert sys.version_info[:2] >= ( 2, 4 )
+
+TRINITY_BASE_DIR = ""
+if os.environ.has_key('TRINITY_HOME'):
+    TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
+else:
+    sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
+    sys.exit()
+
+
+
+# get bindir
+bindir = sys.argv[0]
+bindir = bindir.split("/")
+if len(bindir) > 1:
+    bindir.pop()
+    bindir = "/".join(bindir)
+else:
+    bindir = "."
+
+
+## add locations of tools to path setting.
+TOOL_PATHS_FILE = bindir + "/__add_to_PATH_setting.txt";
+for line in open(TOOL_PATHS_FILE):
+    line = line.rstrip()
+    os.environ['PATH'] += ":" + line
+
+
+def stop_err( msg ):
+    sys.stderr.write( "%s\n" % msg )
+    sys.exit()
+
+def __main__():
+    # Get command-line arguments
+    args = sys.argv
+    # Remove name of calling program, i.e. ./stderr_wrapper.py
+    args.pop(0)
+    # If there are no arguments left, we're done
+    if len(args) == 0:
+        return
+
+    # If one needs to silence stdout 
+    #args.append( ">" )
+    #args.append( "/dev/null" )
+
+    args[0] = "".join([TRINITY_BASE_DIR, '/', args[0]]);
+
+    cmdline = " ".join(args)
+
+    
+
+    try:
+        # Run program
+        err_capture = open("stderr.txt", 'w')
+        proc = subprocess.Popen( args=cmdline, shell=True, stderr=err_capture, stdout=sys.stdout )
+        returncode = proc.wait()
+        err_capture.close()
+
+        
+        if returncode != 0:
+            raise Exception
+
+    except Exception:
+        # Running Grinder failed: write error message to stderr
+        err_text = open("stderr.txt").readlines()
+        stop_err( "ERROR:\n" + "\n".join(err_text))
+
+
+if __name__ == "__main__": __main__()