-
Notifications
You must be signed in to change notification settings - Fork 0
/
DCGL.R
113 lines (88 loc) · 2.84 KB
/
DCGL.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
library(DCGL)
load('data/express_data_order.rdata')
D1 <- varianceBasedfilter(express_data_order, 0.05)
exprs_ga <- D1[, 1:228]
exprs_gyh <- D1[, 229: 396]
system.time({
DCp.res <- DCp(exprs_ga, exprs_gyh,
r.method = c("pearson", "spearman")[1],
link.method = c("qth", "rth", "percent")[1],
cutoff = 0.25,
N=100,
N.type = c("pooled", "gene_by_gene")[1],
q.method = c("BH", "holm", "hochberg", "hommel", "bonferroni","BY", "fdr")[1])
})
DCe.res <- DCe(exprs_ga, exprs_gyh,
link.method = c("qth", "rth", "percent")[1],
cutoff = 0.25,
r.method = c("pearson", "spearman")[1],
q.method = c("BH", "holm", "hochberg", "hommel","bonferroni", "BY", "fdr")[1],
nbins = 20, p = 0.1)
DCe.res$DCGs %>% View
DCe.res$DCGs[1:3, ]
save.image('./data/data.rdata')
DCsum.res <- DCsum(DCp.res, DCe.res,
DCpcutoff = 0.1,
DCecutoff = 0.1)
DCsum.res$DCGs %>% nrow
DCsum.res$DCLs %>% View
data(tf2target)
dcg <- DCsum.res$DCGs
dc_link <- DCsum.res$DCLs
dc_link1 <- dc_link %>% filter(cor.diff>0.5)
nrow(dc_link1)
median(dc_link$cor.diff)
# Get the gene names that are mapped to an entrez gene identifier----
library(org.Hs.eg.db)
x <- org.Hs.egSYMBOL
# Get the gene symbol that are mapped to an entrez gene identifiers
mapped_genes <- mappedkeys(x)
# Convert to a list
xx <- as.list(x[mapped_genes])
entrez_symbol <- do.call('rbind', xx) %>% as.data.frame()
entrez_symbol[, 2] <- rownames(entrez_symbol)
entrez <- data.frame(dcg$DCG, stringsAsFactors = F)
class(entrez$DCG) <- 'character'
colnames(entrez) <- 'DCG'
aa <- entrez %>%
left_join(entrez_symbol, by = c('DCG' = 'V2'))
View(aa)
class(entrez$DCG)
na.omit(aa) %>% nrow
gene1 <- unique(c(unique_link$gene1,unique_link$gene2))
length(gene1)
save.image('./data/data.rdata')
link <- dc_link[, c(1,2, 6)]
colnames(link) <- c('gene1', 'gene2', 'cor')
sapply(1:3, function(ii){
link[,ii] <<- as.character(link[, ii])
})
library(igraph)
library(reshape2)
g <- graph.data.frame(link, directed = F)
adjacency <- get.adjacency(g, type = 'both')
dd <- graph.adjacency()
aa <- fastgreedy.community(gg)
walk <- walktrap.community(gg)
graph.attributes(graph)
library(MCL)
bb <- as.matrix(adjacency)
as.numeric()
str(adjacency)
cc <- mcl(bb, addLoops = F, allow1 = T)
llply(1: nrow(link), .progress = 'text', function(ii){
bb[link[ii,1], link[ii,2]] <<- bb[link[ii,2], link[ii,1]] <<- link[ii,3]
})
nrow(link)
save(bb, file = 'bb.rdata')
cc <- mcl(bb, addLoops = F, allow1 = T)
class(bb)
gc()
class(bb[,1])
dd <- as.data.frame(bb)
llply(1:nrow(bb), .progress = 'text', function(ii){
dd[, ii] <<- as.numeric(dd[,ii])
1
})
dd <- as.matrix(dd)
cc <- mcl(dd, addLoops = F, allow1 = T)