-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetYeastData.R
53 lines (37 loc) · 1.25 KB
/
getYeastData.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
## taken from http://www.stat.ubc.ca/~jenny/webSupp/schluterGlobDisc/schluterEtAl.R
##library(qvalue)
## read in pre-processed data
tmp <- read.csv("schluterEtAlData.csv", header = T, as.is=1:2)
##read.table
caData <- tmp[,-(1:2)]
rownames(caData) <- tmp$ORF
(caData <- caData[1:5,])
## store ORF and ORF pair counts
(G <- nrow(caData)) # 279 ORFs
(GG <- G * (G - 1)/2) # 38781 ORF pairs
## compute euclidean distance and convert to ranks
(d1 <- dist(caData))
d2 <- d1
(d2[1:GG] <- rank(d1))
## what order is this in?
## does d2[1] give you the ranking of the A1 - A2 edge?
## Goal: write down the edge-names (i.e. node-pairs), so that we can use the code I've already written.
matrixMatch <- function (element,m){
index <- match(element,m) - 1
j <- floor(index/nrow(m))
i <- index%%nrow(m)
c(i+1,j+1)
}
##convert to Gustavo's format
convertToEdgeNameRanking <- function(distRanking){
enRanking <- c()
for (i in 1:length(distRanking)){
indexVec <- matrixMatch(i,as.matrix(distRanking))
##jCat("i = ", i, ", indexVec = ", indexVec)
enRanking[i] <- jPaste(tmp$ORF[indexVec[1]],"~",tmp$ORF[indexVec[2]])
}
enRanking
}
d2
convertToEdgeNameRanking(d2)
## test <- function(a,b) (a == b*floor(a/b) + a%%b)