-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhiton.R
58 lines (53 loc) · 1.31 KB
/
hiton.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
new_hiton = function(data, target, max_k = 1 , alpha = 0.05){
cutoff <- qnorm(1 - alpha/2)
n <- nrow(data)
genes = setdiff(colnames(data), target)
y = data[,target]
dm = data[,genes]
data = cbind(y,dm)
colnames(data)[1] = target
C = cor(data)
order_genes = sort(abs(sapply(genes,ind_test,target,NULL,C,n)), decreasing = TRUE)
open = names(order_genes)[order_genes > cutoff]
pc = c()
while (length(open) > 0){
pc = c(pc, open[1])
l = 1
con_set = NULL
while (l <= max_k){
con_set = nextSet(setdiff(pc, open[1]),con_set,l)
if ( is.null(con_set) ){
l = l+1
}
else{
if ( abs(ind_test(open[1], target, con_set, C, n)) <= cutoff ){
pc = setdiff(pc, open[1])
break
}
}
}
open = setdiff(open, open[1])
print(c(length(open),length(pc)))
}
for ( x in pc ){
l = 1
con_set = NULL
print(c(x,length(pc)))
while (l <= max_k){
if ((which(pc == x))<length(pc)){
con_set = nextSet(pc[(which(pc == x)+1):length(pc)],con_set,l)
}
if ( is.null(con_set) ){
l = l+1
}
else{
if ( abs(ind_test(x, target, con_set, C, n)) <= cutoff){
pc = setdiff(pc, x)
print(c('remove',x))
break
}
}
}
}
pc
}