Mercurial > repos > eschen42 > w4mcorcov
comparison w4mcorcov_output.R @ 5:50f60f94c034 draft
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
author | eschen42 |
---|---|
date | Fri, 30 Mar 2018 14:59:19 -0400 |
parents | 23f9fad4edfc |
children |
comparison
equal
deleted
inserted
replaced
4:8bba31f628da | 5:50f60f94c034 |
---|---|
1 | |
2 # turn off all plotting devices | |
3 dev.off.all <- function() { | |
4 while (!is.null(dev.list())) { dev.off() } | |
5 } | |
6 | |
7 # capture plot and write to PDF; then close any devices opened in the process | |
8 plot2pdf <- function( | |
9 file.name | |
10 , plot.function | |
11 , width = 12 | |
12 , height = 12 | |
13 ) { | |
14 # capture plot and write to PDF | |
15 cur.dev <- dev.list() | |
16 filename <- file.name | |
17 pdf(file = filename, width = width, height = height) | |
18 plot.function() | |
19 # close any devices opened in the process | |
20 dev.off() | |
21 if (is.null(cur.dev)) { | |
22 dev.off.all() | |
23 } else { | |
24 while ( length(dev.list()) > length(cur.dev) ) { dev.off() } | |
25 } | |
26 } | |
27 | |
28 # print and capture plot and write to PDF; then close any devices opened in the process | |
29 # This is needed for ggplot which does not print the plot when invoked within a function. | |
30 print2pdf <- function( | |
31 file.name | |
32 , plot.function | |
33 , width = 12 | |
34 , height = 12 | |
35 ) { | |
36 plot2pdf( | |
37 file.name = file.name | |
38 , width = width | |
39 , height = height | |
40 , plot.function = function() { | |
41 print(plot.function()) | |
42 } | |
43 ) | |
44 } | |
45 | |
46 iso8601.znow <- function() | |
47 { | |
48 strftime(as.POSIXlt(Sys.time(), "UTC"), "%Y-%m-%dT%H:%M:%SZ") | |
49 } | |
50 | |
51 # pdf.name <- function(name) | |
52 # { | |
53 # paste0(name, "_", iso8601.filename.fragment(), ".pdf") | |
54 # } | |
55 # | |
56 # tsv.name <- function(name) | |
57 # { | |
58 # paste0(name, "_", iso8601.filename.fragment(), ".tsv") | |
59 # } | |
60 # | |
61 | |
62 tsv_action_factory <- function(file, colnames, append) { | |
63 return ( | |
64 function(tsv) { | |
65 write.table( | |
66 x = tsv | |
67 , file = file | |
68 , sep = "\t" | |
69 , quote = FALSE | |
70 , row.names = FALSE | |
71 , col.names = colnames | |
72 , append = append | |
73 ) | |
74 } | |
75 ) | |
76 } | |
77 |