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

Equal aspect for hic matrix #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Phlya
Copy link

@Phlya Phlya commented Dec 15, 2023

I think equal aspect looks much better for the Hi-C matrix, makes pixels actually square... Perhaps it can be an argument passed to the track, but IMO equal aspect is a better default. What do you think?

@Nanguage
Copy link
Collaborator

Nanguage commented Dec 15, 2023

Hello, I also noticed this issue before. I also believe that setting pixels to be square is a better default value. Unfortunately, I didn't do any Hi-C related work later on, which resulted in a lack of time to maintain this project at the moment. If there are no issues after making the modifications and testing them on your end, please notify me to proceed with the merge. Thank you for your contribution!

@Phlya
Copy link
Author

Phlya commented Dec 15, 2023

I think it works fine for me, the only issue (which is simply the limitations of laws of mathematics) is that with a small height of the track the heatmap might not fill the whole width of the frame...

@Nanguage
Copy link
Collaborator

Can you provide some graphical examples?

@StefanoCretti
Copy link

StefanoCretti commented Jan 8, 2025

Stumbled upon this issue while trying to implement custom matrix tracks for a project I am working on. I think @Phlya is referring to the results which can be obtained from the following snippet of code.

import coolbox.api as ca  # 0.3.8 patched according to @Phlya's suggestion

# File is a subset of the 10kb cooler generated starting from the pairs at
# https://data.4dnucleome.org/files-processed/4DNFIIG4IWKW/
# Can provide if needed, but any region of any file should be the same
COOL_PATH: str = "test_files/chr17_71000000_74000000.cool"
REGION: str = "chr17:71500000-73500000"

frame = ca.ChromName() + ca.Cool(COOL_PATH, height=5) + ca.InsuScore(ca.Cool(COOL_PATH))
fig = frame.plot(REGION)
fig.savefig("test_5.png")

This will yield the following image:

test_5

When the height of the track is too small, the image will not touch the expected borders. This is a major issue when displaying multiple tracks, since they will not be aligned.

On the other hand, by running the same code but with height=20, the result is as follows:

test_20

In this case, since there is enough height, the left and right border will be touched, though there can be some annoying white space below the plot. I could not find an easy way to remove the space and it makes difficult to plot multiple tracks in a compact manner.

My only idea to solve the issue would be to force the track height to be, by default, some function of track width and depth_ratio, which would result in neither of the white spaces. I tried tinkering a bit with it but so far I was not able to come up with a solution, due to the underlying rotated matrix complicating things as well as the interval being internally extended.

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

Successfully merging this pull request may close these issues.

3 participants