So, I have a networkx.classes.graph.Graph objects with nodes and edges
(nx). I have pydot and pygraphviz installed and available. I try to
get the positions for the nodes with the following commands:
>>> from networkx import graphviz_layout
>>> pos=nx.graphviz_layout(nw,prog="dot")
but this results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/site-packages/networkx-1.1.dev-
py2.6.egg/networkx/drawing/nx_agraph.py", line 229, in graphviz_layout
return pygraphviz_layout(G,prog=prog,root=root,args=args)
File "/usr/local/lib/python2.6/site-packages/networkx-1.1.dev-
py2.6.egg/networkx/drawing/nx_agraph.py", line 260, in
pygraphviz_layout
A=to_agraph(G)
File "/usr/local/lib/python2.6/site-packages/networkx-1.1.dev-
py2.6.egg/networkx/drawing/nx_agraph.py", line 147, in to_agraph
A.add_node(n,**nodedata)
File "/usr/local/lib/python2.6/site-packages/pygraphviz-0.99.1-py2.6-
linux-i686.egg/pygraphviz/agraph.py", line 223, in add_node
node.attr.update(**attr)
File "/usr/local/lib/python2.6/UserDict.py", line 164, in update
self.update(kwargs)
File "/usr/local/lib/python2.6/UserDict.py", line 156, in update
self[k] = v
File "/usr/local/lib/python2.6/site-packages/pygraphviz-0.99.1-py2.6-
linux-i686.egg/pygraphviz/agraph.py", line 1586, in __setitem__
raise "Attribute value must be a string"
TypeError: exceptions must be classes or instances, not str
Am I doing something wrong here or is there something wrong with the
install?
It might be a bug - we fixed some related bugs with
string attribute handling (e.g.
https://networkx.lanl.gov/trac/changeset/1485
)
Can you send the version information?
$ python -c "import networkx;print networkx.__version__"
$ python -c "import pygraphviz;print pygraphviz.__version__"
Aric
> python -c "import networkx;print networkx.__version__"
1.1.dev1519
> python -c "import pygraphviz;print pygraphviz.__version__"
0.99.1
Its weird, because I can run the circular tree example, which uses
graphviz for its layout, with no problem.
On Feb 23, 5:32 pm, Aric Hagberg <ahagb...@gmail.com> wrote:
> On Tue, Feb 23, 2010 at 6:24 AM, nickschurch <nickschu...@googlemail.com> wrote:
> > I'm having some problems getting graphvis layout to work on my data.
> > What I have is a bunch of connected GO term nodes so ideally I want a
> > tree-type network plot.
>
> >>>> from networkx import graphviz_layout
> >>>> pos=nx.graphviz_layout(nw,prog="dot")
>
> > but this results in:
>
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > File "/usr/local/lib/python2.6/site-packages/networkx-1.1.de>
> > Am I doing something wrong here or is there something wrong with the
> > install?
>
> It might be a bug - we fixed some related bugs with
> string attribute handling (e.g.https://networkx.lanl.gov/trac/changeset/1485
Try updating to the dev version of PyGraphviz.
http://networkx.lanl.gov/download/pygraphviz/
If that doesn't fix it could you send a small example that
shows the problem?
Aric
--------------------------
>>> import networkx as nx
>>> from networkx import graphviz_layout
>>> pos=nx.graphviz_layout(nw,prog="dot")
Warning: graph has 4859 nodes...layout may take a long time.
/usr/local/lib/python2.6/site-packages/pygraphviz-1.0.dev-py2.6-linux-
i686.egg/pygraphviz/agraph.py:1168: RuntimeWarning: Error:
gvwrite_no_z problem 18484
warnings.warn("".join(errors),RuntimeWarning)
Warning: syntax error in line 124 near ''
Segmentation fault
------------------------------
I guess I can put up a file or two as an example of the error...
On Feb 24, 2:10 pm, Aric Hagberg <ahagb...@gmail.com> wrote:
> On Wed, Feb 24, 2010 at 7:01 AM, nickschurch <nickschu...@googlemail.com> wrote:
> > Hi Aric - here is the info:
>
> >> python -c "import networkx;print networkx.__version__"
> > 1.1.dev1519
> >> python -c "import pygraphviz;print pygraphviz.__version__"
> > 0.99.1
>
> > Its weird, because I can run the circular tree example, which uses
> > graphviz for its layout, with no problem.
>
> Try updating to the dev version of PyGraphviz.http://networkx.lanl.gov/download/pygraphviz/
Do the tests run OK?
>>> import pygraphviz
>>> pygraphviz.test()
Aric
i.e. for each node, i do: nw.add_node(node,genes=geneids)
When I try
>>> pos=nx.graphviz_layout(nw,prog="dot")
I get a segfault, but when I define a new object and addthe nodes and
edges contained within nw, its no problem!
>>> GD=nx.DiGraph()
>>> GD.add_nodes_from(nw.nodes())
>>> GD.add_edges_from(nw.edges())
>>> pos=nx.graphviz_layout(DG,prog="dot")
Warning: graph has 4859 nodes...layout may take a long time.
>>> nx.draw(DG, pos)
So the only thing I can think is that the additional info on the nodes
is causing the problem....
On Feb 24, 4:18 pm, Aric Hagberg <ahagb...@gmail.com> wrote:
I'm glad you were able to track down the source of your problem.
However, had you posted a minimal example which produced the error, I
think diagnosis would have been much simpler (and quicker).
Strictly for informational purposes, what was an example of a
problematic geneid (that maps to a given GO term)?
Chris
I understand, and it was in the process of putting together a minimal
example that I found the problem! I still don't know why it causes the
problem though, since the manual suggests you can attach any arbitrary
information as a node attribute. I didn't post the full code initially
because is part of a large code (which actually makes it kind of hard
to distil into a minimal example I found) and the data that it
operates on is not my own, and I thus I have to treat as confidential.
> Strictly for informational purposes, what was an example of a
> problematic geneid (that maps to a given GO term)?
The geneids are Entrez ID in a list - so an example of the gene ids
for a given GO term would be:
geneids=['100134991','443540','744399']
Could it be a problem that the attribute is not a single entity but a
list?
Nick
In principle, NetworkX can definitely handle that kind of node data. If
you are able to get a minimal example, post it online. You should be
able to reduce it and reduce it...and even change the data so as to keep
confidentiality.
In [1]: import networkx as nx
In [2]: g = nx.Graph()
In [3]: g.add_node('A', genes=['100134991','443540','744399'])
In [4]: g.node
Out[4]: {'A': {'genes': ['100134991', '443540', '744399']}}
Chris
On Feb 26, 3:38 am, Christopher Ellison <celli...@cse.ucdavis.edu>
wrote:
Download file a gunzip it. Then, in python:
>>> # load data
>>> import cPickle
>>> file=open("savenet_temp.pkl","r")
>>> datastore=cPickle.load(file)
>>> file.close()
>>>
>>> # import networkx stuff
>>> import networkx as nx
>>> from networkx import graphviz_layout
>>>
>>> # calculate positions for graph without metadata <- this should work no problem!
>>> pos=nx.graphviz_layout(datastore["without_metadata"],prog="dot")
>>> pos
[output] (something like....)
{'GO:0032774': (906.0, 162.0), 'GO:0019222': (529.0, 450.0), 'GO:
0016310': (1506.0, 90.0), 'GO:0031323': (384.0, 378.0), 'GO:0044249':
(853.0, 378.0), 'GO:0045449': (605.0, 90.0), 'GO:0007165': (240.0,
378.0), 'GO:0034645': (1038.0, 306.0), 'GO:0009799': (80.0, 378.0),
'GO:0043170': (1067.0, 450.0), 'GO:0007275': (178.0, 522.0), 'GO:
0006139': (856.0, 306.0), 'GO:0044260': (1139.0, 378.0), 'GO:0007368':
(64.0, 234.0), 'GO:0050789': (529.0, 522.0), 'GO:0019219': (673.0,
234.0), 'GO:0010467': (1282.0, 378.0), 'GO:0009855': (64.0, 306.0),
'GO:0065007': (529.0, 594.0), 'GO:0031326': (387.0, 306.0), 'GO:
0034960': (1323.0, 306.0), 'GO:0034961': (1129.0, 234.0), 'GO:
0043284': (1180.0, 306.0), 'GO:0032502': (168.0, 594.0), 'GO:0006468':
(1578.0, 18.0), 'GO:0032501': (310.0, 594.0), 'GO:0044267': (1600.0,
234.0), 'GO:0060255': (673.0, 378.0), 'GO:0043687': (1651.0, 90.0),
'GO:0009987': (384.0, 522.0), 'GO:0009889': (529.0, 378.0), 'GO:
0006464': (1651.0, 162.0), 'GO:0050794': (384.0, 450.0), 'GO:0007389':
(88.0, 450.0), 'GO:0009058': (710.0, 450.0), 'GO:0009059': (996.0,
378.0), 'GO:0008150': (419.0, 666.0), 'GO:0008152': (781.0, 522.0),
'GO:0007154': (241.0, 450.0), 'GO:0043283': (1713.0, 378.0), 'GO:
0016070': (856.0, 234.0), 'GO:0044238': (1571.0, 378.0), 'GO:0007242':
(206.0, 306.0), 'GO:0019538': (1651.0, 306.0), 'GO:0051252': (764.0,
162.0), 'GO:0043412': (1742.0, 234.0), 'GO:0044237': (853.0, 450.0),
'GO:0010468': (673.0, 306.0), 'GO:0006355': (764.0, 18.0), 'GO:
0006796': (1506.0, 306.0), 'GO:0010556': (530.0, 306.0), 'GO:0006350':
(1049.0, 162.0), 'GO:0006351': (906.0, 90.0), 'GO:0006793': (1427.0,
378.0)}
>>> # calculate positions for graph with metadata <- this should segfault.
>>> pos=nx.graphviz_layout(datastore["with_metadata"],prog="dot")
[output]
Warning: syntax error in line 233 near ''
Segmentation fault
Hi Nick,
Thanks for uploading the example. I was able to run your example on
both graphs without issue. So perhaps there is some difference in the
versions of the software we are running. It would be nice to get a
second confirmation from another user on the list too.
Here is what I have:
$ python -c "import networkx as nx; print nx.__version__"
1.1.dev1519
$ python -c "import pygraphviz as p; print p.__version__"
1.0.dev1519
$ dot -V
dot - Graphviz version 2.20.2 (Wed Sep 16 11:12:11 UTC 2009)
Chris
$ python -c "import networkx as nx; print nx.__version__"
1.1.dev1519
$ python -c "import pygraphviz as p; print p.__version__"
1.0.dev
$ dot -V
dot - graphviz version 2.22.0 (20090304.0156)
I'm not quite sure why my version of pygraphviz doesn't show a number
after the dev declaration - the package I updated from was
pygraphviz-1.0.dev1521 which is a small increment up from yours
(although I note there is a 1529 on the website now) - could this be
making the difference?. My dot install seems marginally newer too, but
given that its functionality has been aroudn for a while I don't
imagine this is the problem.
Nick
On Mar 3, 6:43 pm, Christopher Ellison <celli...@cse.ucdavis.edu>
wrote:
I have an edgelist see attached file. This edgelist has a third column which the diagonal of the adjacency matrix.
Is possible to read this edgefile with a routine in NetworkX.
Cheers
Just thought I'd bump this back up the list to see if we can find a
solution....
I tried to load your files but apparently you are using numpy
objects in your data and I don't have the same version of numpy
as you do (or some other related problem).
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle
>>> file=open("savenet_temp.pkl","r")
>>> datastore=cPickle.load(file)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: can't handle version -1 of numpy.dtype pickle
Aric
On 8 Mar, 15:49, Aric Hagberg <ahagb...@gmail.com> wrote:
It doesn't matter if you load numpy first. I have numpy-1.3.0.
If it is possible to make a very small (text) example to show the problem
that would help.
Aric
http://software-carpentry.org/
>
> Cheers,
>
> Fred
>
> ________________________________
> Hotmail: Free, trusted and rich email service. Get it now.
>
> --
> You received this message because you are subscribed to the Google Groups
> "networkx-discuss" group.
> To post to this group, send email to networkx...@googlegroups.com.
> To unsubscribe from this group, send email to
> networkx-discu...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/networkx-discuss?hl=en.
>
--
What I want is muscles of iron and nerves of steel, inside which
dwells a mind of the same material as that of which the thunderbolt is
made
--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.