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

A few bugs in loops (arcs) and Hi-C Heatmap body. #70

Open Linhua-Sun opened 2 years ago

Linhua-Sun commented 2 years ago

Hi @Nanguage

Question 1 and 2

I am trying to use CoolBox to plot loops above the heatmap like JuiceBox (https://github.com/aidenlab/Juicebox/wiki/Loading-Annotations-(Annotations-menu)). While, I found sever bugs.

  1. when I use HiCPeaksCoverage to show loops above heatmap body in style of triangular. Only two of all 11 loops are shown, while if we use heatmap body in style of matrix, all loops were shown.
  2. Another associated problem came from Arcs function with/without diameter_to_height, as you can seen from the tracks, Loop 1 only shows two loops.

The Loop bedpe file are:

18  2160000 2320000 18  1670000 1790000 *   100
18  2490000 2710000 18  1690000 1770000 *   100
18  2910000 3100000 18  1660000 1770000 *   100
18  3930000 4130000 18  1710000 1790000 *   100
18  3960000 4080000 18  2500000 2680000 *   100
18  3980000 4130000 18  4830000 4940000 *   100
18  4010000 4110000 18  4530000 4680000 *   100
18  4460000 4710000 18  1710000 1810000 *   100
18  4510000 4640000 18  2500000 2660000 *   100
18  4780000 4930000 18  2500000 2680000 *   100
18  4830000 4950000 18  1680000 1830000 *   100

My code is:

## coolbox 0.3.8
# -*- coding: utf-8 -*-

import coolbox
from coolbox.api import *
#from __future__ import print_function
import sys
import re

Ctrl_mcool='test.mcool'
HandLoop='testLoops.bedpe'
BEDfile='testAnchors.bed'

HandLoops1 =  Arcs(HandLoop, open_region=False,color="red",title="conD Loop",score_to_width=1,line_width=1,height=2,orientation="inverted",diameter_to_height="max_height-1")
HandLoops2 =  Arcs(HandLoop, open_region=False,color="red",title="conD Loop",score_to_width=1,line_width=1,height=2,orientation="inverted")
HandArc = HiCPeaksCoverage(HandLoop,color="black",line_width=1,score_to_width=1)
AnchorsBED=BED(BEDfile,display="collapsed",color="blue",border_color='blue',height=0.5,title='Anchors')

cool1 = XAxis() + Cool(Ctrl_mcool,style='triangular',
    balance=True,
    normalize="expect",
    transform=False,
    gaussian_sigma=1,
    norm=False,
    max_value=100,
    resolution=20000,
    cmap='bwr',
    min_value=10,
    color_bar='no')  + HandArc  + Spacer(height=0.1)+ AnchorsBED +HandLoops1  + HandLoops2

cool1.plot('18:1000000-6000000')

The figure is:

image

Linhua-Sun commented 2 years ago

Question 3

Another question came from loops in upper or lower showing above the heatmap. The key code line is HandArc = HiCPeaksCoverage(HandLoop,color="black",line_width=1,score_to_width=1,side="upper"). I have set side='upper', while the output is still confusing. It is OK if side='both'. It will be quite clean if we can show loops only in one side.

My code is:

## coolbox 0.3.8
# -*- coding: utf-8 -*-

import coolbox
from coolbox.api import *
#from __future__ import print_function
import sys
import re

Ctrl_mcool='test.mcool'
HandLoop='testLoops.bedpe'
BEDfile='testAnchors.bed'

HandLoops =  Arcs(HandLoop, open_region=False,color="red",title="conD Loop",score_to_width=1,line_width=1,height=2,diameter_to_height="max_height-1")

HandArc = HiCPeaksCoverage(HandLoop,color="black",line_width=1,score_to_width=1,side="upper")

AnchorsBED=BED(BEDfile,display="collapsed",color="blue",border_color='blue',height=0.5,title='Anchors')

frame = Arcs(HandLoop, open_region=False,color="red",title="Loop",score_to_width=1,line_width=1,height=2,diameter_to_height="max_height-1") +\
AnchorsBED +\
Spacer() +\
HighLightsFromFile(BEDfile,color='green') 

cool1 = Cool(Ctrl_mcool,style='matrix',
    balance=True,
    normalize="expect",
    transform=False,
    gaussian_sigma=1,
    norm=False,
    max_value=100,
    resolution=20000,
    cmap='bwr',
    min_value=10,
    color_bar='no') + HandArc +  HighLightsFromFile(BEDfile,color='green', alpha=0,border_line_alpha=1,border_line_color='red',border_line_width=1,border_line_style='solid') 

sub_frames = {
    "top": frame,
    "right": frame
}

jv = JointView(cool1,**sub_frames, space=0, padding_left=0)

jv.plot('18:50000000-58000000')

The figure is:

image

Thanks for your time! Best wishes! Linhua