Skip to content

Commit 2e3cc90

Browse files
committed
Worked on annotation view
1 parent 1f9896e commit 2e3cc90

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

panagram/view.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,10 @@ def plot_interactive(anchor_name, chrom, start_coord, end_coord, step, pancounts
683683
hasexon = "exon" in anno_types
684684

685685
c = np.arange(len(anno_types) + (not hasexon))
686-
ann_colors = np.array(px.colors.qualitative.Dark24)
686+
ann_colors = np.array(px.colors.qualitative.Prism)
687687
ann_colors = ann_colors[c % len(ann_colors)]
688688

689-
linewidth = 5 if hasexon else 15
689+
linewidth = 1 if hasexon else 15
690690
print("WIDHT", linewidth)
691691

692692
fig.append_trace(go.Scattergl(
@@ -711,14 +711,14 @@ def plot_interactive(anchor_name, chrom, start_coord, end_coord, step, pancounts
711711
anno["break"] = np.nan
712712
for t, df in anno.groupby("type_id"):
713713
xs = df[["start","end","break"]].to_numpy().flatten()
714-
ys = np.full(len(xs),-t)
714+
ys = np.full(len(xs),-t*2)
715715
name = df["type"].iloc[0]
716716

717717
if name == "exon":
718718
linewidth = 15
719719
else:
720720
anno_names.append(name)
721-
linewidth = 10
721+
linewidth = 1
722722

723723
fig.append_trace(go.Scattergl(x=xs, y=ys,
724724
line=dict(width=linewidth,color=ann_colors[t]),
@@ -727,13 +727,21 @@ def plot_interactive(anchor_name, chrom, start_coord, end_coord, step, pancounts
727727
hovertemplate='<br>x:%{x}<br>m:%{text}',
728728
text=np.repeat(df["name"],3),
729729
showlegend=False,
730-
marker={"symbol":"line-ns","line_color":ann_colors[t],"line_width":1,"size":6},
730+
opacity=0.7,
731+
marker={"symbol":"line-ns","line_color":ann_colors[t],"line_width":1,"size":2},
731732
mode="lines+markers"
732733
), row=2, col=1)
733734

735+
ys = np.arange(-len(ann_colors),0)+1
736+
names = anno_names[::-1]
737+
if len(ys) > 10:
738+
n = len(ys)//10
739+
ys = ys[::n]
740+
names = names[::n]
741+
734742
fig.update_yaxes(
735-
tickvals=np.arange(-len(ann_colors),0)+1,ticktext=anno_names[::-1],
736-
range=[-len(ann_colors)+0.5,0.5], #title="Annotation",
743+
tickvals=ys,ticktext=names,
744+
range=[-len(ann_colors)-0.5,1.5], #title="Annotation",
737745
row=2, col=1
738746
)
739747

0 commit comments

Comments
 (0)