cytoscape / RCy3

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

Importing a graphNEL from 'GOstats' Error in cyrestPUT(paste("networks", net.suid, "tables", tbl, sep = "/"), : object 'res' not found #223

Closed methornton closed 4 months ago

methornton commented 4 months ago

Hello! I also posted this in the Bioconductor support forum. I recently updated to Cytoscape 3.10 and the latest RCy3. I am trying to import graphNEL network graphs from 'GOstats' into Cytoscape. Previously I was not having any problems. I'm sure that it is a formatting error. my graphNEL looks like this:

> str(y1$`1`)
Formal class 'graphNEL' [package "graph"] with 6 slots
  ..@ nodes     : chr [1:79] "GO:0015267" "GO:0022803" "GO:0015318" "GO:0022836" ...
  ..@ edgeL     :List of 79
  .. ..$ GO:0015267:List of 1
  .. .. ..$ edges: int 2
  .. ..$ GO:0022803:List of 1
  .. .. ..$ edges: int 5
  .. ..$ GO:0015318:List of 1
   Truncated
  .. ..$ GO:0005253:List of 1
  .. .. ..$ edges: int [1:2] 8 70
  ..@ edgeData  :Formal class 'attrData' [package "graph"] with 2 slots
  .. .. ..@ data    : Named list()
  .. .. ..@ defaults:List of 1
  .. .. .. ..$ weight: num 1
  ..@ nodeData  :Formal class 'attrData' [package "graph"] with 2 slots
  .. .. ..@ data    :List of 79
  .. .. .. ..$ GO:0015267:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:417] "100360100" "100361584" "100362565" "113995" ...
  .. .. .. .. ..$ pvalue   : num 7.71e-28
  .. .. .. .. ..$ oddsRatio: num 4.99
  .. .. .. .. ..$ expCount : num 22.8
  .. .. .. ..$ GO:0022803:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:417] "100360100" "100361584" "100362565" "113995" ...
  .. .. .. .. ..$ pvalue   : num 7.71e-28
  .. .. .. .. ..$ oddsRatio: num 4.99
  .. .. .. .. ..$ expCount : num 22.8
  .. .. .. ..$ GO:0015318:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:609] "100360100" "100361584" "100362565" "113918" ...
  .. .. .. .. ..$ pvalue   : num 4.25e-27
  .. .. .. .. ..$ oddsRatio: num 4.07
  .. .. .. .. ..$ expCount : num 33.2

  .. .. .. ..$ GO:0015501:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:4] "25550" "29482" "29483" "84012"
  .. .. .. .. ..$ pvalue   : num 0.000621
  .. .. .. .. ..$ oddsRatio: num 52.2
  .. .. .. .. ..$ expCount : num 0.218
  .. .. .. ..$ GO:0005313:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:14] "116638" "25550" "266767" "291840" ...
  .. .. .. .. ..$ pvalue   : num 0.000632
  .. .. .. .. ..$ oddsRatio: num 9.69
  .. .. .. .. ..$ expCount : num 0.764
  .. .. .. ..$ GO:0005254:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:66] "100361584" "114516" "116638" "140674" ...
  .. .. .. .. ..$ pvalue   : num 0.000812
  .. .. .. .. ..$ oddsRatio: num 3.5
  .. .. .. .. ..$ expCount : num 3.6
  .. .. .. ..$ GO:0140161:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:9] "171163" "24777" "289459" "305309" ...
  .. .. .. .. ..$ pvalue   : num 0.000889
  .. .. .. .. ..$ oddsRatio: num 13.9
  .. .. .. .. ..$ expCount : num 0.491
  .. .. .. ..$ GO:0005253:List of 4
  .. .. .. .. ..$ geneIds  : chr [1:77] "100361584" "114516" "116638" "140674" ...
  .. .. .. .. ..$ pvalue   : num 0.000889
  .. .. .. .. ..$ oddsRatio: num 3.24
  .. .. .. .. ..$ expCount : num 4.2
  .. .. ..@ defaults:List of 5
  .. .. .. ..$ pvalue     : num 1
  .. .. .. ..$ geneIds    : num(0) 
  .. .. .. ..$ condGeneIds: num(0) 
  .. .. .. ..$ oddsRatio  : num 1
  .. .. .. ..$ expCount   : num(0) 
  ..@ renderInfo:Formal class 'renderInfo' [package "graph"] with 4 slots
  .. .. ..@ nodes: list()
  .. .. ..@ edges: list()
  .. .. ..@ graph: list()
  .. .. ..@ pars : list()
  ..@ graphData :List of 1
  .. ..$ edgemode: chr "directed"

Here is the error:

       > createNetworkFromGraph(y1$`1`, "male1v0_GOMF")
        Loading data...

        Error: Not Found
        In addition: Warning message:
        In .local(x, container, collapse, ..., .level = .level, .withNames = .withNames,  :
          non-fininte values in numeric vector may not be approriately represented in JSON
        Error in cyrestPUT(paste("networks", net.suid, "tables", tbl, sep = "/"),  : 
          object 'res' not found

Is there some package that I need? What is 'res' and how do I specify it. I googled it and I didn't find anything.

When I start up Cytoscape I get no errors, when I try the import I get these errors:

        karaf.base: /usr/local/lib/cytoscape/Cytoscape_v3.10.2/framework
        JAVA_HOME: /usr/lib/jvm/jdk-17/
                     _                                    
           ___ _   _| |_  ___  ___  ___  __ _ _ __   ___  
          / __| | | | __|/ _ \/ __|/ __|/ _` | '_ \ / _ \ 
         | (__| |_| | |_| (_) \__ \ (__| (_| | |_) |  __/ 
          \___|\__, |\__|\___/|___/\___|\__,_| .__/ \___| 
               |___/                         |_|          

        Cytoscape 3.10.2

        Hit '<tab>' for a list of available commands
           and '[cmd] --help' for help on a specific command.
        Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown Cytoscape.

        karaf@Cytoscape 3.10.2()> Found 1 platforms                                                                                                              
        Got 1 platforms
        Got 1 devices
        Platform: NVIDIA CUDA
        Device: OpenCL 3.0 CUDA Quadro T2000 with Max-Q Design
        The cl_program [0x78AA00BB92A0] was built successfully
        BUILD LOG:
        ----

        -----
        Program built
        Top device after init = OpenCL 3.0 CUDA Quadro T2000 with Max-Q Design
        UserAgent = Cytoscape v3.10.2 Java 17.0.2 Linux 6.5.0-28-generic
        latestVersion = 3.10.2
        com.fasterxml.jackson.core.JsonParseException: Non-standard token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow
         at [Source: org.glassfish.jersey.message.internal.EntityInputStream@e3b340; line: 451, column: 24]
            at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1586)
            at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:521)
            at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2613)
            at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextFieldName(UTF8StreamJsonParser.java:1069)
            at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeObject(JsonNodeDeserializer.java:219)
            at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeArray(JsonNodeDeserializer.java:270)
            at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeObject(JsonNodeDeserializer.java:227)
            at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:69)
            at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:15)
            at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807)
            at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2867)
            at org.cytoscape.rest.internal.resource.TableResource.updateTable(TableResource.java:319)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:568)
            at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
            at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
            at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
            at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
            at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
            at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
            at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
            at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
            at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
            at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
            at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
            at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
            at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
            at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76)
            at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
            at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1631)
            at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:292)
            at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
            at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
            at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
            at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:74)
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
            at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
            at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
            at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
            at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
            at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
            at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
            at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:294)
            at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
            at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
            at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
            at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
            at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
            at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:90)
            at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
            at org.eclipse.jetty.server.Server.handle(Server.java:516)
            at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
            at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
            at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
            at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
            at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
            at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
            at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
            at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
            at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
            at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
            at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
            at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
            at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
            at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
            at java.base/java.lang.Thread.run(Thread.java:833
AlexanderPico commented 4 months ago

Hey Matthew. I started to answer this over at Bioconductor but then found this post here where it's easier to share files etc.

The error message you are getting is indeed not very helpful. It's just saying that the CyREST return obj "res" failed to be returned. This could be caused by a failure at any number of steps. In order to better troubleshoot, it would be helpful to have a test case that I can run locally and debug...

I'll try with a simple graphNEL first. If that works, then I'll need your help recreating (or receiving) your more complex case...

AlexanderPico commented 4 months ago

Ok. This simple case works for me. Does it work for you?

createNetworkFromGraph(makeSimpleGraph())

This first test will help isolate the issue to either your setup vs mine or to the complexity of the graphNEL.

methornton commented 4 months ago

Hello! Thank you for your help! Yes. The above works. Please let me know if you would like an rds file that has just the graphNEL. I don't get the error every time, just 90% I can give an rds graphNEL for the error producing and one that worked like your above example.


> library(RCy3)
> cytoscapePing()
You are connected to Cytoscape!
> createNetworkFromGraph(makeSimpleGraph())
Loading data...

Applying default style...

Applying preferred layout...

networkSUID 
       8745 
methornton commented 4 months ago

Hello! Github wont let me attach rds files. I can email them or ftp. I can put them on my webserver. please let me know what is best.

AlexanderPico commented 4 months ago

The RDS would be perfect. Email to alex.pico@gladstone.ucsf.edu.

AlexanderPico commented 4 months ago

Thanks for the test files. I found the culprit!

The error is occuring during the loadTableData step for node attributes. In particular it's failing on the entry for GO:0005234 where oddsRatio ="inf".

At this point in the script, RCy3 is passing Cytoscape data to fill the Node Table and Cytoscape is specifically attempting to fill a column of Double values in the oddsRatio column. When it hits the String value of "Inf" Cytoscape chokes and throws an error back through CyREST to RCy3.

Easiest fix would be to pre-screen your data values to remove these or set these to a really huge number or whatever makes sense for your analysis. Would this work for you?

AlexanderPico commented 4 months ago

Will also look into implementing a check on our end to catch and swap these automatically... See #224

methornton commented 4 months ago

Oh yeah. I have seen that before. I figures inf was just a placeholder for that really huge number. I'll have to find a way to replace them in the object. Thank you for finding my issue and your help. I really appreciate it!

AlexanderPico commented 4 months ago

Here's a snippet that might work for you if you have you data in a dataframe...

data[] <- lapply(data, function(x){
  if (is.numeric(x)) {
    max_java <- .Machine$integer.max
    min_java <- .Machine$integer.min
    x[is.infinite(x) & x > 0] <- max_java
    x[is.infinite(x) & x < 0] <- min_java
  }
)
guidohooiveld commented 4 months ago

Sorry to chime in (was checking this thread out of curiosity), but .Machine$integer.min doesn't exist, and is therefore NULL? I guess this is not the intended behavior?

> .Machine$integer.max
[1] 2147483647
> .Machine$integer.min
NULL
>

AFAIK the maximum integer value is 2^31 - 1 = +2147483647, and the minimum integer value is -2^31 + 1 = -2147483648, should it not better be:

max_java <-  (2^31) - 1
min_java <- -(2^31) + 1

> as.integer(.Machine$integer.max)
[1] 2147483647
>
> as.integer(2^31)
[1] NA
Warning message:
NAs introduced by coercion to integer range 
> as.integer((2^31)-1)
[1] 2147483647
> as.integer(-2^31)
[1] NA
Warning message:
NAs introduced by coercion to integer range 
> as.integer(-(2^31)+1)
[1] -2147483647
>

Full output:

> .Machine
$double.eps
[1] 2.220446e-16

$double.neg.eps
[1] 1.110223e-16

$double.xmin
[1] 2.225074e-308

$double.xmax
[1] 1.797693e+308

$double.base
[1] 2

$double.digits
[1] 53

$double.rounding
[1] 5

$double.guard
[1] 0

$double.ulp.digits
[1] -52

$double.neg.ulp.digits
[1] -53

$double.exponent
[1] 11

$double.min.exp
[1] -1022

$double.max.exp
[1] 1024

$integer.max
[1] 2147483647

$sizeof.long
[1] 4

$sizeof.longlong
[1] 8

$sizeof.longdouble
[1] 16

$sizeof.pointer
[1] 8

$sizeof.time_t
[1] 8

$longdouble.eps
[1] 1.084202e-19

$longdouble.neg.eps
[1] 5.421011e-20

$longdouble.digits
[1] 64

$longdouble.rounding
[1] 5

$longdouble.guard
[1] 0

$longdouble.ulp.digits
[1] -63

$longdouble.neg.ulp.digits
[1] -64

$longdouble.exponent
[1] 15

$longdouble.min.exp
[1] -16382

$longdouble.max.exp
[1] 16384

>
AlexanderPico commented 4 months ago

@guidohooiveld Good catch! My initial test case only had positive values and we hadn't yet implemented and fully tested this. I would update the snippet to just use -.Machine$integer.max like below, but your approach works too. Thanks!

data[] <- lapply(data, function(x){
  if (is.numeric(x)) {
    max_java <- .Machine$integer.max
    min_java <- -.Machine$integer.max
    x[is.infinite(x) & x > 0] <- max_java
    x[is.infinite(x) & x < 0] <- min_java
  }
)