Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'networkx' has no attribute 'write_gpickle' #7

Open
XuanZhang-Black opened this issue Mar 4, 2024 · 7 comments
Open

module 'networkx' has no attribute 'write_gpickle' #7

XuanZhang-Black opened this issue Mar 4, 2024 · 7 comments

Comments

@XuanZhang-Black
Copy link

Hi Alex,

I confirmed that my networkx version is 3.1 and installed all the dependencies using conda. But when I run the following command syngraph build -d full_table/ -m -o test, I get an error: Traceback (most recent call last):
File "/home/data/t240413/software/syngraph-master/syngraph", line 7, in < module>
main()
File "/home/data/t240413/software/syngraph-master/cli/interface.py", line 39, in main
build.main(run_params)
File "/home/data/t240413/software/syngraph-master/cli/build.py", line 61, in main
graph_file = syngraph.save(parameterObj, check_consistency=True, with_ancestors=False)
File "/home/data/t240413/software/syngraph-master/source/syngraph.py", line 861, in save
nx.write_gpickle(self, graph_file)
AttributeError: module 'networkx' has no attribute 'write_gpickle'
I don't know how to run it successfully.
Another question, about the *.full_table.tsv file, I would like to know whether the start and end position of each gene should be the continuous start and end position on the whole genome or the start and end position on each chromosome?
Looking forward to your reply!

Best wishes!

Sincerely,
Xuan Zhang

@A-J-F-Mackintosh
Copy link
Owner

Hi Xuan Zhang,

I wrote syngraph using networkx=2.4, so I would recommend installing that version via conda. I have included a yaml file in this repo that can be used to generate the conda env I used for development.

Please let me know whether this fixes the problem, and if so I will edit the docs to include networkx=2.4.

If I understand your second question correctly, you should just use chromosome coordinate system, no need to convert to a 'whole genome' coordinate system.

Cheers,

Alex

@XuanZhang-Black
Copy link
Author

Hi Alex,

This is indeed the problem, I used networkx=2.4 to solve the error, but syngraph still can not run properly, then I used the yaml file you gave, using the command “conda env create -f syngraph.yaml” to create the same environment as yours,and I made sure I replaced the conda environment path in the yaml file with my own. But there are many conflicts between packages: Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort. failed | |

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package pypy3.7 conflicts for:
setuptools==46.1.1=py38_0 -> certifi[version='>=2016.9.26'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
graph-tool-base==2.45=py38hba1c032_2 -> boost[version='>=1.74.0,<1.74.1.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.7|>=7.3.5|>=7.3.4']
more-itertools==8.5.0=py_0 -> python[version='>=3.4'] -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
fonttools==4.37.4=py38h0a891b7_0 -> unicodedata2[version='>=14.0.0'] -> pypy3.7[version='>=7.3.7']
certifi==2022.9.24=pyhd8ed1ab_0 -> python[version='>=3.7'] -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
networkx==2.4=py_0 -> python[version='>=3.5'] -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.|>=7.3.7|>=7.3.5|>=7.3.3']
cycler==0.10.0=py_2 -> python -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
packaging==21.3=pyhd8ed1ab_0 -> python[version='>=3.6'] -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
nlopt==2.7.0=py38hd6d24a2_0 -> numpy[version='>=1.16.5,<2.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
tqdm==4.43.0=py_0 -> python -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
pytz==2019.3=py_0 -> python -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
decorator==4.4.2=py_0 -> python -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
boost==1.74.0=py38h2b96118_5 -> numpy[version='>=1.18.5,<2.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
glib==2.74.0=h6239696_0 -> python= -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
pygobject==3.42.2=py38h3be095d_0 -> pycairo -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.7']
wheel==0.34.2=py38_0 -> setuptools -> pypy3.7[version='>=7.3.3|>=7.3.5|>=7.3.7']
pycparser==2.21=pyhd8ed1ab_0 -> python[version='2.7.|>=3.4'] -> pypy3.7[version='7.3.3.|7.3.4.|7.3.5.|7.3.7.']
mkl_fft==1.0.15=py38ha843d7b_0 -> numpy[version='>=1.11.3,<2.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
graph-tool==2.45=py38h7041675_2 -> matplotlib-base -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
ete3==3.1.1=pyhf5214e1_0 -> lxml -> pypy3.7[version='7.3.3.
|7.3.4.|7.3.5.|7.3.7.|>=7.3.3|>=7.3.7|>=7.3.5|>=7.3.4']
pandas==1.0.3=py38h0573a6f_0 -> numpy[version='>=1.14.6,<2.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
scipy==1.4.1=py38h0b6359f_0 -> numpy[version='>=1.14.6,<2.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
matplotlib-base==3.6.0=py38hb021067_0 -> certifi[version='>=2020.06.20'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
seaborn==0.10.1=py_0 -> matplotlib[version='>=2.1.2'] -> pypy3.7[version='7.3.3.
|7.3.4.|7.3.5.|7.3.7.|>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
matplotlib==3.6.0=py38h578d9bd_0 -> tornado -> pypy3.7[version='>=7.3.3|>=7.3.7']
zstandard==0.18.0=py38h0a891b7_0 -> cffi[version='>=1.8'] -> pypy3.7[version='7.3.3.
|7.3.4.|7.3.5.|7.3.7.']
python-dateutil==2.8.1=py_0 -> python -> pypy3.7[version='7.3.3.
|7.3.4.|7.3.5.|7.3.7.']
contourpy==1.0.5=py38h43d8883_0 -> numpy[version='>=1.16'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
pip==20.0.2=py38_1 -> setuptools -> pypy3.7[version='>=7.3.3|>=7.3.5|>=7.3.7']
pyparsing==2.4.6=py_0 -> python -> pypy3.7[version='7.3.3.
|7.3.4.|7.3.5.|7.3.7.']
mkl_random==1.1.0=py38h962f231_0 -> numpy[version='>=1.11.3,<2.0a0'] -> pypy3.7[version='>=7.3.3|>=7.3.4|>=7.3.5|>=7.3.7']
munkres==1.1.4=pyh9f0ad1d_0 -> python -> pypy3.7[version='7.3.3.
|7.3.4.|7.3.5.|7.3.7.*']

Package libnsl conflicts for:
python_abi==3.8=1_cp38 -> python=3.8 -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
tqdm==4.43.0=py_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
fonttools==4.37.4=py38h0a891b7_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pyqtwebengine==5.12.1=py38h7400c14_7 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pygraphviz==1.9=py38he170440_2 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
graph-tool-base==2.45=py38hba1c032_2 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
matplotlib-base==3.6.0=py38hb021067_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pytz==2019.3=py_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
decorator==4.4.2=py_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
nlopt==2.7.0=py38hd6d24a2_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pycparser==2.21=pyhd8ed1ab_0 -> python[version='2.7.*|>=3.4'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pillow==9.2.0=py38ha3b2c9c_2 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
numpy-base==1.18.1=py38hde5b4d6_1 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pandas==1.0.3=py38h0573a6f_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
ete3==3.1.1=pyhf5214e1_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pyparsing==2.4.6=py_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
tornado==6.0.4=py38h1e0a361_1 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
python-dateutil==2.8.1=py_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
glib==2.74.0=h6239696_0 -> python= -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
matplotlib==3.6.0=py38h578d9bd_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
mkl-service==2.3.0=py38he904b0f_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
lxml==4.5.0=py38hefd8a0e_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
networkx==2.4=py_0 -> python[version='>=3.5'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pip==20.0.2=py38_1 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
zstandard==0.18.0=py38h0a891b7_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
libnsl==2.0.0=h7f98852_0
contourpy==1.0.5=py38h43d8883_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
kiwisolver==1.1.0=py38hbf85e49_1 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
munkres==1.1.4=pyh9f0ad1d_0 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pyqt5-sip==4.19.18=py38h709712a_7 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
docopt==0.6.2=py38_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
mkl_random==1.1.0=py38h962f231_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
python==3.8.12=hf930737_2_cpython -> libnsl[version='>=2.0.0,<2.1.0a0']
pyqtchart==5.12=py38h7400c14_7 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pycairo==1.21.0=py38h9c00e7a_1 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
boost==1.74.0=py38h2b96118_5 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
cffi==1.15.1=py38h4a40e3a_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pyqt-impl==5.12.3=py38h7400c14_7 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
mkl_fft==1.0.15=py38ha843d7b_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
scipy==1.4.1=py38h0b6359f_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
wheel==0.34.2=py38_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
graph-tool==2.45=py38h7041675_2 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
six==1.14.0=py38_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
unicodedata2==14.0.0=py38h0a891b7_1 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pygobject==3.42.2=py38h3be095d_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
numpy==1.20.3=py38h9894fe3_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
seaborn==0.10.1=py_0 -> python[version='>=3.6'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
more-itertools==8.5.0=py_0 -> python[version='>=3.4'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
sip==4.19.13=py38he6710b0_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
certifi==2022.9.24=pyhd8ed1ab_0 -> python[version='>=3.7'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
pyqt==5.12.3=py38h578d9bd_7 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
setuptools==46.1.1=py38_0 -> python[version='>=3.8,<3.9.0a0'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
cycler==0.10.0=py_2 -> python -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']
packaging==21.3=pyhd8ed1ab_0 -> python[version='>=3.6'] -> libnsl[version='>=2.0.0,<2.1.0a0|>=2.0.1,<2.1.0a0']

Package _openmp_mutex conflicts for:
lcms2==2.12=hddcbb42_0 -> libgcc-ng[version='>=9.3.0'] -> _openmp_mutex[version='>=4.5']
epoxy==1.5.10=h166bdaf_1 -> libgcc-ng[version='>=10.3.0'] -> _openmp_mutex[version='>=4.5']
openjpeg==2.5.0=h7d73246_1 -> libgcc-ng[version='>=12'] -> _openmp_mutex[version='>=4.5']
libwebp-base==1.2.4=h166bdaf_0 -> libgcc-ng[version='>=12'] -> _openmp_mutex[version='>=4.5']
pyqtchart==5.12=py38h7400c14_7 -> libgcc-ng[version='>=9.3.0'] -> _openmp_mutex[version='>=4.5']
libcups==2.3.3=h3e49a29_2 -> libgcc-ng[version='>=12'] -> _openmp_mutex[version='>=4.5']
gdk-pixbuf==2.42.8=hff1cb4f_1 -> libgcc-ng[version='>=12'] -> _openmp_mutex[version='>=4.5']
pygobject==3.42.2=py38h3be095d_0 -> libgcc-ng[version='>=12'] -> _openmp_mutex[version='>=4.5']
Now I don't know how to solve this error.
Looking forward to your reply!

Best wishes!

Sincerely,
Xuan Zhang

@A-J-F-Mackintosh
Copy link
Owner

Hi Xuan Zhang,

'This is indeed the problem, I used networkx=2.4 to solve the error, but syngraph still can not run properly,'

What was the error message? Perhaps it can solved without the need for a new yaml file.

Best,

Alex

@XuanZhang-Black
Copy link
Author

Hi Alex,

I reinstalled numpy=1.20.3=py38h9894fe3_0 and was able to successfully run syngraph in my own conda env.

But the test.rearrangements.tsv file that I generated after running it was empty and I don't know what went wrong. My busco_full_table.tsv was generated by using BUSCO v5.6.1 to evaluate the pep.fa files of each genome in prot mode, and then I named them as A_a.full_table.tsv.... I put 9 *.full_table.tsv files in the folder full_table/ , and then run "syngraph build -d full_table/ -m -o test" successfully to produce the test.pickle file; In the second step, I ran "syngraph infer -g test.pickle -t newick.txt -r 2 -s A_a -o test" to generate an empty test.rearrangements.tsv file. My tree file is generated by iqtree2 with the protein sequences of 9 species, A_a is also a leaf in the newick tree. And the number of chromosomes in my nine species is different, and some species have revealed chromosomal fusion events in other studies (using syngraph).
Is it because I don't have a specific value of -m? But when I set -m 5 (command: syngraph build -d full_table/ -m 5 -o test), the program automatically stops and echo: Usage: syngraph build -d

[-o -m -h]

Best,

Xuan Zhang

@A-J-F-Mackintosh
Copy link
Owner

Hi Xuan Zhang,

To prepare input for syngraph with BUSCO you should run the tool on your genome, not the proteins.

Note that -m INT adds a minimum threshold to syngraph infer, but has a different meaning when running syngraph build (it allows missingness).

Cheers,

Alex

@marcelauliano
Copy link

Hi Alex,
I just also want to state I had the same installation problems. Basically, I created a conda env, which as a default now creates a python3.9. The thing is that, the code needs numpy 1.20.3, which only works with python3.8. So I needed to downgrade de python version. What I did that worked just now bulding syngraphs is this:

1-) create a conda env with python=3.8
1.1) Activate env then install:
2-) numpy=1.20.3=py38h9894fe3_0
3-) networkx=2.4 pandas docopt ete3 pygraphviz matplotlib

But! All that installed, I still met another dependency, more_itertools. So I did:

4-) pip install more_itertools

With the instructions to create the conda env as they are now, people are going to have a higher version of numpy which doesn't work with the code.

I also tried to use the yml file and couldn't create a conda from it because of many inconsistencies as Zhang mentioned.

Thank you so much!

@A-J-F-Mackintosh
Copy link
Owner

Hi Marcela,

Thanks for the feedback about installation. Putting those steps into a single conda / mamba command gives an env that supports both syngraph build and infer. I have added it to the README.

mamba install pandas docopt ete3 pygraphviz matplotlib tqdm networkx=2.4 numpy=1.20.3=py38h9894fe3_0 python=3.8 more-itertools

The viz module requires graph-tool, so this could also be added to the above command, although viz is a work in progress and not well tested.

More generally, please do let me know how you get on with syngraph. I have tested the tool with lepidoptera, nematodes, and simulations, and think that it will work well in certain cases but not others (see the preprint for more details).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants