Repository 'quantp'
hg clone https://toolshed.g2.bx.psu.edu/repos/galaxyp/quantp

Changeset 1:bcc7a4c4cc29 (2018-12-20)
Previous changeset 0:75faf9a89f5b (2018-09-14) Next changeset 2:ed0bb50d7ffe (2019-01-09)
Commit message:
planemo upload commit 1887dff812162880d66b003a927867cd5000c98f
modified:
quantp.r
quantp.xml
b
diff -r 75faf9a89f5b -r bcc7a4c4cc29 quantp.r
--- a/quantp.r Fri Sep 14 12:22:31 2018 -0400
+++ b/quantp.r Thu Dec 20 16:06:05 2018 -0500
[
b'@@ -16,6 +16,7 @@\n   png(outfile, width = 6, height = 6, units = \'in\', res=300);\n   # bitmap(outfile, "png16m");\n   g = autoplot(prcomp(select(tempdf, -Group)), data = tempdf, colour = \'Group\', size=3);\n+  saveWidget(ggplotly(g), file.path(gsub("\\\\.png", "\\\\.html", outplot)))\n   plot(g);\n   dev.off();\n }\n@@ -30,20 +31,20 @@\n   regmodel_summary = summary(regmodel);\n   \n   cat("<font><h3>Linear Regression model fit between Proteome and Transcriptome data</h3></font>\\n",\n-    "<p>Assuming a linear relationship between Proteome and Transcriptome data, we here fit a linear regression model.</p>\\n",\n-    \'<table  border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Value</font></th></tr>\\n\',\n-    file = htmloutfile, append = TRUE);\n+      "<p>Assuming a linear relationship between Proteome and Transcriptome data, we here fit a linear regression model.</p>\\n",\n+      \'<table  border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Value</font></th></tr>\\n\',\n+      file = htmloutfile, append = TRUE);\n   \n   cat("<tr><td>Formula</td><td>","PE_abundance~TE_abundance","</td></tr>\\n",\n-    "<tr><td colspan=\'2\' align=\'center\'> <b>Coefficients</b></td>","</tr>\\n",\n-    "<tr><td>",names(regmodel$coefficients[1]),"</td><td>",regmodel$coefficients[1]," (Pvalue:", regmodel_summary$coefficients[1,4],")","</td></tr>\\n",\n-    "<tr><td>",names(regmodel$coefficients[2]),"</td><td>",regmodel$coefficients[2]," (Pvalue:", regmodel_summary$coefficients[2,4],")","</td></tr>\\n",\n-    "<tr><td colspan=\'2\' align=\'center\'> <b>Model parameters</b></td>","</tr>\\n",\n-    "<tr><td>Residual standard error</td><td>",regmodel_summary$sigma," (",regmodel_summary$df[2]," degree of freedom)</td></tr>\\n",\n-    "<tr><td>F-statistic</td><td>",regmodel_summary$fstatistic[1]," ( on ",regmodel_summary$fstatistic[2]," and  ",regmodel_summary$fstatistic[3]," degree of freedom)</td></tr>\\n",\n-    "<tr><td>R-squared</td><td>",regmodel_summary$r.squared,"</td></tr>\\n",\n-    "<tr><td>Adjusted R-squared</td><td>",regmodel_summary$adj.r.squared,"</td></tr>\\n",\n-    file = htmloutfile, append = TRUE);\n+      "<tr><td colspan=\'2\' align=\'center\'> <b>Coefficients</b></td>","</tr>\\n",\n+      "<tr><td>",names(regmodel$coefficients[1]),"</td><td>",regmodel$coefficients[1]," (Pvalue:", regmodel_summary$coefficients[1,4],")","</td></tr>\\n",\n+      "<tr><td>",names(regmodel$coefficients[2]),"</td><td>",regmodel$coefficients[2]," (Pvalue:", regmodel_summary$coefficients[2,4],")","</td></tr>\\n",\n+      "<tr><td colspan=\'2\' align=\'center\'> <b>Model parameters</b></td>","</tr>\\n",\n+      "<tr><td>Residual standard error</td><td>",regmodel_summary$sigma," (",regmodel_summary$df[2]," degree of freedom)</td></tr>\\n",\n+      "<tr><td>F-statistic</td><td>",regmodel_summary$fstatistic[1]," ( on ",regmodel_summary$fstatistic[2]," and  ",regmodel_summary$fstatistic[3]," degree of freedom)</td></tr>\\n",\n+      "<tr><td>R-squared</td><td>",regmodel_summary$r.squared,"</td></tr>\\n",\n+      "<tr><td>Adjusted R-squared</td><td>",regmodel_summary$adj.r.squared,"</td></tr>\\n",\n+      file = htmloutfile, append = TRUE);\n   \n   cat("</table>\\n", file = htmloutfile, append = TRUE);\n   \n@@ -58,13 +59,27 @@\n   plot(regmodel, 1, cex.lab=1.5);\n   dev.off();\n   \n+  suppressWarnings(g <- autoplot(regmodel, label = FALSE)[[1]] +\n+                     geom_point(aes(text=sprintf("Residual: %.2f<br>Fitted value: %.2f<br>Gene: %s", .fitted, .resid, PE_TE_data$PE_ID)),\n+                                shape = 1, size = .1, stroke = .2) +\n+                     theme_light())\n+  saveWidget(ggplotly(g, tooltip= c("text")), file.path(gsub("\\\\.png", "\\\\.html", outplot)))\n+  \n   outplot = paste(outdir,"/PE_TE_lm_2.png",sep="",collapse="");\n   png(outplot,width = 10, height = 10, units = \'in\', res=300);\n   # bitmap(outplot, "png'..b'"#7a0019"><th><font color=#ffcc33>Scatter plot between Proteome and Transcriptome Abundance</font></th></tr>\\n\', file = htmloutfile, append = TRUE);\n-    cat("<tr><td align=center>", \'<img src="TE_PE_scatter.png" width=800 height=800></td>\\n\', file = htmloutfile, append = TRUE);\n-    PE_TE_data = data.frame(PE_df, TE_df);\n-    colnames(PE_TE_data) = c("PE_ID","PE_abundance","TE_ID","TE_abundance");\n     singlesample_scatter(PE_TE_data, outplot);  \n-\n+    lines <- extractWidgetCode(outplot);\n+    postscripts <- c(postscripts, lines$postscripts);  \n+    cat("<tr><td align=center>", \'<img src="TE_PE_scatter.png" width=800 height=800>\', gsub(\'width:500px;height:500px\', \'width:800px;height:800px\' , lines$widget_div),\n+        \'</td>\\n\', file = htmloutfile, append = TRUE);\n+    \n     # TE PE Cor\n     cat("<tr><td align=center>\\n", file = htmloutfile, append = TRUE);\n     singlesample_cor(PE_TE_data, htmloutfile, append=TRUE);\n     cat(\'<font color="red">*Note that <u>correlation</u> is <u>sensitive to outliers</u> in the data. So it is important to analyze outliers/influential observations in the data.<br> Below we use <u>Cook\\\'s distance based approach</u> to identify such influential observations.</font>\\n\',\n-      file = htmloutfile, append = TRUE);\n+        file = htmloutfile, append = TRUE);\n     cat(\'</td></table>\',\n-    file = htmloutfile, append = TRUE);\n+        file = htmloutfile, append = TRUE);\n     \n     cat(\'<hr/><h2 id="regression_data"><font color=#ff0000>REGRESSION ANALYSIS</font></h2>\\n\',\n-    file = htmloutfile, append = TRUE);\n+        file = htmloutfile, append = TRUE);\n     \n     # TE PE Regression\n     singlesample_regression(PE_TE_data,htmloutfile, append=TRUE);\n+    postscripts <- c(postscripts, c(extractWidgetCode(paste(outdir,"/PE_TE_lm_1.png",sep="",collapse=""))$postscripts,\n+                                    extractWidgetCode(paste(outdir,"/PE_TE_lm_2.png",sep="",collapse=""))$postscripts,\n+                                    extractWidgetCode(paste(outdir,"/PE_TE_lm_5.png",sep="",collapse=""))$postscripts,\n+                                    extractWidgetCode(paste(outdir,"/PE_TE_lm_cooksd.png",sep="",collapse=""))$postscripts,\n+                                    extractWidgetCode(paste(outdir,"/AbundancePlot_scatter_without_outliers.png",sep="",collapse=""))$postscripts,\n+                                    gsub(\'data-for="html\', \'data-for="secondhtml"\', \n+                                         extractWidgetCode(paste(outdir,"/TE_PE_scatter.png",sep="",collapse=""))$postscripts)));\n     \n     cat(\'<hr/><h2 id="cluster_data"><font color=#ff0000>CLUSTER ANALYSIS</font></h2>\\n\',\n-    file = htmloutfile, append = TRUE);\n+        file = htmloutfile, append = TRUE);\n     \n     #TE PE Heatmap\n     singlesample_heatmap(PE_TE_data, htmloutfile, hm_nclust);\n+    lines <- extractWidgetCode(paste(outdir,"/PE_TE_heatmap.png",sep="",collapse=""))\n+    postscripts <- c(postscripts, lines$postscripts)\n+    prescripts <- c(prescripts, lines$prescripts)\n     \n     #TE PE Clustering (kmeans)\n     singlesample_kmeans(PE_TE_data, htmloutfile, nclust=as.numeric(numCluster))\n-    \n+    postscripts <- c(postscripts, extractWidgetCode(paste(outdir,"/PE_TE_kmeans.png",sep="",collapse=""))$postscripts);\n   }\n }\n cat("<h3>Go To:</h3>\\n",\n@@ -1002,3 +1219,14 @@\n     "<br><a href=#>TOP</a>",\n     file = htmloutfile, append = TRUE);\n cat("</body></html>\\n", file = htmloutfile, append = TRUE);\n+\n+\n+#===============================================================================\n+# Add masked-javascripts tags to HTML file in the head and end\n+#===============================================================================\n+\n+htmllines <- readLines(htmloutfile)\n+htmllines[1] <- paste(\'<html>\\n<head>\\n\', paste(prescripts, collapse=\'\\n\'), \'\\n</head>\\n<body>\')\n+cat(paste(htmllines, collapse=\'\\n\'), file = htmloutfile)\n+cat(\'\\n\', paste(postscripts, collapse=\'\\n\'), "\\n",\n+    "</body>\\n</html>\\n", file = htmloutfile, append = TRUE);\n'
b
diff -r 75faf9a89f5b -r bcc7a4c4cc29 quantp.xml
--- a/quantp.xml Fri Sep 14 12:22:31 2018 -0400
+++ b/quantp.xml Thu Dec 20 16:06:05 2018 -0500
[
@@ -1,4 +1,4 @@
-<tool id="quantp" name="QuanTP" version="1.0.0">
+<tool id="quantp" name="QuanTP" version="1.1.0">
     <description>Correlation between protein and transcript abundances</description>
     <requirements>
         <requirement type="package" version="1.10.4">r-data.table</requirement>
@@ -6,6 +6,8 @@
         <requirement type="package" version="0.7.6">r-dplyr</requirement>
         <requirement type="package" version="3.0.0">r-ggplot2</requirement>
         <requirement type="package" version="0.4.5">r-ggfortify</requirement>
+        <requirement type="package" version="4.8.0">r-plotly</requirement>
+        <requirement type="package" version="0.6.1.2">r-d3heatmap</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
 Rscript '$__tool_directory__/quantp.r' 
@@ -108,6 +110,7 @@
             <output name="html_file">
                 <assert_contents>
                     <has_text text="SAMPLE DISTRIBUTION" />
+                    <has_text text="plotly" />
                 </assert_contents>
             </output>
         </test>