-
Notifications
You must be signed in to change notification settings - Fork 2
/
levelplot.r
69 lines (60 loc) · 1.64 KB
/
levelplot.r
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# John M. Gaspar (jsh58@wildcats.unh.edu)
# June 2013
# This script will allow one to visualize the
# denoising "misses" from FlowClus using
# the lattice function "levelplot".
# output from FlowClus (-d option)
file <- "misses.csv"
library(lattice)
# load data
rep <- read.csv(file, header = FALSE)
repm <- data.matrix(rep)
# trim matrix
for (i in length(repm[1,]):1) {
if (any(repm[,i] != 0) || any(repm[i,] != 0))
break
}
# round up to nearest integer
while (i %% 100 != 0 && i < length(repm[1,])) {
i <- i + 1
}
repm <- repm[1:i,1:i]
# create level boundaries -- based on max value
div <- 8 # number of boundaries
z <- max(repm)
reg <- c(-0.1, 0.1)
for (j in 1:(div - 1)) {
reg <- c(reg, z^(j/div)) # logarithmic: <div> powers
}
reg <- c(reg, z + 0.1)
# make arrays for plotting
int <- seq(from = 0, to = i, by = 100)
f <- log(reg[3], base = div)
lab <- seq(from = 0, to = f * (length(reg) - 1), by = f)
color <- RColorBrewer::brewer.pal(length(reg) - 1, "Blues")
# make levelplot
lp <- levelplot(repm,
main = "Denoising misses",
xlab = "Reference (cluster/node) flow value",
ylab = "Query (read) flow value",
scales = list(
x = list(labels = int / 100, at = int, limits = c(0, i)),
y = list(labels = int / 100, at = int, limits = c(0, i)),
tck = c(1, 0)
),
at = reg,
col.regions = color,
colorkey = list(
col = color,
labels = list(
labels = c(0, 1, round(reg[3:length(reg)])),
at = lab
),
at = lab
),
)
plot(lp)
# to print to a file
#jpeg("misses.jpg")
#plot(lp)
#dev.off()