@@ -12,7 +12,7 @@ def plot_interaction(
1212 height = None ,
1313 y = 10 ,
1414 plot_text = True ,
15- color = ( 223.0 / 255.0 , 90 / 255.0 , 73 / 255.0 ) ):
15+ color = 'tomato' ):
1616 """Visualize an individual loop with an arc diagram.
1717 """
1818 arc_center = ((l + r )/ 2 ,y )
@@ -39,16 +39,11 @@ def plot_interaction(
3939 color = color
4040 )
4141
42-
43- def plot_lefs (
44- l_sites ,
45- r_sites ,
46- L ,
47- site_width_bp = 600 ,
48- colors = (223.0 / 255.0 ,90 / 255.0 ,73 / 255.0 ),
49- ** kwargs ):
50- """Plot an arc diagram for a list of loops.
51- """
42+ def prepare_canvas (
43+ L ,
44+ site_width_bp = None ,
45+ ):
46+
5247 plt .figure (figsize = (15 ,5 ))
5348 plt .gca ().spines ['top' ].set_visible (False )
5449 plt .gca ().spines ['bottom' ].set_visible (False )
@@ -61,21 +56,35 @@ def plot_lefs(
6156 left = 'off' ,
6257 direction = 'out' ,
6358 top = 'off' )
64- plt .axhline (0 , color = 'gray' , lw = 5 ,zorder = - 1 )
59+ plt .xlim (- 20 ,L + 20 )
60+ plt .ylim (- 30 ,200 )
61+
6562 plt .yticks ([])
66- plt .xticks ([100 * i * 1000 / float (site_width_bp ) for i in range (16 )],
67- [100 * i for i in range (16 )],
68- fontsize = 20 )
69- plt .xlabel ('chromosomal position, kb' , fontsize = 20 )
63+
64+ plt .axhline (0 , color = 'gray' , lw = 5 ,zorder = - 1 )
7065
71- n_lefs = looptools .stack_lefs (l_sites ,r_sites )
66+ if site_width_bp :
67+ plt .xticks ([100 * i * 1000 / float (site_width_bp ) for i in range (16 )],
68+ [100 * i for i in range (16 )],
69+ fontsize = 20 )
70+ plt .xlabel ('chromosomal position, kb' , fontsize = 20 )
71+
72+
73+ def plot_lefs (
74+ l_sites ,
75+ r_sites ,
76+ colors = 'tomato' ,
77+ ** kwargs ):
78+ """Plot an arc diagram for a list of loops.
79+ """
80+
81+ n_lefs = looptools .stack_lefs (np .vstack ([l_sites ,r_sites ]).T )
7282 for i in range (l_sites .size ):
7383 plot_interaction (
7484 l_sites [i ],
7585 r_sites [i ],
7686 n_lefs [i ],
77- color = colors [i ] if (type (colors ) in (list , np .ndarray )) else colors ,
87+ color = colors [i ] if (type (colors ) in (list , tuple , np .ndarray )) else colors ,
7888 ** kwargs )
7989
80- plt .xlim (- 20 ,L + 20 )
81- plt .ylim (- 30 ,200 )
90+
0 commit comments