Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logical merge #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/maxKnownKs.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"","K.2","K.4","K.5","K.6","K.9"
"1",39.0641988031379,40.5065171208468,42.2639233189173,43.6574062551325,52.8978703506378
"1",37.0641988031379,40.5065171208468,42.2639233189173,43.6574062551325,52.8978703506378
49 changes: 37 additions & 12 deletions report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
title: "Perturbation Analysis Report"
output: html_document
params:
g: NA #default value
pv: NA
pe: NA
perturbationCounter: NA
graphHistory: !r list()
pvHistory: !r list()
peHistory: !r list()
delEventHistory: !r list()

---

```{r eval = FALSE, echo = FALSE}
Expand All @@ -15,20 +18,42 @@ params:
# of `n`.
require(igraph)
require(knitr)
require(xtable)
```

```{r echo = FALSE}

coords <- layout_(params$g, as_star())

plot(params$g,
layout = coords, edge.arrow.size = 0.4,
vertex.size = 25, vertex.label.family = "Arial Black")
```{r results= 'asis', echo = FALSE}

# https://stackoverflow.com/questions/28313600/r-knitr-print-in-a-loop
# https://github.com/yihui/knitr/issues/886


knitr::kable(params$pv, caption = "Vertex perturbations",
row.names = FALSE)
#https://stackoverflow.com/questions/32418860/output-markdown-in-r-code-chunk
for (i in 1:params$perturbationCounter){

cat('\n')

cat(paste0("### ",params$delEventHistory[[i]]))

cat('\n')

coords <- layout_(params$graphHistory[[i]], as_star())

plot(params$graphHistory[[i]], layout = coords, edge.arrow.size = 0.4,
vertex.size = 25, vertex.label.family = "Arial Black")

knitr::kable(params$pe, caption ="Edge perturbations")
cat('\n')

print(knitr::kable(params$pvHistory[[i]], caption = "Possible node perturbations",
row.names = FALSE))
cat('\n')

print(knitr::kable(params$peHistory[[i]], caption = "Possible link perturbations",
row.names = FALSE))

cat('\n')

}
```

```
322 changes: 0 additions & 322 deletions report.html

This file was deleted.

59 changes: 49 additions & 10 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,21 @@ shinyServer(function(input, output, session) {

sizeOfHistory <- vcount(g) + ecount(g)

graphHistory <- vector("list", sizeOfHistory)
ptHistory <- vector("list", sizeOfHistory)
pvHistory <- vector("list", sizeOfHistory)
peHistory <- vector("list", sizeOfHistory)
graphHistory <- list()

pvHistory <- list()

peHistory <- list()

delEventHistory <- vector("list", sizeOfHistory)

perturbationCounter <- as.integer(0)
graphHistory[[1]] <- g
pvHistory[[1]] <- relabelVertexTable(pv)
peHistory[[1]] <- relabelEdgeTable(pe)
delEventHistory[[1]] <- "Initial state of the network"

#starts with 1 even though the network hasn't been changed at the start
perturbationCounter <- as.integer(1)

my <- reactiveValues(g = g,
pv = pv,
Expand Down Expand Up @@ -445,15 +453,18 @@ shinyServer(function(input, output, session) {
if (is.null(inFile$datapath)){



} else {

g <- loadGraph(inFile$datapath)
g <- loadGraphPA(inFile$datapath)
my$pv <- calculatePerturbationByVertexDeletion(g, 4, 1)
my$pe <- calculatePerturbationByEdgeDeletion(g, 4, 1)
my$g <- setGraphColors(g, my$pv, my$pe)

my$sizeOfHistory <- vcount(my$g) + ecount(my$g)

my$perturbationCounter <- as.integer(1)

#todo: check if this vector("list", my$sizeOfHistory) works with list() in Report.Rmd
graphHistory <- vector("list", my$sizeOfHistory)
ptHistory <- vector("list", my$sizeOfHistory)
pvHistory <- vector("list", my$sizeOfHistory)
Expand All @@ -469,12 +480,26 @@ shinyServer(function(input, output, session) {

if(vcount(my$g) > 5){

my$perturbationCounter <- my$perturbationCounter + 1



my$g <- delete_vertices(my$g,
input$vertexToDelete)

my$pv <- calculatePerturbationByVertexDeletion(my$g, 4, 1)
my$pe <- calculatePerturbationByEdgeDeletion(my$g, 4, 1)

my$g <- setGraphColors(my$g, my$pv, my$pe)

my$graphHistory[[my$perturbationCounter]] <- my$g
my$pvHistory[[my$perturbationCounter]] <- relabelVertexTable(my$pv)
my$peHistory[[my$perturbationCounter]] <- relabelEdgeTable(my$pe)

my$delEventHistory[[my$perturbationCounter]] <- paste0("Deletion of node ",
input$vertexToDelete)


}

else {
Expand All @@ -499,6 +524,18 @@ shinyServer(function(input, output, session) {
my$pv <- calculatePerturbationByVertexDeletion(my$g, 4, 1)
my$pe <- calculatePerturbationByEdgeDeletion(my$g, 4, 1)

my$g <- setGraphColors(my$g, my$pv, my$pe)

my$perturbationCounter <- my$perturbationCounter + 1

my$graphHistory[[my$perturbationCounter]] <- my$g
my$pvHistory[[my$perturbationCounter]] <- relabelVertexTable(my$pv)
my$peHistory[[my$perturbationCounter]] <- relabelEdgeTable(my$pe)


my$delEventHistory[[my$perturbationCounter]] <- paste0("Deletion of link ",
input$edgeToDelete)

} else {

output$cantDeleteLink <- renderText("can't delete more links")
Expand Down Expand Up @@ -557,9 +594,11 @@ shinyServer(function(input, output, session) {
printET <- relabelEdgeTable(my$pe)


params <- list(g = printG,
pv = printVT,
pe = printET)
params <- list(graphHistory = my$graphHistory,
pvHistory = my$pvHistory,
peHistory = my$peHistory,
perturbationCounter = my$perturbationCounter,
delEventHistory = my$delEventHistory)

rmarkdown::render(tempReport,
output_file = file,
Expand Down