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

rows with no 'to' and 'from' but including them in chord diagram #31

Closed
amjass12 opened this issue Aug 22, 2023 · 4 comments
Closed

rows with no 'to' and 'from' but including them in chord diagram #31

amjass12 opened this issue Aug 22, 2023 · 4 comments
Labels
question Further information is requested

Comments

@amjass12
Copy link

amjass12 commented Aug 22, 2023

Hi!

thank you so much for this easy to use package.

I am currently generating a circos from matrix (as its a huge dataset).

Most data have a to and from link. however, there are some points that are present in some of the sectors but dont go anywhere. I would like these to be blank extensions to the sector. I am unsure how to do this in the original raw data which has the following format:

item, from, to, value
'a'.    'one'    'two' 1
etc 

There are situations where, for example, item 'b' is part of track 'one' but doesnt go anywhere. And i would like to see the sector include that data point but without any arrows going to or from that point. So for example, half of or most of that vector would have a to or from data, and the rest of the sector width would be there, but blank.

is this possible?

thank you!

@moshi4
Copy link
Owner

moshi4 commented Aug 22, 2023

It is impossible to satisfy your request with Circos.initialize_from_matrix() which plots a Chord Diagram.
The only way to fulfill your request is to implement the code to define sectors and links by yourself, taking advantage of pyCirclize's API.

With pyCirclize, you can plot sectors and links easily and freely, as shown in the example below.

from pycirclize import Circos

sectors = {"A": 10, "B": 20, "C": 15}
name2color = {"A": "red", "B": "blue", "C": "green"}
circos = Circos(sectors, space=5)
for sector in circos.sectors:
    track = sector.add_track((95, 100))
    track.axis(fc=name2color[sector.name])
    track.text(sector.name, color="white", size=12)
    track.xticks_by_interval(1)

# Plot links in various styles
circos.link(("A", 0, 1), ("A", 7, 8))
circos.link(("A", 1, 2), ("A", 7, 6), color="skyblue")
circos.link(("A", 9, 10), ("B", 4, 3), direction=1, color="tomato")
circos.link(("B", 5, 7), ("C", 6, 8), direction=1, ec="black", lw=1, hatch="//")
circos.link(("B", 18, 16), ("B", 11, 13), r1=90, r2=90, color="violet", ec="red", lw=2, ls="dashed")
circos.link(("C", 1, 3), ("B", 2, 0), direction=1, color="limegreen")
circos.link(("C", 11.5, 14), ("A", 4, 3), direction=2, color="chocolate", ec="black", lw=1, ls="dotted")

circos.savefig("result.png")

result.png

result

@amjass12
Copy link
Author

thank you, yes this is the behavious i am after, however, is it possible to iterate over a row of a dataframe with many thousands of links? the to and from points are strings, not values that can be assigned to the track itself...

@moshi4
Copy link
Owner

moshi4 commented Aug 22, 2023

is it possible to iterate over a row of a dataframe with many thousands of links?

It would be possible to plot thousands of links. However, plotting will take time and the density of links may be too high for an easy-to-read figure.

@amjass12
Copy link
Author

thank you!

@moshi4 moshi4 added the question Further information is requested label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants