moshi4 / pyCirclize

Circular visualization in Python (Circos Plot, Chord Diagram, Radar Chart)
https://moshi4.github.io/pyCirclize/
MIT License
758 stars 47 forks source link

cannot import name 'SimpleLocation' from 'Bio.SeqFeature' #54

Closed erinyoung closed 9 months ago

erinyoung commented 9 months ago

I've been trying to get pyCirclize to work, but I've run into an error. I feel like I've installed something wrong.

Traceback (most recent call last):
  File "/Volumes/IDGenomics_NAS/Bioinformatics/eriny/CirculoCov/moshi_test.py", line 1, in <module>
    from pycirclize import Circos
  File "/home/eriny/.local/lib/python3.10/site-packages/pycirclize/__init__.py", line 1, in <module>
    from pycirclize.circos import Circos
  File "/home/eriny/.local/lib/python3.10/site-packages/pycirclize/circos.py", line 24, in <module>
    from pycirclize.parser import Bed, Matrix
  File "/home/eriny/.local/lib/python3.10/site-packages/pycirclize/parser/__init__.py", line 2, in <module>
    from pycirclize.parser.genbank import Genbank
  File "/home/eriny/.local/lib/python3.10/site-packages/pycirclize/parser/genbank.py", line 13, in <module>
    from Bio.SeqFeature import Seq, SeqFeature, SimpleLocation
ImportError: cannot import name 'SimpleLocation' from 'Bio.SeqFeature' (/home/eriny/.local/lib/python3.10/site-packages/Bio/SeqFeature.py)

I have pyCirclize version 1.2.0, BioPython version 1.79, and am working under python version 3.10.

I installed pyCirclize into my virtual environment with pip install pycirclize --user.

This is the script that I was trying to run (it's from https://github.com/moshi4/pyCirclize/issues/51).

from pycirclize import Circos
import pandas as pd
import random
random.seed(0)

# Random generate coverage dataframe
chr_size = 6554127
interval = 500
df = pd.DataFrame(
    data=[
        [1, interval * i + 1, interval * (i + 1), random.randint(50, 200)] for i in range(int(chr_size / interval))
    ],
    columns=["chr", "start", "end", "mean_depth"]
)
print(df)

circos = Circos(sectors={"1": chr_size})

for sector in circos.sectors:
    track1 = sector.add_track((65, 70))
    track1.axis()

    chr_df = df[df["chr"].astype(str) == sector.name]
    x = ((chr_df["end"] + chr_df["start"]) / 2).to_numpy()
    y = chr_df["mean_depth"].to_numpy()

    track2 = sector.add_track((70, 100), r_pad_ratio=0.1)
    track2.fill_between(x, y, color="skyblue")

circos.savefig("example.png")
erinyoung commented 9 months ago

Nevermind! I spun up a new environment with python 3.11 and everything worked fine.