# simple network engine prep
grow <- function(nominal_GO_df, rownamespwfOne, enriched.GO, Genome, topEnriched) ({
total = list()
getGo <- getgo(rownamespwfOne, Genome, input$geneRef)
Base = data.table(rownamespwfOne, getGo)
for(go in nominal_GO_df$ind[1:topEnriched]){
Names <- Base$rownamespwfOne[grep(go,Base$getGo)]
nameList = list(Names)
total = append(total, nameList)
}
names(total) <- nominal_GO_df$ind[1:topEnriched]
total <- total
})
# simple network engine
network <- reactive({
enriched.GO <- enriched()
#network analysis loop (FDR vs nominal p-value) within simple network engine
if(!length(enriched.GO) == 0){
nominal_GO_df <- stack(lapply(mget(enriched.GO, GOTERM, ifnotfound = NA), Term))
total <- grow(nominal_GO_df, rownamespwfOne, input$chooseEnriched, input$Genome, input$numberGenes)
namesGo <- names(total)
vector = c()
targetVector = c()
for (go in 1:length(namesGo)){
lengthName <- length(total[[go]])
for(populate in 1:lengthName){
nameGene <- nominal_GO_df$values[grep(namesGo[go], nominal_GO_df$ind)]
vector = append(vector, nameGene)
targetVector = append(targetVector, total[[go]][populate])
}
}
src <- vector
target <- targetVector
networkData <- data.frame(src, target)
simpleNetwork(networkData)
# , charge = -1000, opacity = 1, zoom = T)
}
else {
return(validate(need(input$goData == 0, "No enriched genes are available to make a network at this statistical cutoff level")))
}
})
# simple network output
output$networkData <- renderSimpleNetwork({
if (input$doNets == 0) {return(validate(
need(input$countMatrix != 0, "For network analysis, please first select a file for input") %then%
need(input$goButton != 0, "For network analysis, please first perform Differential Expression Analysis") %then%
need(input$goData != 0, "For network analysis, please perform Gene Ontology analysis") %then%
need(input$doNets != 0, "For network analysis, please click on 'Do Network Analysis' and wait for about 5-30 seconds")
))}
else {
network()
}
})
})
Thank You.