#R code of recursive program to generate GO parent-child relationship table for network visualization
#To identify all the parent-child relationships of GO terms, we applied recursion programming. The programming code in R is provided bellow:
f1 <- function(n, go1){ # assume go1 has only one term
if(length(GOBPCHILDREN[[go1]])==1){
return(c())
}
if(n==1){
e3 = c()
for(i in go1){
a0 = as.character(GOBPCHILDREN[[i]])
a1 = cbind(rep(i, length(a0)), a0)
e3 = rbind(e3, a1)
}
e3
}else{
# e3 = c()
go2 = as.character(GOBPCHILDREN[[go1]])
e3 = cbind(rep(go1, length(go2)), go2)
for (i in go2){
e3 = rbind(e3, f1(n-1, i))
}
e3
}
}
# send starting point and level you want to go down
edge2 = f1(3, "GO:0008150")
#The recursion stopped when it reached a pre-specified depth of N, that reflected how far the recursion went to search for child terms, or when it reached the final term. In this analysis, N=3 for both the main network and for sub-networks in order to control the complexity of the resulting network figure. This recursion process generated tables with parent and child terms that define the edges for our network.