changeset 8:b0d11fcbc3ac

cummerbund add MDS and PCA plots, handle errors from R
author Jim Johnson <jj@umn.edu>
date Thu, 11 Oct 2012 15:14:51 -0500
parents c2b922c9d545
children b6427cdbf6d4
files cummerbund_wrapper.py cummerbund_wrapper.xml
diffstat 2 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/cummerbund_wrapper.py	Wed Oct 10 11:09:15 2012 -0500
+++ b/cummerbund_wrapper.py	Thu Oct 11 15:14:51 2012 -0500
@@ -8,13 +8,13 @@
 
 def stop_err( msg ):
     sys.stderr.write( "%s\n" % msg )
-    sys.exit()
+    sys.exit(1)
 
 def html_report_from_directory( html_out, dir ):
     html_out.write( '<html>\n<head>\n<title>Galaxy - cummeRbund Output</title>\n</head>\n<body>\n<p/>\n<ul>\n' )
     for fname in sorted( os.listdir( dir ) ):
         # html_out.write(  '<li><a href="%s">%s</a></li>\n' % ( fname, fname ) )
-        html_out.write(  '<li><a href="%s"><img src="%s" alt="" height="42" width="42">%s</a></li>\n' % ( fname, fname , fname ) )
+        html_out.write(  '<li><a href="%s"><img src="%s" alt="" height="80" width="80">%s</a></li>\n' % ( fname, fname , fname ) )
     html_out.write( '</ul>\n</body>\n</html>\n' )
 
 def __main__():
@@ -39,7 +39,7 @@
     cmd = ( "Rscript --vanilla %s" % options.r_script )
     
     # Debugging.
-    print cmd
+    # print cmd
 
 #liubo added, for test, look at the generated R script
 #    shutil.copy2(options.r_script, '/nfs/software/galaxy/r_script')
--- a/cummerbund_wrapper.xml	Wed Oct 10 11:09:15 2012 -0500
+++ b/cummerbund_wrapper.xml	Thu Oct 11 15:14:51 2012 -0500
@@ -48,11 +48,19 @@
 					<option value="cluster">Cluster</option>
 					<option value="expressionplot">Expression Plot</option>
 					<option value="expressionbarplot">Expression Bar Plot</option>
+					<option value="mds">MultiDimentional Scaling (MDS) Plot</option>
+					<option value="pca">Principal Component Analysis (PCA) Plot</option>
 				</param>
 				<when value="density">
 					<param name="log_mode" type="boolean" truevalue="T" falsevalue="F" checked="True" label="Apply log10 transformation on FPKM values?"/>
 					<param name="replicates" type="boolean" truevalue="T" falsevalue="F" checked="False" label="Replicates?"/>
 				</when>
+				<when value="mds">
+					<param name="replicates" type="boolean" truevalue="T" falsevalue="F" checked="True" label="Replicates?"/>
+				</when>
+				<when value="pca">
+					<param name="replicates" type="boolean" truevalue="T" falsevalue="F" checked="True" label="Replicates?"/>
+				</when>
 				<when value="dispersion">
 				</when>
 				<when value="fpkmSCV">
@@ -163,7 +171,9 @@
 			</conditional>
 		</repeat>
     </inputs>
-    
+    <stdio>
+        <exit_code range="1:"  level="fatal"   description="CummerBund Error" />
+    </stdio>
     <outputs>
         <data format="data" name="output_database" label="${tool.name} on ${on_string}: Database File (sqlite)">
             <filter>backend_database_source['backend_database_selector'] == "cuffdiff_output"</filter>
@@ -227,31 +237,26 @@
 #for $i, $p in enumerate($plots, start=1):
 	#set $filename = "plot%02d-%s.png" % ($i, $p.plot['type'])
 png(filename = "${filename}", width = ${p.width}, height = ${p.height})
-
+tryCatch({
     ## Density plot ##
 	#if $p.plot['type'] == "density":
 csDensity(genes(cuff),replicates=$p.plot.replicates)
-devname = dev.off()
 
     ## Dispersion plot ##
 	#elif $p.plot['type'] == "dispersion":
 dispersionPlot(genes(cuff))
-devname = dev.off()
 
     ## Squared Coefficient of Variation plot ##
 	#elif $p.plot['type'] == "fpkmSCV":
 fpkmSCVPlot(genes(cuff))
-devname = dev.off()
 
     ## Scatter Matrix ##
 	#elif $p.plot['type'] == "scatterMatrix":
 csScatterMatrix(genes(cuff))
-devname = dev.off()
 
     ## Boxplot ##
 	#elif $p.plot['type'] == "boxplot":
 csBoxplot(genes(cuff))
-devname = dev.off()
 
     ## Scatter ##
 	#elif $p.plot['type'] == "scatter":
@@ -265,7 +270,6 @@
         #else
 csScatter(genes(cuff), "${p.plot.x}", "${p.plot.y}", smooth=${p.plot.smooth})
         #end if
-devname = dev.off()
 
     ## Volcano ##
 	#elif $p.plot['type'] == "volcano":
@@ -279,7 +283,6 @@
         #else
 csVolcano(genes(cuff), "${p.plot.x}", "${p.plot.y}")
         #end if
-devname = dev.off()
 
     ## Heatmap ##
 	#elif $p.plot['type'] == "heatmap":
@@ -289,7 +292,6 @@
 		#end for
 myGenes &lt;- getGenes(cuff, myGeneIds)
 csHeatmap(get_features(myGenes, "${p.plot.features}"), clustering="${p.plot.clustering}", labCol="${p.plot.labcol}", labRow="${p.plot.labrow}", border="${p.plot.border}")
-devname = dev.off()
 
     ## Cluster ##
 	#elif $p.plot['type'] == "cluster":
@@ -299,22 +301,30 @@
 		#end for
 myGenes &lt;- getGenes(cuff, myGeneIds)
 csCluster(get_features(myGenes, "${p.plot.features}"), k=${p.plot.k}, iter.max="${p.plot.iter_max}")
-devname = dev.off()
 
     ## Expression Plot ##
 	#elif $p.plot['type'] == "expressionplot":
 myGeneId &lt;- "$p.plot.gene_id"
 myGenes &lt;- getGenes(cuff, myGeneId)
 expressionPlot(get_features(myGenes, "${p.plot.features}"), drawSummary=${p.plot.draw_summary}, iter.max="${p.plot.show_error_bars}")
-devname = dev.off()
 
     ## Expression Bar Plot ##
 	#elif $p.plot['type'] == "expressionbarplot":
 myGeneId &lt;- "$p.plot.gene_id"
 myGenes &lt;- getGenes(cuff, myGeneId)
 expressionBarplot(get_features(myGenes, "${p.plot.features}"), iter.max="${p.plot.show_error_bars}")
+
+    ## MDS plot ##
+	#elif $p.plot['type'] == "mds":
+MDSplot(genes(cuff),replicates=$p.plot.replicates)
+
+    ## PCA plot ##
+	#elif $p.plot['type'] == "pca":
+PCAplot(genes(cuff),"PC1","PC2",replicates=$p.plot.replicates)
+	#end if
+
+},error = function(e) {paste("$p.plot['type'] failed: ", e)})
 devname = dev.off()
-	#end if
 
 #end for
         </configfile>