GangCaoLab / CoolBox

Jupyter notebook based genomic data visualization toolkit.
https://gangcaolab.github.io/CoolBox/index.html
GNU General Public License v3.0
224 stars 37 forks source link

Requesting Assistance with CoolBox Visualization - Achieving A/B compartments #84

Open wbszhu opened 1 year ago

wbszhu commented 1 year ago

I am currently using CoolBox for visualization purposes and I would like to achieve a visual effect similar to the provided image. I am seeking guidance on how to proceed and I was wondering if you could provide some example code to help me achieve this effect. image I will appreciate any help or insights you can provide to assist me in achieving the desired visual effect. Thank you in advance for your assistance!

zhqu1148980644 commented 1 year ago

To complete this task, you will need some knowledge of Python coding. You can subclass the Cool class to create a new class or track called Com that will display A/B compartment. You will need to implement the fetch_data method in the Com class to return the A/B compartment matrix.

Here is an example code:

class Com(Cool):
      def fetch_data(self, gr1, gr2):
          # 1. fetch compartment matrix for the entire chromosome range
          # 2. subrange the matrix in gr1 and gr2

You can refer to the source codes of Cool to learn how to extract raw matrix from a cooler file. You can find it here: https://github.com/GangCaoLab/CoolBox/blob/36a86b20e032c6200d6f4077a5b241c0dbda2a78/coolbox/core/track/hicmat/cool.py#L37C1-L47C39

wbszhu commented 1 year ago

Thanks for your reply, I'll try it out.