combineNetwork - combine two networks
Description
The function combines two networks at a time. The networks might be computed from grinn functions such as fetchGrinnNetwork, fetchCorrGrinnNetwork, fetchDiffCorrGrinnNetwork, or from users' provided networks. The provided network must be in the following format:
nodes = data.frame(id,nodename,nodetype) #nodes contain at least 3 columns
edges = data.frame(source,target,relname) #edges contain at least 3 columns nwX or nwY = list(nodes,edges).
Usage
combineNetwork(nwX, nwY, returnAs)
Arguments
nwX | list of nodes and edges to be combined. |
nwY | list of nodes and edges to be combined. |
returnAs | string of output type. Specify the type of the returned network. It can be one of "tab","json","cytoscape", default is "tab". "cytoscape" is the format used in Cytoscape.js |
Value
list of nodes and edges. The list is with the following componens: edges and nodes. Return empty list if error.
Examples
# Create metabolite-protein network from the list of metabolites using grinn ids and combine the grinn network to a correlation network
kw <- c('G160','G300','G371')
grinnnw <- fetchGrinnNetwork(txtInput=kw, from="metabolite", to="protein")
# Compute a correlation network of metabolites and expand to a grinn network of metabolite-protein
dummy <- rbind(nodetype=rep("metabolite"),t(mtcars))
colnames(dummy) <- c('G1.1','G15603','G371','G17295',paste0('G',sample(400:22000, 28)))
corrnw <- fetchCorrGrinnNetwork(datX=dummy, corrCoef=0.7, pval=1e-12, method="spearman", returnAs="tab", xTo="protein")
result <- combineNetwork(grinnnw,corrnw)
# Create metabolite-protein network from the list of metabolites using grinn ids and combine the grinn network to a provided network
txtInput <- list('G371','G783','G1.1')
grinnnw <- fetchGrinnNetwork(txtInput, from="metabolite", to="protein")
nwY = list()
nwY$nodes = data.frame(id=c("G371","G783","XXX","YYY"),nodename=c("G371","G783","XXX","YYY"),nodetype=c("metabolite","metabolite","protein","protein"),stringsAsFactors = FALSE)
nwY$edges = data.frame(source=c("G371","G783"),target=c("XXX","YYY"),corr_coef=c(-0.368,0.385),pval=c(0.000927,0.000497),reltype=c("Metabolite_Protein","Metabolite_Protein"),relname=c("CORRELATION","CORRELATION"),stringsAsFactors = FALSE)
result <- combineNetwork(grinnnw,nwY)
Go to HOME | Documentation | fetchGrinnNetwork | fetchCorrGrinnNetwork | fetchDiffCorrGrinnNetwork | fetchModuGrinnNetwork | fetchGrinnCorrNetwork | input formats