saezlab / CARNIVAL

CAusal Reasoning for Network Identification with integer VALue programming in R
https://saezlab.github.io/CARNIVAL/
57 stars 29 forks source link

No DOT figure #74

Closed harrytr closed 2 years ago

harrytr commented 3 years ago

Using BigSur 11.6 and CPLEX 20.10, I get no DOT figure with CARNIVAL 2.2 as an output network even though the problem is optimal. The same inputs generate a DOT figure file in Windows10 as normal.

gabora commented 2 years ago

Hi, sorry, I think this feature was temporarily removed, but it is very easy to produce by creating a graph from the results$weightedSIF by the igraph package and then export (see code below). BTW, for an interactive view, I would use the visNetwork package.

library(igraph)
library(CARNIVAL)
library(dplyr)

# run CARNIVAL:
results = runCARNIVAL(...)

results$weightedSIF %>%
dplyr::select(Node1,Node2,Sign,Weight) %>%  # arrange the columns of the SIF, igraph assumes that the nodes are in the first 2 columns: 
dplyr::filter(Weight >0) %>%                # remove edges which never appear: 
igraph::graph_from_data_frame(.) %>%       # convert to igraph graph
igraph::write_graph("result_graph.dot",format = "dot")  # export to dot