Mercurial > repos > mingchen0919 > aurora_demo_site
changeset 1:5808dc52afe8 draft default tip
demo
author | mingchen0919 |
---|---|
date | Mon, 12 Mar 2018 11:49:18 -0400 |
parents | dd498df3f006 |
children | |
files | aurora_demo_site.xml aurora_demo_site_1_python.Rmd aurora_demo_site_2_bash.Rmd aurora_demo_site_3_r.Rmd aurora_demo_site_bash.Rmd aurora_demo_site_python.Rmd aurora_demo_site_r.Rmd aurora_demo_site_render.R aurora_demo_site_site.yml |
diffstat | 9 files changed, 73 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/aurora_demo_site.xml Mon Mar 12 10:02:53 2018 -0400 +++ b/aurora_demo_site.xml Mon Mar 12 11:49:18 2018 -0400 @@ -12,12 +12,13 @@ <regex match="XXX" source="stderr" level="warning" description="Check the warnings_and_errors.txt file for more details."/> </stdio> - <command><![CDATA[Rscript '${__tool_directory__}/aurora_demo_render.R' + <command><![CDATA[Rscript '${__tool_directory__}/aurora_demo_site_render.R' -r $row_number -c $column_number -R $report + -d $report.files_path -O $heatmap_data -T '${__tool_directory__}']]></command>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aurora_demo_site_1_python.Rmd Mon Mar 12 11:49:18 2018 -0400 @@ -0,0 +1,24 @@ +--- +title: 'Python script' +output: html_document +--- + +```{r setup, include=FALSE, warning=FALSE, message=FALSE} +knitr::opts_chunk$set( + echo = TRUE, + error = TRUE +) +``` + +We first use Python code to generate a random data matrix and save the data into an output file. + +```{python} +import numpy as np +import os + +n_row = int(os.environ['X_r']) +n_col = int(os.environ['X_c']) +heatmap_data = np.power(10, np.random.randn(n_row, n_col)) +np.savetxt(os.environ['X_O'], heatmap_data) +print(heatmap_data) +```
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aurora_demo_site_2_bash.Rmd Mon Mar 12 11:49:18 2018 -0400 @@ -0,0 +1,18 @@ +--- +title: 'Bash script' +output: html_document +--- + +```{r setup, include=FALSE, warning=FALSE, message=FALSE} +knitr::opts_chunk$set( + echo = TRUE, + error = TRUE +) +``` + + +Then we use shell script to display the file content. + +```{bash} +awk '{print $1, $2}' ${X_O} +```
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aurora_demo_site_3_r.Rmd Mon Mar 12 11:49:18 2018 -0400 @@ -0,0 +1,20 @@ +--- +title: 'R script' +output: html_document +--- + +```{r setup, include=FALSE, warning=FALSE, message=FALSE} +knitr::opts_chunk$set( + echo = TRUE, + error = TRUE +) +``` + + +Finally, we use R script to import the data and generate a heatmap. + +```{r warning=FALSE, message=FALSE} +heatmap_data = read.table(opt$X_O, header = FALSE, stringsAsFactors = FALSE) +knitr::kable(heatmap_data) +pheatmap::pheatmap(heatmap_data, cluster_rows = FALSE, cluster_cols = FALSE) +```
--- a/aurora_demo_site_bash.Rmd Mon Mar 12 10:02:53 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ ---- -title: 'Bash script' -output: html_document ---- - -```{r setup, include=FALSE, warning=FALSE, message=FALSE} -knitr::opts_chunk$set( - echo = TRUE, - error = TRUE -) -``` - - -Then we use shell script to display the file content. - -```{bash} -awk '{print $1, $2}' ${X_O} -```
--- a/aurora_demo_site_python.Rmd Mon Mar 12 10:02:53 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ ---- -title: 'Python script' -output: html_document ---- - -```{r setup, include=FALSE, warning=FALSE, message=FALSE} -knitr::opts_chunk$set( - echo = TRUE, - error = TRUE -) -``` - -We first use Python code to generate a random data matrix and save the data into an output file. - -```{python} -import numpy as np -import os - -n_row = int(os.environ['X_r']) -n_col = int(os.environ['X_c']) -heatmap_data = np.power(10, np.random.randn(n_row, n_col)) -np.savetxt(os.environ['X_O'], heatmap_data) -print(heatmap_data) -```
--- a/aurora_demo_site_r.Rmd Mon Mar 12 10:02:53 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ ---- -title: 'R script' -output: html_document ---- - -```{r setup, include=FALSE, warning=FALSE, message=FALSE} -knitr::opts_chunk$set( - echo = TRUE, - error = TRUE -) -``` - - -Finally, we use R script to import the data and generate a heatmap. - -```{r warning=FALSE, message=FALSE} -heatmap_data = read.table(opt$X_O, header = FALSE, stringsAsFactors = FALSE) -knitr::kable(heatmap_data) -pheatmap::pheatmap(heatmap_data, cluster_rows = FALSE, cluster_cols = FALSE) -```
--- a/aurora_demo_site_render.R Mon Mar 12 10:02:53 2018 -0400 +++ b/aurora_demo_site_render.R Mon Mar 12 11:49:18 2018 -0400 @@ -8,25 +8,10 @@ #------------2. define environment variables----- spec_matrix = as.matrix( data.frame(stringsAsFactors=FALSE, - long_flags = c("X_r", "X_c", "X_R", "X_O", "X_T"), - short_flags = c("r", "c", "R", "O", "T"), - argument_mask_flags = c(1L, 1L, 1L, 1L, 1L), - data_type_flags = c("integer", "integer", "character", "character", "character") - ) -) -opt = getopt(spec_matrix) -do.call(Sys.setenv, opt[-1]) -#------------------------------------------------ - - -#------------1. collect input values in R-------- -#------------2. define environment variables----- -spec_matrix = as.matrix( - data.frame(stringsAsFactors=FALSE, - long_flags = c("X_r", "X_c", "X_R", "X_O", "X_T"), - short_flags = c("r", "c", "R", "O", "T"), - argument_mask_flags = c(1L, 1L, 1L, 1L, 1L), - data_type_flags = c("integer", "integer", "character", "character", "character") + long_flags = c("X_r", "X_c", "X_R", "X_d", "X_O", "X_T"), + short_flags = c("r", "c", "R", "d", "O", "T"), + argument_mask_flags = c(1L, 1L, 1L, 1L, 1L, 1L), + data_type_flags = c("integer", "integer", "character", "character", "character", "character") ) ) opt = getopt(spec_matrix) @@ -38,8 +23,8 @@ # OUTPUT_DIR: path to the output associated directory, which stores all outputs # TOOL_DIR: path to the tool installation directory OUTPUT_DIR = opt$X_d -TOOL_DIR = opt$X_t -OUTPUT_REPORT = opt$X_o +TOOL_DIR = opt$X_T +OUTPUT_REPORT = opt$X_R # create the output associated directory to store all outputs
--- a/aurora_demo_site_site.yml Mon Mar 12 10:02:53 2018 -0400 +++ b/aurora_demo_site_site.yml Mon Mar 12 11:49:18 2018 -0400 @@ -8,11 +8,11 @@ icon: fa-home href: index.html - text: "Python" - href: aurora_demo_site_python.html + href: aurora_demo_site_1_python.html - text: "Bash" - href: aurora_demo_site_bash.html + href: aurora_demo_site_2_bash.html - text: "R" - href: aurora_demo_site_r.html + href: aurora_demo_site_3_r.html output: html_document: theme: cosmo