[BioC] RCytoscape: object 'graph' not found error
Paul Shannon
paul.thurmond.shannon at gmail.com
Tue Dec 31 22:34:15 CET 2013
Hi Chris,
Switching to a graphNEL -- which RCytoscape requires -- here below is some working graph-creation code.
In addition to the vignette and the usual R help, some useful documentation and examples can be found here
http://rcytoscape.systemsbiology.net
Does this help? If an adjacency matrix is the data you prefer to start from, then this may be helpful:
g.am <- graphAM(your.matrix, edgemode="directed")
g <- as(g.am, "graph")
# --- working code
library(RCytoscape)
from <- c("ENSMUSG00000000037", "ENSMUSG00000000037",
"ENSMUSG00000000037", "ENSMUSG00000000037",
"ENSMUSG00000000037", "ENSMUSG00000004267",
"ENSMUSG00000004267", "ENSMUSG00000004267",
"ENSMUSG00000004267", "ENSMUSG00000016757",
"ENSMUSG00000016757", "ENSMUSG00000016757",
"ENSMUSG00000019849", "ENSMUSG00000019849",
"ENSMUSG00000022070")
to <- c( "ENSMUSG00000004267", "ENSMUSG00000016757",
"ENSMUSG00000019849", "ENSMUSG00000022070",
"ENSMUSG00000022391", "ENSMUSG00000016757",
"ENSMUSG00000019849", "ENSMUSG00000022070",
"ENSMUSG00000022391", "ENSMUSG00000019849",
"ENSMUSG00000022070", "ENSMUSG00000022391",
"ENSMUSG00000022070", "ENSMUSG00000022391",
"ENSMUSG00000022391")
edgeWeights <- c(0.13080159, 0.14678129, 0.10697558, 0.12109223,
0.14722505, 0.19004585, 0.08775686, 0.15081269, 0.04768105,
0.21863816, 0.19299134, 0.17825061, 0.18689388, 0.10821313,
0.14221187)
g <- graphNEL(unique(c(from, to)), edgemode="directed")
g <- addEdge(from, to, g)
g <- initEdgeAttribute (g, 'edgeWeight', 'numeric', 0.0)
edgeData(g, from, to, "edgeWeight") <- edgeWeights
edges(g)
eda(g, "edgeWeight")
On Dec 31, 2013, at 1:02 PM, Christopher T Gregg wrote:
> Hi Paul,
>
> Thank you. This did resolve the problem. However, it revealed another issue that is also unclear. Would you mind commenting on the source of this error? Thank you for your help.
>
> best wishes,
> Chris
>
> > from
> [1] "ENSMUSG00000000037" "ENSMUSG00000000037" "ENSMUSG00000000037" "ENSMUSG00000000037" "ENSMUSG00000000037" "ENSMUSG00000004267" "ENSMUSG00000004267"
> [8] "ENSMUSG00000004267" "ENSMUSG00000004267" "ENSMUSG00000016757" "ENSMUSG00000016757" "ENSMUSG00000016757" "ENSMUSG00000019849" "ENSMUSG00000019849"
> [15] "ENSMUSG00000022070"
> > to
> [1] "ENSMUSG00000004267" "ENSMUSG00000016757" "ENSMUSG00000019849" "ENSMUSG00000022070" "ENSMUSG00000022391" "ENSMUSG00000016757" "ENSMUSG00000019849"
> [8] "ENSMUSG00000022070" "ENSMUSG00000022391" "ENSMUSG00000019849" "ENSMUSG00000022070" "ENSMUSG00000022391" "ENSMUSG00000022070" "ENSMUSG00000022391"
> [15] "ENSMUSG00000022391"
> > edgeInteger
> [1] 0.13080159 0.14678129 0.10697558 0.12109223 0.14722505 0.19004585 0.08775686 0.15081269 0.04768105 0.21863816 0.19299134 0.17825061 0.18689388 0.10821313 0.14221187
> > g <- initEdgeAttribute (g, "edgeInteger", "integer", 0)
> > edgeData (g, from, to, "edgeInteger") <- edgeInteger
> Error in .verifyEdges(graph, from, to) :
> edges not found: ‘ENSMUSG00000004267|ENSMUSG00000000037, ENSMUSG00000016757|ENSMUSG00000000037, ENSMUSG00000019849|ENSMUSG00000000037, ENSMUSG00000022070|ENSMUSG00000000037, ENSMUSG00000022391|ENSMUSG00000000037, ENSMUSG00000016757|ENSMUSG00000004267, ENSMUSG00000019849|ENSMUSG00000004267, ENSMUSG00000022070|ENSMUSG00000004267, ENSMUSG00000022391|ENSMUSG00000004267, ENSMUSG00000019849|ENSMUSG00000016757, ENSMUSG00000022070|ENSMUSG00000016757, ENSMUSG00000022391|ENSMUSG00000016757, ENSMUSG00000022070|ENSMUSG00000019849, ENSMUSG00000022391|ENSMUSG00000019849, ENSMUSG00000022391|ENSMUSG00000022070’
>
>
> On Dec 31, 2013, at 1:20 PM, Paul Shannon <paul.thurmond.shannon at gmail.com>
> wrote:
>
>> Hi Christopher,
>>
>> In a moment I will work this through step-by-step, but the solution is almost certain to change
>>
>> g <<- initEdgeAttribute (g, "edgeInteger", "integer", 0)
>>
>> to
>>
>> g <- initEdgeAttribute (g, "edgeInteger", "integer", 0)
>>
>> The use of the global assignment operator is an old bad habit of mine, which you probably picked up from my documentation. I will seek those out, and expunge them!
>>
>> One would expect global assignment, however inelegant, to work in this case. But I have seen that in some occasional circumstances the scoping rules and environment traversal behave oddly. I think that is what you have encountered here. Using the normal assignment operator is the right thing to do.
>>
>> Please let me know how this goes.
>>
>> - Paul
>>
>> On Dec 31, 2013, at 10:33 AM, Christopher T Gregg wrote:
>>
>>> Hi,
>>>
>>> I have encountered an error with RCytoscape that is unclear to me. I have attached our script and data file and sessionInfo (at the bottom of the script) below.
>>>
>>> Our data is an adjacency matrix and we wish to construct a weighted network graph in Cytoscape. I am able to generate the graph object ('g'), which contains the gene names in the @adjMat slot from the adjacency matrix and it will generate a graph in Cytoscape. However, when I attempt to add node and edge attributes to the g object, I get the following error:
>>>
>>>> g <<- initEdgeAttribute (g, "edgeInteger", "integer", 0)
>>>> edgeData (g, from, to, "edgeInteger") <<- edgeInteger
>>> Error in edgeData(g, from, to, "edgeInteger") <<- edgeInteger :
>>> object 'g' not found
>>>
>>> The edgeInteger, from and to variables have the data of interest and the g object is successfully generated (see below), so I can't understand where the error lies. Thank you for any and all help.
>>>
>>> best wishes,
>>> Chris
>>>
>>> #SUCCESSFUL GENERATION OF GRAPH OBJECT and EDGE INTEGER
>>> g <<- new ("graphAM", adjMat = dataNetR, edgemode="weighted")
>>>> g
>>> A graphAM graph with weighted edges
>>> Number of Nodes = 6
>>> Number of Edges = 7.5
>>>> str(g)
>>> Formal class 'graphAM' [package "graph"] with 5 slots
>>> ..@ adjMat : num [1:6, 1:6] 0 0 0 0 0 0 1 0 0 0 ...
>>> .. ..- attr(*, "dimnames")=List of 2
>>> .. .. ..$ : NULL
>>> .. .. ..$ : chr [1:6] "ENSMUSG00000000037" "ENSMUSG00000004267" "ENSMUSG00000016757" "ENSMUSG00000019849" ...
>>> ..@ edgeData :Formal class 'attrData' [package "graph"] with 2 slots
>>> .. .. ..@ data : list()
>>> .. .. ..@ defaults: list()
>>> ..@ nodeData :Formal class 'attrData' [package "graph"] with 2 slots
>>> .. .. ..@ data : list()
>>> .. .. ..@ defaults:List of 1
>>> .. .. .. ..$ nodeChar:Class 'STRING' chr ""
>>> ..@ renderInfo:Formal class 'renderInfo' [package "graph"] with 4 slots
>>> .. .. ..@ nodes: list()
>>> .. .. ..@ edges: list()
>>> .. .. ..@ graph: list()
>>> .. .. ..@ pars : list()
>>> ..@ graphData :List of 1
>>> .. ..$ edgemode: chr "weighted"
>>>
>>>> edgeInteger
>>> [1] 0.13080159 0.14678129 0.10697558 0.12109223 0.14722505 0.19004585 0.08775686 0.15081269 0.04768105 0.21863816 0.19299134 0.17825061
>>> [13] 0.18689388 0.10821313 0.14221187
>>>
>>> Christopher Gregg, PhD.
>>> New York Stem Cell Foundation-Robertson Investigator
>>> Assistant Professor, Neurobiology and Anatomy
>>> Adjunct Assistant Professor, Human Genetics
>>> 323 Wintrobe Bldg 530
>>> University of Utah, School of Medicine
>>> 20 North 1900 East
>>> Salt Lake City, Utah 84132-3401
>>>
>>> phone: (801) 581-8212
>>> fax: (801) 585-9736
>>> ------------------------------------
>>> Gregg Lab Website: www.neuro.utah.edu/labs/gregg/index.html<http://www.neuro.utah.edu/labs/gregg/index.html>
>>>
>>> _______________________________________________
>>> Bioconductor mailing list
>>> Bioconductor at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
>
> Christopher Gregg, PhD.
> New York Stem Cell Foundation-Robertson Investigator
> Assistant Professor, Neurobiology and Anatomy
> Adjunct Assistant Professor, Human Genetics
> 323 Wintrobe Bldg 530
> University of Utah, School of Medicine
> 20 North 1900 East
> Salt Lake City, Utah 84132-3401
>
> phone: (801) 581-8212
> fax: (801) 585-9736
> ------------------------------------
> Gregg Lab Website: www.neuro.utah.edu/labs/gregg/index.html
>
More information about the Bioconductor
mailing list