File: InternalCalibration_Models.R

package info (click to toggle)
openms 2.6.0%2Bcleaned1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 783,168 kB
  • sloc: cpp: 526,888; xml: 142,287; ansic: 54,252; python: 11,640; php: 2,454; sh: 1,137; ruby: 529; yacc: 403; perl: 85; lex: 74; makefile: 60
file content (40 lines) | stat: -rw-r--r-- 1,250 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library("ggplot2")
library("reshape2")

file.table.in = commandArgs(TRUE)[1] ## file.table.in = "models.csv"
file.plot.out = commandArgs(TRUE)[2] ## file.plot.out = "output.png"

cat(paste0("Reading file '", file.table.in, "' to plot model parameters ..."))

d = read.csv(file.table.in, check.names = FALSE, comment.char = "#", strip.white = TRUE)
model_count = sum(d$source == "local")

dm = melt(d, id.vars = c("RT", "source"))
head(dm)

## for linear models: remove 'power' graph (it's all 0)
if (all(dm$value[grep("power", dm$variable)] == 0, na.rm=TRUE))
{
  dm = dm[grep("power", dm$variable, invert=TRUE), ]
}

#options(device = "pdf")
#dev.new(filename = file.plot.out, file = file.plot.out)
png(filename = file.plot.out, width=1920)
if (model_count == 0)
{
  plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
  text(0.5,0.5,"Model fitting failed!\nCheck your tool parameters and/or data!")
} else {
  pl = ggplot(dm) + 
        geom_point(aes(x=RT, y=value, col=source)) +
        ggtitle(paste("Model coefficients over time\n", model_count, "model(s)", collapse="")) +
        xlab("RT [sec]") +
        ylab("model coefficient") +
        facet_grid(  variable ~ ., scales="free_y")
  print(pl)
}

dev.off()