comparison rgToolFactory.xml @ 10:59bce2efadfe draft

Uploaded
author fubar
date Thu, 20 Mar 2014 05:03:17 -0400
parents e4e097a41064
children e052aadae3e9
comparison
equal deleted inserted replaced
9:e4e097a41064 10:59bce2efadfe
193 193
194 # note this script takes NO input or output because it generates random data 194 # note this script takes NO input or output because it generates random data
195 for (i in 1:10) { 195 for (i in 1:10) {
196 foo = runif(100) 196 foo = runif(100)
197 bar = rnorm(100) 197 bar = rnorm(100)
198 bar = foo + 0.2*bar 198 bar = foo + 0.05*bar
199 pdf(paste('yet',i,"anotherplot.pdf",sep='_')) 199 pdf(paste('yet',i,"anotherplot.pdf",sep='_'))
200 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6) 200 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6)
201 dev.off() 201 dev.off()
202 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100)) 202 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
203 bar = as.matrix(foo) 203 bar = as.matrix(foo)
204 pdf(paste('yet',i,"anotherheatmap.pdf",sep='_')) 204 pdf(paste('yet',i,"anotherheatmap.pdf",sep='_'))
205 heatmap(bar,main='Random Heatmap') 205 heatmap(bar,main='Random Heatmap')
206 dev.off() 206 dev.off()
207 } 207 }
208 208
209 A slight variation taking an input tabular file from which we read the first number as nreps
210
211 # note this script takes a single parameter
212 # number of replicates
213 ourargs = commandArgs(TRUE)
214 infname = ourargs[1]
215 nreps = read.table(infname,head=F)
216 nreps = unlist(nreps)[1]
217 nreps = max(c(1,nreps))
218 nreps = min(c(20,nreps))
219 print(paste("Using nreps=",nreps))
220 for (i in 1:nreps) {
221 foo = runif(100)
222 bar = rnorm(100)
223 bar = foo + 0.2*bar
224 pdf(paste("yet",i,"anotherplot.pdf",sep="_"))
225 plot(foo,bar,main=paste("Foo by Bar plot ",i),col="maroon", pch=3,cex=0.6)
226 dev.off()
227 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
228 bar = as.matrix(foo)
229 pdf(paste("yet",i,"anotherheatmap.pdf",sep="_"))
230 heatmap(bar,main="Random Heatmap")
231 dev.off()
232 }
209 233
210 A Python example that reverses each row of a tabular file (you'll need to remove the leading spaces 234 A Python example that reverses each row of a tabular file (you'll need to remove the leading spaces
211 for this to work if cut and pasted into the script box):: 235 for this to work if cut and pasted into the script box)::
212 236
213 # reverse order of columns in a tabular file 237 # reverse order of columns in a tabular file