cytoscape / RCy3

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

broweURL() does not import KEGG pathways from KGML file #199

Closed delfarahalireza closed 1 year ago

delfarahalireza commented 1 year ago

I used to be able to import a KEGG KGML pathway to Cytoscape with a browsURL command in R e.g: browseURL('http://localhost:1234/keggscape/v1/ko00010', browser = getOption("browser"), encodeIfNeeded = FALSE) I believe this was done via KEGGScape Cytoscape app. I'm using Cytoscape 3.9.1 and still have KEGGScape, but the pathway import does not work via R.

AlexanderPico commented 1 year ago

Hi. browseURL simply opens a url in CyBrowser. It does not perform an import into Cytoscape.

Maybe the KEGGScape Cytoscape app offers an import command? You should find it in the swagger docs if you have Cytoscape running and the app installed. See commandsAPI(). If it's not there, then I'm not sure how you did it in 3.9.1, but it wasn't by using browseURL.

AlexanderPico commented 1 year ago

I just installed the app, but I don't see any support for commands.

The KEGGscape app page mentions automation support and links to here: https://github.com/idekerlab/KEGGscape/blob/master/usecase/f1000-cyauto-workflow.Rmd

But this is for python using the old py2cytoscape, which has been replaced and is no longer supported.

AlexanderPico commented 1 year ago

Interestingly, the app store page also says this:

KEGGscape 0.8.x has REST API. You can import KEGG pathway to Cytoscape by requesting http://localhost:1234/keggscape/v1/THE_KEGG_PATHWAY_ID for example you can import http://www.genome.jp/dbget-bin/www_bget?eco00010 by requesting http://localhost:1234/keggscape/v1/eco00010

which matches exactly what you are saying. I have no idea how this ever worked, however. It is beyond the scope of what I thought browseURL did :)

You might need to contact the folks hosting the KEGG REST API...

AlexanderPico commented 1 year ago

Nothing in RCy3 changed regarding this method. So, I'll close the ticket here. I hope they can address your issue at KEGG. If not, consider the WikiPathways app for Cytoscape :)

delfarahalireza commented 1 year ago

Thanks for the quick response. I was definitely able to import a KEGG pathway to Cytoscape in the past either with a localhost request on a browser or running browsURL() in R. I'll try to seek a solution from KEGG REST API people. Thanks again.

kozo2 commented 1 year ago

Hi @AlexanderPico @delfarahalireza I am the KEGGscape maintainer. I am sorry, I have removed the KEGGscape REST API (that Alex referred) from KEGGscape App. The reason was that the KEGG [API] license was unclear, and I felt that there was a risk of violating the license. Therefore, I decided to have users download kgml by themselves using software other than KEGGscape.

Once the kgml is downloaded using some software other than KEGGscape, you can import the KGML into Cytoscape using RCy3::importNetworkFromFile(file = "THEKGMLFILEPATH") function.

delfarahalireza commented 1 year ago

Hi @kozo2 thanks for letting me know. I had missed the RCy3::importNetworkFromFile function, it works, thank you.

bdemchak commented 1 year ago

@delfarahalireza @AlexanderPico @kozo2 Wouldn't it be possible to use a sandbox function to directly download a file from a URL onto the PC so that it can then be imported into Cytoscape?

For py4cytoscape, the appropriate Cytoscape function would be sandbox_url_to. It would leave the file (on my machine) in CytoscapeConfiguration/filetransfer/default_sandbox.

I think the corresponding RCy3 function might be sandboxUrlTo().

It's possible to use sandbox functions to make this even more convenient. If this is useful, I can elaborate.

Here's a good tutorial on sandboxing:

kozo2 commented 1 year ago

@bdemchak Thanks for the comment.

@delfarahalireza @AlexanderPico

I believe that the code intended by Barry would be the following (for RCy3). I'm sorry, KEGGscape does not seem to automatically apply the KEGG style on import. This is due to my lack of maintenance. I can't update that Java code right away, so I'm using RCy3's setVisualStyle() to apply that style.

library(RCy3)
installApp("KEGGscape")
sandboxUrlTo("https://rest.kegg.jp/get/hsa00600/kgml", "hsa00600.xml")
importNetworkFromFile("hsa00600.xml")
setVisualStyle("KEGG Style")
delfarahalireza commented 1 year ago

@bdemchak @kozo2 Thanks both!

This should work! I'm using an old version of RCy3 2.6.0 (which doesn't have sandboxUrlTo function). The reason for using 2.6.0 is because the new version 2.19.0 was significantly slower when running commands between R and Cytoscape. I haven't figured out why the 2.19.0 version is slow on my end, I will submit a separate issue if I figure that out. So I haven't been able to test sandboxUrlTo yet, but it seems like it should work perfectly fine. Also @kozo2 yes, upon importing a xml file, Cytoscape applies the default visual style, but that can easily be changed to "KEGG Style" with setVisualStyle("KEGG Style") as you mentioned. Thanks again!

bdemchak commented 1 year ago

@delfarahalireza @kozo2 @AlexanderPico @yihangx Good news there. Sorry you're having speed issues with 2.19.0 ... I'm the py4cytoscape guy, so I wouldn't be much help with RCy3 issues.

However, I can suggest that if you really need to stick with 2.6, there's another way to access this sandbox function. It turns out that sandbox code calls a Cytoscape core app (called filetransfer) to do its work. Specifically, urlToSandbox() in filetransfer ... and you can call it yourself directly from RCy3 by using commandsPOST(). You can see how the sandbox function calls it by looking at the current RCy3's Sandbox.R::sandboxUrlTo() function near line 195.

You can read about this app here

The most recent version of filetransfer is 1.3 ... if you don't have it installed, you can find it here

You can play with it interactively with Cytoscape's Command panel (View | Show Command Panel) or via Swagger by using Cytoscape's Help | Automation | CyREST Commands API Pictures of both are below.

Enjoy!

image

image