Mercurial > repos > mingchen0919 > rmarkdown_samtools_flagstat
comparison rmarkdown_samtools_flagstat_render.R @ 4:ec39bfeaf496 draft
update
| author | mingchen0919 |
|---|---|
| date | Wed, 27 Dec 2017 15:14:47 -0500 |
| parents | a0f0effea707 |
| children | 1c16536c70f5 |
comparison
equal
deleted
inserted
replaced
| 3:106ab5f33970 | 4:ec39bfeaf496 |
|---|---|
| 1 library(getopt) | 1 library(getopt) |
| 2 library(rmarkdown) | 2 library(rmarkdown) |
| 3 library(htmltools) | 3 library(htmltools) |
| 4 library(dplyr) | 4 library(dplyr) |
| 5 library(stringr) | |
| 5 | 6 |
| 6 ##============ Sink warnings and errors to a file ============== | 7 ##============ Sink warnings and errors to a file ============== |
| 7 ## use the sink() function to wrap all code within it. | 8 ## use the sink() function to wrap all code within it. |
| 8 ##============================================================== | 9 ##============================================================== |
| 9 zz = file('warnings_and_errors.txt') | 10 zz = file('warnings_and_errors.txt') |
| 56 readLines(opt$tool_template_rmd) %>% | 57 readLines(opt$tool_template_rmd) %>% |
| 57 (function(x) { | 58 (function(x) { |
| 58 gsub('ECHO', opt$echo, x) | 59 gsub('ECHO', opt$echo, x) |
| 59 }) %>% | 60 }) %>% |
| 60 (function(x) { | 61 (function(x) { |
| 61 gsub('REPORT_DIR', opt$output_dir, x) | 62 gsub('REPORT_DIR', opt$report_dir, x) |
| 62 }) %>% | 63 }) %>% |
| 63 (function(x) { | 64 (function(x) { |
| 64 fileConn = file('tool_template.Rmd') | 65 fileConn = file('rmarkdown_samtools_flagstat.Rmd') |
| 65 writeLines(x, con=fileConn) | 66 writeLines(x, con=fileConn) |
| 66 close(fileConn) | 67 close(fileConn) |
| 67 }) | 68 }) |
| 68 | 69 |
| 69 | 70 |
| 70 ##=============STEP 4: render .Rmd templates================= | 71 ##=============STEP 4: render .Rmd templates================= |
| 71 ## | 72 ## |
| 72 ##=========================================================== | 73 ##=========================================================== |
| 73 render('tool_template.Rmd', output_file = opt$report_html) | 74 render('rmarkdown_samtools_flagstat.Rmd', output_file = opt$report_html) |
| 74 | 75 |
| 75 | 76 |
| 76 ##--------end of code rendering .Rmd templates---------------- | 77 ##--------end of code rendering .Rmd templates---------------- |
| 77 sink() | 78 sink() |
| 78 ##=========== End of sinking output============================= | 79 ##=========== End of sinking output============================= |
