KEGGgraph result difference
1
0
Entering edit mode
Arindam ▴ 80
@ag1805x-15215
Last seen 11 days ago
University of Eastern Finland

I was trying to extract a KEGG pathway as an igraph object of the gene-gene and gene-compound interactions. I observed that different functions from KEGGgraph seemingly give different results. The number of nodes and edges obtained from parseKGML2DataFrame is less than parseKGML2Graph. Also, after parseKGML, the statistics display different numbers of nodes and edges. The graph obtained from parseKGML2Graph has some additional genes, which I assume are the islands that do not show up in the data frame. But what about the parseKGML statistics? And why does the parseKGML2Graph contain ontology or the path itself as a node?


> path_id <- "dre03320"
> 
> retrieveKGML(pathwayid = path_id, organism = "dre", destfile = paste("tmp_dir/", path_id, ".kgml"))
trying URL 'https://rest.kegg.jp/get/dre03320/kgml'
downloaded 25 KB

> 
> df <- parseKGML2DataFrame(file = paste("tmp_dir/", path_id, ".kgml"), reactions = TRUE, genesOnly = FALSE)
Warning message:
In KEGGpathway2reactionGraph(pathway) :
  The pathway contains no chemical reactions!

> length(unique(c(df$from, df$to)))
[1] 89
> nrow(df)
[1] 501
> 
> net_1 <- parseKGML2Graph(file = paste("tmp_dir/", path_id, ".kgml"), genesOnly = FALSE, expandGenes = TRUE)
> net_1
A graphNEL graph with directed edges
Number of Nodes = 111 
Number of Edges = 491 
> 
> path <- parseKGML(file = paste("tmp_dir/", path_id, ".kgml"))
> path
KEGG Pathway
[ Title ]: PPAR signaling pathway
[ Name ]: path:dre03320
[ Organism ]: dre
[ Number ] :03320
[ Image ] :https://www.kegg.jp/kegg/pathway/dre/dre03320.png
[ Link ] :https://www.kegg.jp/kegg-bin/show_pathway?dre03320
------------------------------------------------------------
Statistics:
    65 node(s)
    53 edge(s)
    0 reaction(s)
------------------------------------------------------------
> 
> net_2 <- KEGGpathway2Graph(path, genesOnly = FALSE, expandGenes = TRUE)
> net_2
A graphNEL graph with directed edges
Number of Nodes = 111 
Number of Edges = 491

Once I have the GraphNEL object from KEGGgraph, i can convert it to igraph object but I get error while doing further processing on these graphs. Any idea why this might be?


> net_1_igraph <- igraph::graph_from_graphnel(net_1)
> net_2_igraph <- igraph::graph_from_graphnel(net_2)
> 
> RCy3::createNetworkFromIgraph(net_1_igraph)
Error in FUN(X[[i]], ...) : environments cannot be coerced to other types
> RCy3::createNetworkFromIgraph(net_2_igraph)
Error in FUN(X[[i]], ...) : environments cannot be coerced to other types
> net_1_igraph_df <- igraph::as_data_frame(net_1_igraph, what = "edges")
> net_2_igraph_df <- igraph::as_data_frame(net_2_igraph,  what = "edges")
> 
> net_1_igraph_df
Error in paste(x, collapse = ", ") : 
  environments cannot be coerced to other types
> net_2_igraph_df
Error in paste(x, collapse = ", ") : 
  environments cannot be coerced to other types
igraph KEGGgraph RCy3 GraphNEL • 356 views
ADD COMMENT
1
Entering edit mode
alex.pico ▴ 30
@alexpico-15339
Last seen 7 weeks ago
United States

I'm not surprised that this fails. Not all GraphNELs nor igraphs are the same, so these chains of conversions are fraught with peril. Assuming the goal is creating the network in Cytoscape (given the final lines you shared), here are some shorter routes:

  1. RCy3::createNetworkFromDataFrames(). If you can extract a simple node and edge dataframes from the parsed KGML, then you have more transparent control over the conversion and completely skip the poorly specified/implemented GraphNEL and igraph intermediates. [50/50 odds of working]
  2. RCy3::commandsRun('wikipathways import-as-pathway id="WP4020'). Skip KEGG altogether :) If you have the WikiPathways app installed in Cytoscape, then this one liner will perform the import. [100% odds of working]
ADD COMMENT
0
Entering edit mode

The first method seems better. However, there seems to be a small discrepancy in how the KGML is parsed.

path_id <- "dre00982"
test1_net <- parseKGML2Graph(file = paste0("tmp_dir/", path_id, ".kgml"), 
                                                    genesOnly = FALSE)
test2_net <- parseKGML2DataFrame(file = paste0("tmp_dir/", path_id, ".kgml"), 
                                 reactions = TRUE, 
                                 genesOnly = FALSE)

Here in test2_net there are grouped nodes "dr:D08233 cpd:C01516". But in test1_net, this is spitted as separate nodes. Is this expected?

ADD REPLY

Login before adding your answer.

Traffic: 565 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6