GangCaoLab / CoolBox

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

The coordinates of loops are misplaced #45

Closed Linhua-Sun closed 2 years ago

Linhua-Sun commented 3 years ago

I found that the coordinates of loops are misplaced. Just like the following picture: the yellow loop in bedpe is Chr5 16940000 17150000 Chr5 19340000 19550000. I also high light with regions= ["Chr5:16940000-17150000", "Chr5:19340000-19550000"]. Obviously, the position of the loop seems to be misplaced, which is more obvious when I deliberately enlarge the loop

PPP (1)

Nanguage commented 3 years ago

Hi, can you provide some code example let us to reproduce this?

Linhua-Sun commented 3 years ago

Hi, I used following codes.

import coolbox
from coolbox.api import *

Control_cool = "QWQ_MM_Control_10KSm.cool"

regions= ["Chr5:13940000-14150000", "Chr5:8340000-8550000"]
highlights = HighLights(regions, color="green", alpha=0.3)

test=f'/data1/linhua/QIANLAB/PROJECT/hic/JointView/1.bedpe'

frameD = XAxis() + Cool(Control_cool,style='matrix',balance=True,normalize="expect",transform=False, norm=False, max_value=6, min_value=-2)+ \
        HiCPeaksCoverage(test, color="black",style='hicpeaks',line_width=5,side="both") + \
        highlights

frameD.plot("Chr5:8000000-15000000")

And bedpe file only have a line.

!cat /data1/linhua/QIANLAB/PROJECT/hic/JointView/1.bedpe
Chr5    13940000    14150000    Chr5    8340000 8550000

The QWQ_MM_Control_10KSm.cool file is the cooler file of Hi-C datasets of Arabidopsis at 10 kb resolution. If you need it, I can also send it you. May be by e-mail? I have also attached the output picture.

BUG loops

zhqu1148980644 commented 3 years ago

Another runnable script to reproduce this bug in the online binder.

import sys
sys.path.insert(0, "../")
from coolbox.api import *

with open('test.bed', 'w') as f:
    f.write("chr9\t4520000\t4630000\tchr9\t4520000\t4630000")

DATA_DIR = f"test_data"
test_interval = "chr9:4000000-6000000"
test_itv = test_interval.replace(':', '_').replace('-', '_')

regions= ["chr9:4520000-4630000", "chr9:8340000-8550000"]

cool1 = Cool(f"{DATA_DIR}/cool_{test_itv}.mcool", cmap="JuiceBoxLike", style='matrix', color_bar='vertical')
with TrackHeight(2):
    frame = XAxis() + \
        cool1 + Title("Hi-C(.cool)") + \
        HighLights(regions, color="green", alpha=0.3) +  \
        HiCPeaksCoverage('test.bed')
frame.properties['width'] = 45
bsr = Browser(frame)
bsr.goto(test_interval)
bsr.show()
Nanguage commented 3 years ago

This has been fixed.

import sys
sys.path.insert(0, "../")
import os
from coolbox.api import *

cool_path = "./test_data/cool_chr9_4000000_6000000.mcool"
test_interval = "chr9:4000000-6000000"

s1, e1, s2, e2 = [4200000, 4300000, 4500000, 4800000]

test_bedpe = "./test.bedpe"
with open(test_bedpe, 'w') as f:
    f.write(f"chr9\t{s1}\t{e1}\tchr9\t{s2}\t{e2}\n")
os.system("rm ./test.bedpe.bgz*")

regions = [f"chr9:{s1}-{e1}", f"chr9:{s2}-{e2}"]

hicp = HiCPeaksCoverage(test_bedpe)

frame = XAxis() + Cool(cool_path, style="matrix") + hicp
frame *= HighLights(regions, color="green", alpha=0.3)
frame *= Vlines(['chr9:5000000-5000000'])
frame.plot(test_interval)

style='matrix'

image

style='triangular'

image

style='window'

image

This fix will publish in the next version

Linhua-Sun commented 3 years ago

Thank you very much for your work and look forward to the next version of the software.