-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
512 lines (512 loc) · 16.3 KB
/
.Rhistory
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
"Eigenvector centrality"="Eigenvector centrality\tevcent(igraph)$vector",
"Subgraph centrality"="Subgraph centrality\tsubgraph.centrality(igraph)"
)
eranking_methods <- c(
"Betweenness centrality"="Betweenness centrality\tedge.betweenness(igraph)"
)
ui_options <- c(
"ui_table_line_height" = "80%"
)
ui_css <- paste0('
.box-panel {
border-radius: 0 0 5px 5px;
border-width: 1px;
border-color: #d7d7d7;
border-style: none solid solid solid;
}
.box-panel-padding {
padding: 20px 20px 20px 20px;
}
.tabBox-panel {
padding: 20px 20px 20px 20px;
border-width: 1px;
border-color: #d7d7d7;
border-radius: 0px 0px 8px 8px;
border-style: none solid solid solid;
background: #ffffff;
}
.centerBlock {
float: none;
margin: 0 auto;
}
',".dataTables_wrapper td {
line-height: ",ui_options['ui_table_line_height'],";
}")
ui_dataTable_panel <- function(datasetName, pagination = TRUE){
return(parse(text=paste0("div(div(DT::dataTableOutput('",datasetName,"'), class='box-panel-padding'), class='box-panel')")))
}
fluidPage(useShinyjs(),
tags$head(tags$script(src="cyjs.js")),
navbarPage("The Network Analysis Provider (NAP)", header=tags$head(tags$style(type="text/css", ui_css)),
tabPanel("Welcome",
h2("Welcome to the Network Analysis Provider"),
strong("a mediator for shaking hands between graph theory and systems biology."),
br(),
br(),
helpText("Upload networks with up to 10,000 edges and perform analyses such as:"),
tags$ul(
tags$li("Exploring topological features"),
tags$li("Rank nodes/edges by properties"),
tags$li("Compare Networks to each other"),
tags$li("Use various layouts to see the network"),
tags$li("See whether a network follows a specific model distribution")
)
),
tabPanel("Upload File(s)", icon = icon("upload"),
sidebarLayout(
sidebarPanel(
bsAlert("tabUploadSideAlert"),
helpText("Please follow the steps below:"),
tags$ul(
tags$li("Load your network file in tab delimited format"),
tags$li("Choose the network type"),
tags$li("Give it a name"),
tags$li("Hit the ADD button")
),
selectInput("uiLoadGraphOptionsInput",
"Choose input method",
c("File upload"="oF", "Random scale-free network"="oRFS")
),
uiOutput("uiLoadGraphOptionsOutput"),
div( span( actionButton("btnAddNetwork", "ADD", icon = icon("plus")) ,class="input-group-btn"), tags$input(id="networkName", type="text", class="form-control", placeholder="Type network name ..",value="Network name"),class="input-group"),
uiOutput("uiStoredGraphsOutputRadio")
),
mainPanel(
conditionalPanel( condition = "input.availableNetworks == 0",
bsAlert("tabUploadMainAlert"),
uiOutput("uiStoredGraphsOutputSelectUpload"),
tabsetPanel(
tabPanel("Table View of Dataset(s)", icon = icon("table"),
eval(ui_dataTable_panel('datasettab1'))
),
tabPanel("Visualization",
div(div(
textOutput('info_vertices1'),
textOutput('info_edges1'),
#simpleNetworkOutput('tabVizIgraphForce'),
plotOutput('tabVizIgraphForce'),
class='box-panel-padding'
), class='box-panel')
)#,
#tabPanel("Vertices",
# div(
# textOutput('vertices1_label'),
# verbatimTextOutput('vertices1'),
# class='box-panel-padding')
#),
#tabPanel("Edges",
# div(
# textOutput('edges1_label') ,
# verbatimTextOutput('edges1'),
# class='box-panel-padding')
#)
)
)
) # mainPanel
) # sidebarLayout
), # tabPanel 'Upload File(s)'
tabPanel("Topology", icon = icon("globe", lib = "glyphicon"),
sidebarLayout(
sidebarPanel(
bsAlert("tabTopologySideAlert"),
conditionalPanel( condition = "input.statisticsMethodsMainTabsetPanel == 'tableView'",
uiOutput("uiStoredGraphsOutputSelectTopolopgy")
),
conditionalPanel( condition = "input.statisticsMethodsMainTabsetPanel == 'plotView'",
uiOutput("uiStoredGraphsOutputMultipleSelectTopolopgy")
),
helpText("Select the statistics you want in the analysis."),
checkboxGroupInput(
"statistics","The statistics:",
choices=statistics,
selected=selected_statistics
)
),
conditionalPanel( condition = "input.availableNetworks == 0",
mainPanel(
bsAlert("tabTopologyMainAlert"),
tabsetPanel(id = "statisticsMethodsMainTabsetPanel",
tabPanel("Statistic", value = "tableView", icon = icon("table"), eval(ui_dataTable_panel("statres", FALSE))),
tabPanel("The Plots", value = "plotView", icon = icon("bar-chart"),
div(div(
uiOutput("statisticsMethodsPlotRender"),
class='box-panel-padding'
), class='box-panel'),
sliderInput("statisticsPlotPercentMagnify", "Adjust plot height (% taller)", min=0, max=100, value=0)
)
)
)
)
)
),
tabPanel("Ranking", icon = icon("sort-amount-desc"),
sidebarLayout(
sidebarPanel(
bsAlert("tabRankingSideAlert"),
conditionalPanel( condition = "input.rankingMethodsMainTabsetPanel == 'tableView'",
uiOutput("uiStoredGraphsOutputSelectRanking"),
tabsetPanel(id = 'rankingTableViewTabsetPanel',
tabPanel("Node ranking", radioButtons( "vrankingTableView",label = "Method", choices=vranking_methods ), class='tabBox-panel'),
tabPanel("Edge ranking", radioButtons( "erankingTableView",label = "Method", choices=eranking_methods ), class='tabBox-panel')
)
),
conditionalPanel( condition = "input.rankingMethodsMainTabsetPanel == 'plotView'",
uiOutput("uiStoredGraphsOutputMultipleSelectRanking"),
tabsetPanel(id = 'rankingPlotViewTabsetPanel',
tabPanel("Node ranking", checkboxGroupInput( "vrankingPlotView", "Method", choices=vranking_methods ), class='tabBox-panel'),
tabPanel("Edge ranking", checkboxGroupInput( "erankingPlotView", "Method", choices=eranking_methods ), class='tabBox-panel')
)
)
),
conditionalPanel( condition = "input.availableNetworks == 0",
mainPanel(
bsAlert("tabRankingMainAlert"),
tabsetPanel(id = "rankingMethodsMainTabsetPanel",
tabPanel("Table View of Dataset(s)", value = "tableView", icon = icon("table"), eval(ui_dataTable_panel("rankeddatasettab1"))),
tabPanel("Plots", value = "plotView", icon = icon("bar-chart"),
conditionalPanel(condition = "(input.rankingPlotViewTabsetPanel == 'Node ranking' && input.vrankingPlotView.length == 1) || (input.rankingPlotViewTabsetPanel == 'Edge ranking' && input.erankingPlotView.length == 1)",
div(div(
plotOutput("rankingMethodsPowerLawScatter"),
# plotOutput("rankingMethodsScatterPlotRender"),
class='box-panel-padding'
), class='box-panel')
),
conditionalPanel(condition = "(input.rankingPlotViewTabsetPanel == 'Node ranking' && input.vrankingPlotView.length > 1) || (input.rankingPlotViewTabsetPanel == 'Edge ranking' && input.erankingPlotView.length > 1)",
div(div(
#plotlyOutput('rankingMethodsScatterPlot', height="auto"),
#plotOutput('rankingMethodsScatterPlot'),
uiOutput("rankingMethodsScatterPlotRender"),
class='box-panel-padding'
), class='box-panel'),
sliderInput("scatterPlotMatrixPercentMagnify", "Adjust plot height (% taller)", min=0, max=100, value=0)
)
)
)
)
)
)
),
tabPanel("Layouts", icon = icon("sitemap"),
sidebarLayout(
sidebarPanel(
bsAlert("tabLayoutsMainAlert"),
uiOutput("uiStoredGraphsOutputSelectLayouts"),
uiOutput('ui_combobox_layouts_netnames'),
selectInput(
'combobox_layouts',
'Choose the layout:',
choices=sort( c(
"Random"="random",
"Circle"="circle",
"Sphere"="sphere",
"Fruchterman-Reingold"="fruchterman",
"Kamada-Kawai"="kamada",
"Reingold-Tilford"="reingold",
"Grid"="grid",
"Lgl"="lgl",
"SVD"="svd")
),
selected="random"
),
helpText("Download the coordinates of the Selected Layout."),
downloadButton("dwnld_layout","Download"),
helpText("Download the projection graphs."),
downloadButton("dwnld_projections","Download")
),
conditionalPanel( condition = "input.availableNetworks == 0",
mainPanel(
tabsetPanel(
tabPanel("Plot of the Layout",
plotOutput("plot_layout")
)
)
)
)
)
),
tabPanel("Help", icon = icon("question"),
strong("Number of Edges"),
helpText("Shows the number of edges in the network. If the has more than 10000 edges it will take into account the first 10000"),
br(),
strong("Number of Nodes"),
helpText("Shows the number of noded in the network. There is no limitation on the nuber of nodes"),
br(),
strong("Diameter"),
helpText("Shows the length of the longest geodesic.The diameter is calculated by using a breadth-first search like method.The graph-theoretic or geodesic distance between two points is defined as the length of the shortest path between them."),
br(),
strong("Radius"),
helpText("The eccentricity of a vertex is its shortest path distance from the farthest other node in the graph. The smallest eccentricity in a graph is called its radius. The eccentricity of a vertex is calculated by measuring the shortest distance from (or to) the vertex, to (or from) all vertices in the graph, and taking the maximum."),
br(),
strong("Density"),
helpText("The density of a graph is the ratio of the number of edges and the number of possible edges"),
br(),
strong("Number of Edges"),
helpText("Shows the number of edges in the network. If the has more than 10000 edges it will take into account the first 10000"),
br(),
strong("Average path length"),
helpText("The average number of steps needed to go from a node to any other"),
br(),
strong("Clustering Coefficient:"),
helpText("A metric to show if the network has the tendency to form clusters"),
br(),
strong("Modularity"),
helpText("This function calculates how modular is a given division of a graph into subgraphs"),
br(),
strong("Number of self loops"),
helpText("how many nodes are connected to themselves"),
br(),
strong("Average Eccentricity:"),
helpText("The eccentricity of a vertex is its shortest path distance from the farthest other node in the graph."),
br(),
strong("Average Eigenvector Centrality:"),
helpText("It is a measure of the influence of a node in a network."),
br(),
strong("Assortativity degree:"),
helpText("The assortativity coefficient is positive is similar vertices (based on some external property) tend to connect to each, and negative otherwise."),
br(),
strong("Is directed acyclic graph"),
helpText("It returns True (1) or False (0)"),
br(),
strong("Is directed"),
helpText("It returns True (1) or False (0) depending whether the edges are directed or not"),
br(),
strong("Is Bipartite"),
helpText("It returns True (1) or False (0) depending whether the graph is bipartite or not"),
br(),
strong("Is chordal"),
helpText("It returns True (1) or False (0). A graph is chordal (or triangulated) if each of its cycles of four or more nodes has a chord, which is an edge joining two nodes that are not adjacent in the cycle. An equivalent definition is that any chordless cycles have at most three nodes."),
br(),
strong("Average number of Neighbors"),
helpText("How many neighbors each node of the network has on average"),
br(),
strong("Centralization betweenness"),
helpText("It is an indicator of a node's centrality in a network. It is equal to the number of shortest paths from all vertices to all others that pass through that node.Betweenness centrality quantifies the number of times a node acts as a bridge along the shortest path between two other nodes"),
br(),
strong("Centralization closeness"),
helpText("It measures the speed with which randomly walking messages reach a vertex from elsewhere in the graph"),
br(),
strong("Centralization degree"),
helpText("It is defined as the number of links incident upon a node"),
br(),
strong("Graph mincut"),
helpText("calculates the minimum st-cut between two vertices in a graph The minimum st-cut between source and target is the minimum total weight of edges needed to remove to eliminate all paths from source to target."),
br(),
br()
),
# tabPanel 'Layouts'
tabPanel("Input File",
strong("The input file can be a network in tab delimited format."),
br(),
helpText("Below you can see a network sample in tab delimited format:"),
pre("
A B
A C
A D
B C
C D
A E
A F"
),
helpText("Or:"),
pre("
A B 3
A C 3
A D 4
B C 1
C D 1
A E 4
A F 5
D D1 3
A1 B1 3
A1 C1 3
A1 D1 4
B1 C1 1
C1 D1 1
A1 E1 4
A1 F1 5"
)
),
tabPanel("People", icon = icon("users"),
strong("The Team:"),
tags$ul(
tags$li("Georgios Pavlopoulos - JGI, Berkeley Labs"),
tags$li("Theodosios Theodosiou - University of Crete"),
tags$li("Georgios Efstathiou - University of Crete"),
tags$li("Nikolas Papanikolaou - University of Crete"),
tags$li("Pantelis Bagos - University of Thessaly"),
tags$li("Nikos Kyrpides - JGI, Berkeley Labs"),
tags$li("Ioannis Iliopoulos - University of Crete")
),
br(),
strong("Development:"),
tags$ul(
tags$li("Georgios Pavlopoulos (g.pavlopoulos@lbl.gov)"),
tags$li("Theodosis Theodosiou (theodosios.theodosiou@gmail.com) "),
tags$li("Georgios Efstathiou (y.efstathiou@gmail.com ) ")
)
)
)
)
# By default, Shiny limits file uploads to 5MB per file.
# You can modify this limit by using the shiny.maxRequestSize option.
# For example, adding options(shiny.maxRequestSize=30*1024^2)
# to the top of server.R would increase the limit to 30MB.
# From within R, inside the app source dir, start the app with: shiny::runApp(getwd())
# From a shell, start the app with: R -e "shiny::runApp('~/appsourcedir')"
library(rcytoscapejs)
if(!require(shiny))install.packages('shiny')
runApp()
runApp()
install.packages("igraph")
shiny::runApp()
runApp()
runApp()
runApp()
runApp()
install.packages("shiny")
install.packages("shiny")
shiny::runApp()
runApp()
runApp()
shiny::runApp()
g = random.graph.game(500, p.or.m = 0.005, type = "gnp")
library('igraph')
g = random.graph.game(500, p.or.m = 0.005, type = "gnp")
plot(g, layout = layout.fruchterman.reingold, vertex.label= NA, edge.arrow.size=0.02,vertex.size = 0.5, xlab = "Random Network: G(N,p) model")
hist_g = hist(degree(g), main="random graph", col="Gray")
g1 = sample_smallworld(1,size=500,nei=4,p=0.03)
plot(g1, layout = layout.fruchterman.reingold, vertex.label= NA, edge.arrow.size=0.02,vertex.size = 0.5, xlab = "Random Network: G(N,p) model")
h1= sample_pa (500)
par(mfrow = c(1,1))
plot(h1, layout = layout.fruchterman.reingold, vertex.label= NA, edge.arrow.size=0.02,vertex.size = 0.5, xlab = "Random Network: G(N,p) model")
shiny::runApp()
shiny::runApp()
runApp()
runApp()
runApp()
runApp()
res<-data.frame(as.vector(eval(parse(text=command))))
ranking <- function(igraph, method, nodeRanking = TRUE){
if(length(method)==0)
return(NULL)
tmp<-unlist(strsplit(method,"\t",fixed=T))
description<-tmp[1]
command<-tmp[2]
print(paste0("Calculating ranking: ",command))
res<-data.frame(as.vector(eval(parse(text=command))))
if(nodeRanking)
res$V2<-names(V(igraph))
else{
if(as.logical(is.directed(igraph))){
edgesym <- "\U2794"
}
else{
edgesym <- "\U2015"
}
res$V2<-apply(ends(igraph, E(igraph)), 1, paste, collapse=edgesym)
}
return(res[,c(2,1)])
}
runApp()
runApp()
runApp()
runApp()
shiny::runApp()
shiny::showReactLog()
reactlogShow
shiny::runApp()
shiny::showReactLog()
loadNetworkFromFile <- function() {
dataset1 <- NULL
switch(input$uiLoadGraphOptionsInput, oF = {
if (!is.null(input$file1)) {
dataset1 <- read_data(input$file1$datapath)
}
}, oR_Barbasi = {
dataset1 <- data.frame(get.edgelist(barabasi.game(n = as.integer(input$oR_selected_size), power = 1, directed = F)))
}, oR_Erdos_Renyi = {
n <- as.integer(input$oR_selected_size)
dataset1 <- data.frame(get.edgelist(erdos.renyi.game(n = n, p.or.m = as.integer(n * log10(n)), type = "gnm", directed = F)))
}, oR_Watts_Strogatz = {
n <- as.integer(input$oR_selected_size)
dataset1 <- data.frame(get.edgelist(sample_smallworld(1, n, 2, 0.05)))
}, oR_Bipartite = {
n <- as.integer(input$oR_selected_size)
v <- sample(c(F, T), n, T)
v1 <- sample(which(v == F))
v2 <- sample(which(v == T))
e <- unlist(mapply(c, v1, v2, SIMPLIFY = F))
dataset1 <- data.frame(get.edgelist(make_bipartite_graph(v, e, directed = F)))
})
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
shiny::runApp()
runApp()
runApp()
runApp()
doAddNetwork <- observeEvent(input$btnAddNetwork, {
dataset <- loadNetworkFromFile()
if (!is.null(dataset)) {
nid <- UUIDgenerate(T) #time-base UUID is generated
nn <- input$networkName
cnt <- 1 #count
while (nn %in% reactiveVars$StoredNetworks$name) { #reactiveVars: represents a single reactive variable.
cnt <- cnt + 1
nn <- paste(input$networkName, cnt) #paste: converts its arguments (via as.character) to character strings
print("hello")
}
df <- data.frame(id = nid, name = nn, stringsAsFactors = F)
if (nrow(dataset) > 10000) {
dataset <- dataset[1:10000, ]
}
shiny::runApp()
shiny::runApp()
shiny::runApp()
shiny::runApp()
shiny::runApp()
shiny::runApp()
runApp()
runApp()
runApp()
install.packages("reactlog")
tools:::.BioC_version_associated_with_R_version()
shiny::runApp()
runApp()
shiny::runApp()
shiny::runApp()
shiny::runApp()
runApp()
runApp()
shiny::runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
shiny::runApp()
library(MCL)
shiny::runApp()
shiny::runApp()
shiny::runApp()