cytoscape / RCy3

New version of RCy3, redesigned and collaboratively maintained by Cytoscape developer community
MIT License
48 stars 20 forks source link

createNetworkFromGraph doesn't work on pathways from KEGGParser app #196

Closed AlexanderPico closed 1 year ago

AlexanderPico commented 1 year ago

From Jordan:

My name is Jordan Langston, and I am a bioengineering doctoral student at Temple University in Philadelphia. I remember reaching out to you a few years ago regarding a few questions in Cytoscape/R. I wanted to follow up on one in case you may have any new ideas on the matter. In Cytoscape, there is the KEGGParser app that allows you to load in a KGML file and edit existing pathways, tuning it etc (example attached). In the RCy3 package, you and your team created a couple of functions that convert a graph in Cytoscape to a graphNEL object in R and vice versa. I ran the command to convert the graph attached to a graphNEL in R and received this error:

Error in names(x) <- value : 'names' attribute [2] must be the same length as the vector [1].

Any advice would be much appreciated or tips to work around this.

AlexanderPico commented 1 year ago

Without the CYS file, it's hard to say for sure. But my guess is that KEGGParser app makes a few non-network objects (like those labels and ovals) that cannot be converted to graphNEL.

Troubleshooting idea:

Also, what are you trying to accomplish overall? Maybe there is another suggested route.

jordlang01 commented 1 year ago

I'm unsure which components break the conversion, thus I probably can not pinpoint which components to specifically delete to prevent the error.

I'm trying to manually create pathways (or edit existing KEGG pathways to add in new interactions etc.), somehow import them into R and convert into a graphNEL object, convert it to a boolean network (already have a R script for that), and then use another script from one of my collaborators to run different computational analysis on it.

AlexanderPico commented 1 year ago

Got it.

In order to determine with components break the conversion, simply delete everything but a few nodes in your KEGG network and try. If it works, then try second time with fewer components deleted. Repeat until it doesn't work, then you'll have the answer.

Regarding strategy. You might try exporting the KEGG as something simple, like SIF file. Then import the sif and convert that to graphNEL. Somehow you need to strip away the "extra" non-graph stuff that KEGG is importing.

For example, the WikiPathways app allows you import pathways "as networks" which does exactly this, making them easy to work with as graph objects. You could try using that instead of KEGGParser.

kozo2 commented 1 year ago

I am familiar with working with KEGG data and may be able to help in some way with this case. I do not know where to find the KEGGParser app at first. Could you tell me the website for the KEGGParser app?

AlexanderPico commented 1 year ago

@kozo2 Surely you know where to find Cytoscape apps! :) https://apps.cytoscape.org/apps/cykeggparser

kozo2 commented 1 year ago

@AlexanderPico Thank you for your comment. I was wondering if Jordan intended another app since https://apps.cytoscape.org/apps/cykeggparser has stopped updating. Anyway I will investigate Jordan's issue.

jordlang01 commented 1 year ago

@kozo2 Thanks for offering to help. Yes, I am using the latest version of cykeggparser (think 2017). I downloaded the cykeggparser app within Cytoscape and imported a kegg pathway from there.

kozo2 commented 1 year ago

@jordlang01 By the way, which KEGG pathway did you import using cykeggparser?

jordlang01 commented 1 year ago

@kozo2 the leukocyte transendothelial migration pathway

kozo2 commented 1 year ago

@jordlang01 OK. I took it to be https://www.genome.jp/pathway/hsa04670 .

jordlang01 commented 1 year ago

@kozo2 Yes

jordlang01 commented 1 year ago

@AlexanderPico I deleted many nodes from the KEGG graph (only 3-4 left), but I still received the same error when trying to convert it from graph to graphNEL.

jordlang01 commented 1 year ago

@AlexanderPico Also, when I downloaded the wikipathways app in Cytoscape; I was unable to access it, as in it wasn't under the "apps" tab in the Cytoscape tool bar. I've tried restarting, uninstalling and installing the app a few times, but it still does not appear. I am specifically interested in KEGG rather than wikipathways. I also tried creating my own small (3 nodes and 2 edges) pathway in Pathvisio, saved it as a gpml, and tried to import in in Cytoscape (as a network not pathway), but I obtained the error.

AlexanderPico commented 1 year ago

Ah, it doesn't add anything to the "app" tab. It works as a network search tool (upper left of control panel)

Screen Shot 2023-02-14 at 11 56 07 AM

AlexanderPico commented 1 year ago

More details here: https://apps.cytoscape.org/apps/wikipathways

Remember to try "import as network" if you find an interesting pathway.

jordlang01 commented 1 year ago

@AlexanderPico Ok, now I remember that is where the wikipathways app is found, thanks. Any additional thoughts on my previous comment, where I deleted many nodes from an imported KEGG pathway in Cytoscape, tried to run the creategraphfromnetwork function in r, but I still obtained the same error?

AlexanderPico commented 1 year ago

Another test: Select 2 or 3 connected nodes and create a new subnetwork. Then try to convert that.

If that also fails, then there is something inherent to how nodes and/or edges are named by the CyKEGGParser app that is breaking convention.

jordlang01 commented 1 year ago

@AlexanderPico I did try your suggestion but it didn't work unfortunately. Creating a smaller network using Cytoscape's default node and edge styles does allow the conversion to work, just unsure why it doesn't for KEGG pathways, which would be the preferable place to begin when it comes to manually editing existing pathways and then converting it vs creating one from scratch using Cytoscape's default and then converting it.

Do you possibly know of any other Cytoscape apps that works with KEGG pathways or another software/program in general where the user can import KEGG pathways and edit them, figuring out a way to transfer the file to R as a graphNEL object etc?

AlexanderPico commented 1 year ago

Some ideas:

jordlang01 commented 1 year ago

Thanks for the input. On NDEx, can you also edit existing pathways yourself before reading them into R, in case you want to add/remove interactions that may/may not be present for one's research?

AlexanderPico commented 1 year ago

NDEx is a database for Cytoscape networks in CX format. So, you could start with an NDEx network, then import it into Cytoscape, edit, then export back to NDEx, then read into R.

Or, you could try starting with a KEGG network in Cytoscape, exporting to NDEx, then read into R.

These steps can all be done in R using RCy3 and NDExR packages.

jordlang01 commented 1 year ago

@AlexanderPico I was able to successfully export the pathway to NDEx, created an account and uploaded the network/pathway to the site, but now I'm having trouble reading it into R. I've gone through the ndexR into R, logged into my account in R, but I'm unable to import my own network into R. I'm able to import other networks from NDEx into R, but from my own personal account, I'm having some trouble.

AlexanderPico commented 1 year ago

Believe it or not, you are pioneering new workflows that I haven't seen others do yet, nor have I done them myself. So, I can suggest things to try, but in the end, it might not be possible or there might be a bug in ndexr or something else beyond my control.

I don't have a suggestion for your current NDEx to R import issue. You could contact NDEx support or file a bug with the ndexr package? Or kozo might have other suggestions?

jordlang01 commented 1 year ago

That is very hard to believe but thanks! I was able to figure out how to import the KEGG pathway from NDex into R. I just went back to the vignette and made a couple of adjustments to my code.

jordlang01 commented 1 year ago

@AlexanderPico Sorry I know you closed this comment, but I just realized something. When I imported the KEGG pathway to NDex, the graph went from directed to undirected. Is there a way to maintain those directed connections during conversion or is this hard coded in the Cytoscape system?

AlexanderPico commented 1 year ago

That’s probably an NDEx question. As far as I know all cytoscape networks are directed since there is always a source and target.

jordlang01 commented 1 year ago

Ok, thank you.