Open Linhua-Sun opened 3 years ago
Technically YES. The design of CoolBox follows an object-oriented design. So you need to make a custom track and manually return your merged matrix in numpy.ndarray
format. here is a custom example.
In practical, you can use array mask to compose these two sample like this:
And, even you can use two different colormap in one matrix:
Thnaks for your feature request, I think this should be a built-in track type in the next version.
Here is a quick example:
from coolbox.api import *
class MergedCool(Cool):
def __init__(self, cool1, cool2, **kwargs):
super().__init__(cool1, **kwargs)
self.cool1 = Cool(cool1, **kwargs)
self.cool2 = Cool(cool2, **kwargs)
def fetch_data(self, gr1, **kwargs):
import numpy as np
up = self.cool1.fetch_data(gr1, **kwargs)
low = self.cool2.fetch_data(gr1, **kwargs)
merged = np.triu(up) + (np.tril(low) * 100) # * 100 is for letting the figure shows the difference
return merged
DATA_DIR = f"test_data"
test_interval = "chr9:4000000-6000000"
test_itv = test_interval.replace(':', '_').replace('-', '_')
COOL = f"{DATA_DIR}/cool_{test_itv}.mcool"
merged_cool = MergedCool(cool1=COOL, cool2=COOL, style='matrix', color_bar='vertical')
with TrackHeight(2):
frame = XAxis() + merged_cool + Title("Hi-C(.cool)")
frame.goto(test_interval)
frame.plot()
This is so great, thank you very much for your reply, perfectly solved my problem, thank you!
possible syntax in future:
cool1 / cool2
Can I use this tool to draw a Hi-C heatmap, and the lower left corner corresponds to the wild type situation and the upper right corner to the mutant situation?
-split : Creates non-symmetric matrices where the lower left represents the first experiment and the upper-right represents the 2nd experiment. This methods is probably the sensitive (visually) for spotting differences between experiments. If additional experiments are provided, the 3rd and 4th will be split beneath the first two, and so on.
like the map from homer2 (http://homer.ucsd.edu/homer/interactions2/HiCmatrices.html)