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

How can I add small circles of different sizes in each grid of a heatmap? #69

Closed
wyxxxj opened this issue May 19, 2024 · 2 comments
Closed
Labels
question Further information is requested

Comments

@wyxxxj
Copy link

wyxxxj commented May 19, 2024

Can we add circles of different sizes in each grid of a heatmap? If so, could you please provide an example? Thank you!
JOH-1

@moshi4
Copy link
Owner

moshi4 commented May 19, 2024

Hi @wyxxxj,

Although I could not plot a similar legend, it was possible to plot circles of different sizes on the heatmap grid.
It seems difficult to set the appropriate circle size, so it would be a challenge to visualize the analysis results in this plot format. Due to the difficulty of the plot, I do not intend to provide further support, but good luck.

Code Example

from pycirclize import Circos
import numpy as np
np.random.seed(0)

# Create 10 - 100 random values (8 x 80) 2d-array
darray = np.random.randint(10, 100 + 1, (8, 80))

# Plot heatmap
x_size, y_size = darray.shape[1], darray.shape[0]
circos = Circos(dict(heatmap=x_size))
sector = circos.sectors[0]
track = sector.add_track((50, 100))
track.heatmap(darray, vmin=0, vmax=100, cmap="Oranges")

# Plot circle on heatmap rect
for i in range(y_size):
    for j in range(x_size):
        v = darray[i][j]
        x, y = j + 0.5, y_size - i - 0.5
        # Circle size(s) is defined based on 2d-array value
        # In the actual data analysis, some sort of correction would need to be applied to determine the circle size.
        track.scatter([x], [y], s=v, vmin=0, vmax=y_size, fc="none", ec="black", lw=0.5)

circos.savefig("example.png")

example.png

example

@moshi4 moshi4 closed this as completed May 21, 2024
@moshi4 moshi4 added the question Further information is requested label May 21, 2024
@wyxxxj
Copy link
Author

wyxxxj commented May 25, 2024

Thank you very much for your reply!I have successfully drawn the graph!

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