git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/rTRM@79428 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,13 +1,11 @@ |
1 | 1 |
Package: rTRM |
2 | 2 |
Type: Package |
3 |
-Title: Identification of transcriptional regulatory modules |
|
4 |
-Version: 0.9.7 |
|
5 |
-Date: 2013-06-16 |
|
3 |
+Title: Identification of transcriptional regulatory modules from PPI networks |
|
4 |
+Version: 0.99.0 |
|
5 |
+Date: 2013-07-25 |
|
6 | 6 |
Author: Diego Diez |
7 | 7 |
Depends: R (>= 2.10), igraph, RSQLite |
8 |
-Suggests: RUnit, BiocGenerics, MotifDb, graph, PWMEnrich, biomaRt, |
|
9 |
- knitr, Biostrings, BSgenome.Mmusculus.UCSC.mm8, org.Mm.eg.db, |
|
10 |
- AnnotationDbi, annotate |
|
8 |
+Suggests: RUnit, BiocGenerics, MotifDb, graph, PWMEnrich, biomaRt, knitr, Biostrings, BSgenome.Mmusculus.UCSC.mm8, org.Mm.eg.db, AnnotationDbi, annotate |
|
11 | 9 |
Maintainer: Diego Diez <[email protected]> |
12 | 10 |
Description: rTRM identifies transcriptional regulatory modules (TRMs) from protein-protein interaction networks. |
13 | 11 |
License: GPL-3 |
... | ... |
@@ -99,3 +99,62 @@ getConcentricList = function(g, t, e, max.size = 60, order.by = "label") { |
99 | 99 |
} |
100 | 100 |
res |
101 | 101 |
} |
102 |
+ |
|
103 |
+layout.arc = function (g, target, query) |
|
104 |
+{ |
|
105 |
+ n = vcount(g) |
|
106 |
+ if(! all(target %in% V(g)$name)) { |
|
107 |
+ warning("some targets not in graph, removing them.") |
|
108 |
+ target=target[target %in% V(g)$name] |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ # |
|
112 |
+ target = target[target %in% query] |
|
113 |
+ |
|
114 |
+ V(g)$type = "bridge" |
|
115 |
+ V(g)[name %in% query]$type = "query" |
|
116 |
+ V(g)[name %in% target]$type = "target" |
|
117 |
+ |
|
118 |
+ g_con = g |
|
119 |
+ n_left = character() |
|
120 |
+ |
|
121 |
+ if(! is.connected(g)) { |
|
122 |
+ g_con = getLargestComp(g) |
|
123 |
+ n_left = setdiff(V(g)$name,V(g_con)$name) |
|
124 |
+ } |
|
125 |
+ |
|
126 |
+ set = list(target = target, bridge=V(g_con)[type == "bridge"]$name, query1 = character(), query2 = character(), query3 = character(), left=n_left) |
|
127 |
+ for(q in V(g_con)[type == "query"]$name) { |
|
128 |
+ sp = get.all.shortest.paths(g_con,from=V(g_con)[q],to=V(g_con)[name %in% target]) |
|
129 |
+ print(sp) |
|
130 |
+ sp_min = min(sapply(sp$res,length)) |
|
131 |
+ print(sp_min) |
|
132 |
+ if(sp_min == 2) { |
|
133 |
+ set$query1 = c(set$query1, V(g_con)[q]$name) |
|
134 |
+ } |
|
135 |
+ else set$query2 = c(set$query2, V(g_con)[q]$name) |
|
136 |
+ } |
|
137 |
+ |
|
138 |
+ set = lapply(set,function(s) { |
|
139 |
+ ns = V(g)[s]$label |
|
140 |
+ s[order(ns,decreasing=TRUE)] |
|
141 |
+ }) |
|
142 |
+ |
|
143 |
+ x0 = c(left=-2,query1=-1,target=0,bridge=1,query2=2) |
|
144 |
+ y0 = sapply(set,function(x){ |
|
145 |
+ -1 * floor(length(x)/2) |
|
146 |
+ }) |
|
147 |
+ |
|
148 |
+ res = matrix(NA, nrow = n, ncol = 2) |
|
149 |
+ all_n = unlist(set) |
|
150 |
+ for(my_n in all_n) { |
|
151 |
+ k = which(V(g)$name == my_n) |
|
152 |
+ my_type = names(set)[sapply(set,function(x) my_n %in% x)] |
|
153 |
+ x1 = x0[my_type] |
|
154 |
+ y1 = y0[my_type] |
|
155 |
+ y0[my_type] = y0[my_type] + 1 |
|
156 |
+ res[k,1] = x1 |
|
157 |
+ res[k,2] = y1 |
|
158 |
+ } |
|
159 |
+ res |
|
160 |
+} |
|
102 | 161 |
\ No newline at end of file |
... | ... |
@@ -137,7 +137,7 @@ annotateTRM = function(g, target) { |
137 | 137 |
default |
138 | 138 |
} |
139 | 139 |
|
140 |
-plotTRM = function(g, layout = layout.fruchterman.reingold, mar = .5, vertex.col, vertex.cex, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.cex, label.col, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE) { |
|
140 |
+plotTRM = function(g, layout = layout.fruchterman.reingold, mar = .5, vertex.col, vertex.cex, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.cex, label.col, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE, normalizr.layout=TRUE) { |
|
141 | 141 |
|
142 | 142 |
if(class(layout) == "function") |
143 | 143 |
l = layout(g) |
... | ... |
@@ -145,7 +145,8 @@ plotTRM = function(g, layout = layout.fruchterman.reingold, mar = .5, vertex.col |
145 | 145 |
l = layout |
146 | 146 |
|
147 | 147 |
# normalize layout. |
148 |
- l = layout.norm(l, -1, 1, -1, 1) |
|
148 |
+ if(normalize.layout) |
|
149 |
+ l = layout.norm(l, -1, 1, -1, 1) |
|
149 | 150 |
|
150 | 151 |
vertex.col = .checkParam(vertex.col, V(g)$frame.color, "black", multi = vcount(g)) |
151 | 152 |
vertex.cex = .checkParam(vertex.cex, V(g)$size, 10, multi = vcount(g)) |
... | ... |
@@ -238,14 +239,15 @@ plotTRMlegend = function (x, title = NULL, cex = 1) |
238 | 239 |
symbols(xpos, ypos, circles = radius, inches = FALSE, add = TRUE, fg = frame.color, lwd = frame.width) |
239 | 240 |
} |
240 | 241 |
|
241 |
-plotGraph = function(g, layout = layout.fruchterman.reingold, mar = .5, vertex.pch = 21, vertex.cex, vertex.col, vertex.bg, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.col, label.cex, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE) { |
|
242 |
+plotGraph = function(g, layout = layout.fruchterman.reingold, mar = .5, vertex.pch = 21, vertex.cex, vertex.col, vertex.bg, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.col, label.cex, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE, normalize.layout=TRUE) { |
|
242 | 243 |
if(class(layout) == "function") |
243 | 244 |
l = layout(g) |
244 | 245 |
else |
245 | 246 |
l = layout |
246 | 247 |
|
247 | 248 |
# normalize layout. |
248 |
- l = layout.norm(l, -1, 1, -1, 1) |
|
249 |
+ if(normalize.layout) |
|
250 |
+ l = layout.norm(l, -1, 1, -1, 1) |
|
249 | 251 |
|
250 | 252 |
vertex.cex = .checkParam(vertex.cex, V(g)$size, 5) |
251 | 253 |
vertex.col = .checkParam(vertex.col, V(g)$frame.color, "grey") |
... | ... |
@@ -8,7 +8,7 @@ Plot an graph in igraph format. |
8 | 8 |
This function plots graphs of the class igraph. |
9 | 9 |
} |
10 | 10 |
\usage{ |
11 |
-plotGraph(g, layout = layout.fruchterman.reingold, mar = .5, vertex.pch = 21, vertex.cex, vertex.col, vertex.bg, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.col, label.cex, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE) |
|
11 |
+plotGraph(g, layout = layout.fruchterman.reingold, mar = .5, vertex.pch = 21, vertex.cex, vertex.col, vertex.bg, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.col, label.cex, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE, normalize.layout = TRUE) |
|
12 | 12 |
} |
13 | 13 |
%- maybe also 'usage' for other objects documented here. |
14 | 14 |
\arguments{ |
... | ... |
@@ -33,9 +33,8 @@ plotGraph(g, layout = layout.fruchterman.reingold, mar = .5, vertex.pch = 21, ve |
33 | 33 |
\item{label.offset}{label offset.} |
34 | 34 |
|
35 | 35 |
\item{adjust.label.col}{ |
36 |
-whether to automatically adjust label color depending on the luminance of the node's color/s. |
|
37 |
- |
|
38 |
-} |
|
36 |
+whether to automatically adjust label color depending on the luminance of the node's color/s.} |
|
37 |
+ \item{normalize.layout}{whether to apply layout.norm (with limits xmin=-1, xmax=1, ymin=-1, ymax=1) to the layout.} |
|
39 | 38 |
} |
40 | 39 |
|
41 | 40 |
\author{ |
... | ... |
@@ -8,7 +8,7 @@ Plot an annotated TRM. |
8 | 8 |
This function plots the output findTRM() after it has been annotated with cluster information with annotateTRM() function. Cluster membership is plotted using a pie plot. |
9 | 9 |
} |
10 | 10 |
\usage{ |
11 |
-plotTRM(g, layout = layout.fruchterman.reingold, mar = .5, vertex.col, vertex.cex, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.cex, label.col, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE) |
|
11 |
+plotTRM(g, layout = layout.fruchterman.reingold, mar = .5, vertex.col, vertex.cex, vertex.lwd, edge.col, edge.lwd, edge.lty, label = TRUE, label.cex, label.col, label.pos = NULL, label.offset = 1.5, adjust.label.col = FALSE, normalize.layout = TRUE) |
|
12 | 12 |
} |
13 | 13 |
%- maybe also 'usage' for other objects documented here. |
14 | 14 |
\arguments{ |
... | ... |
@@ -30,6 +30,7 @@ plotTRM(g, layout = layout.fruchterman.reingold, mar = .5, vertex.col, vertex.ce |
30 | 30 |
\item{label.pos}{label position.} |
31 | 31 |
\item{label.offset}{label offset.} |
32 | 32 |
\item{adjust.label.col}{whether to automatically adjust label color depending on the luminance of the node's color.} |
33 |
+ \item{normalize.layout}{whether to apply layout.norm (with limits xmin=-1, xmax=1, ymin=-1, ymax=1) to the layout.} |
|
33 | 34 |
} |
34 | 35 |
|
35 | 36 |
\author{ |
... | ... |
@@ -6,10 +6,7 @@ |
6 | 6 |
Identification transcription regulatory modules (TRMs) |
7 | 7 |
} |
8 | 8 |
\description{ |
9 |
- This package integrates transcription factor binding, enrichment analysis, |
|
10 |
- gene expression, functional information and protein-protein interaction |
|
11 |
- data, and identifies transcription factor modules (TFM) that regulate |
|
12 |
- cellular responses. |
|
9 |
+ This package identifies transcriptional regulatory modules (TRMs) from PPI networks. |
|
13 | 10 |
} |
14 | 11 |
\details{ |
15 | 12 |
\tabular{ll}{ |