-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminet.R
101 lines (69 loc) · 2.52 KB
/
minet.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
library("minet")
library("Rgraphviz")
library("RCytoscape")
setwd ("/home/ben/workspace/timeCourse/data")
source("../code/R/tools.R")
library("igraph")
library("graph")
counts<-read.csv("networkCandidateGeneReads.csv",row.names=1,header=TRUE)
candidates<-read.csv("../results/tripleDE.csv",row.names=1,header=TRUE)
candidates<-rownames(candidates)
candidates
medians<-getMedians(counts[candidates,],24,120,condition="psa")
dim(medians)
psaMedians<-as.data.frame(t(medians))
psaMedians<-log(psaMedians+1)
psaMim<-build.mim(psaMedians, estimator = "spearman", disc = "none", nbins = sqrt(NROW(dataset)))
psaNet<-aracne(psaMim,eps=0)
psaNet[is.na(psaNet)] <- 0
psaNet
psaNet<-mrnet( psaMim)
am.graph<-new("graphAM", adjMat=psaNet, edgemode="undirected")
plot(am.graph, attrs = list(node = list(fillcolor = "lightblue"),edge = list(arrowsize=0.5)))
medians<-getMedians(candidates,24,120,condition="control")
controlMedians<-as.data.frame(t(medians))
controlMedians<-log(controlMedians+1)
mim<-build.mim(controlMedians, estimator = "spearman", disc = "none", nbins = sqrt(NROW(dataset)))
controlNet<-aracne(mim,eps=0)
controlNet[is.na(controlNet)] <- 0
am.graph<-new("graphAM", adjMat=controlNet[1800:2000,1800:2000], edgemode="undirected")
plot(am.graph, attrs = list(node = list(fillcolor = "lightblue"),edge = list(arrowsize=0.5)))
##subtract control from psa, see what changes.
net<-psaNet-controlNet
?pdf()
net[net < 0] <- 0
dim(psaNet)
am.graph<-new("graphAM", adjMat=net[1800:2000,1800:2000], edgemode="undirected")
am.matrix <- as(am.graph,"matrix")
am.nel <-as(am.graph,"graphNEL")
graph <- graph.adjacency(am.matrix, mode="undirected")
class(graph)
plot(am.graph, attrs = list(node = list(fillcolor = "lightblue"),edge = list(arrowsize=0.5)))
### export for cytoscape
am.matrix<-as(am.graph,"graphNEL")
am.matrix
To <- as(am.matrix,"matrix")
To
?write.graph
write.graph(am.matrix,"graph.gml","gml")
g2 <- igraph.from.graphNEL(am.matrix)
myAdjacencyMatrix <- matrix(runif(400),nc=20,nr=20)
myAdjacencyMatrix
g <- graph.adjacency(To,weighted=TRUE)
df <- get.data.frame(g)
head(df)
write.table(df,"graph.gml")
plot( as(net[1:100,1:100] ,"graphNEL") )
colnames(net)
class(net)
net <- minet(rawCounts, method = "mrnet", estimator = "mi.empirical", disc = "equalwidth", nbins = sqrt(nrow(rawCounts)))
net[1:10,1:10]
net[1:100,1:100]
am.graph
head(candidates)
head(thing)
rownames(medians)
cor(medians[,2:5])
plot(as(net ,"graphNEL"))
poi <- read.csv( "deResults/psa/psaDown1.5-12.csv", header=TRUE, row.names=1,stringsAsFactors = FALSE )
rownames(poi)