comparison w4mcorcov_util.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 ddcc33ff3205
comparison
equal deleted inserted replaced
4:8bba31f628da 5:50f60f94c034
19 } 19 }
20 ) 20 )
21 return (retval) 21 return (retval)
22 } 22 }
23 23
24 # turn off all plotting devices
25 dev.off.all <- function() {
26 while (!is.null(dev.list())) { dev.off() }
27 }
28
29 # capture plot and write to PDF; then close any devices opened in the process
30 plot2pdf <- function(
31 file.name
32 , plot.function
33 , width = 12
34 , height = 12
35 ) {
36 # capture plot and write to PDF
37 cur.dev <- dev.list()
38 filename <- file.name
39 pdf(file = filename, width = width, height = height)
40 plot.function()
41 # close any devices opened in the process
42 dev.off()
43 if (is.null(cur.dev)) {
44 dev.off.all()
45 } else {
46 while ( length(dev.list()) > length(cur.dev) ) { dev.off() }
47 }
48 }
49 24
50 # print and capture plot and write to PDF; then close any devices opened in the process 25 # # pseudo-inverse - computational inverse of non-square matrix a
51 # This is needed for ggplot which does not print the plot when invoked within a function.
52 print2pdf <- function(
53 file.name
54 , plot.function
55 , width = 12
56 , height = 12
57 ) {
58 plot2pdf(
59 file.name = file.name
60 , width = width
61 , height = height
62 , plot.function = function() {
63 print(plot.function())
64 }
65 )
66 }
67
68 iso8601.znow <- function()
69 {
70 strftime(as.POSIXlt(Sys.time(), "UTC"), "%Y-%m-%dT%H:%M:%SZ")
71 }
72
73 # pdf.name <- function(name)
74 # {
75 # paste0(name, "_", iso8601.filename.fragment(), ".pdf")
76 # }
77 #
78 # tsv.name <- function(name)
79 # {
80 # paste0(name, "_", iso8601.filename.fragment(), ".tsv")
81 # }
82 #
83 # # pseudo-inverse - computational inverse non-square matrix a
84 # p.i <- function(a) { 26 # p.i <- function(a) {
85 # solve(t(a) %*% a) %*% t(a) 27 # solve(t(a) %*% a) %*% t(a)
86 # } 28 # }
87 29
88 30