pylocuszoom 0.3.0__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pylocuszoom/__init__.py +74 -2
- pylocuszoom/backends/base.py +131 -0
- pylocuszoom/backends/bokeh_backend.py +254 -68
- pylocuszoom/backends/matplotlib_backend.py +173 -0
- pylocuszoom/backends/plotly_backend.py +327 -87
- pylocuszoom/colors.py +44 -1
- pylocuszoom/forest.py +37 -0
- pylocuszoom/gene_track.py +1 -0
- pylocuszoom/loaders.py +880 -0
- pylocuszoom/phewas.py +35 -0
- pylocuszoom/plotter.py +342 -117
- pylocuszoom/py.typed +0 -0
- pylocuszoom/recombination.py +49 -35
- pylocuszoom/schemas.py +406 -0
- {pylocuszoom-0.3.0.dist-info → pylocuszoom-0.6.0.dist-info}/METADATA +153 -25
- pylocuszoom-0.6.0.dist-info/RECORD +26 -0
- pylocuszoom-0.3.0.dist-info/RECORD +0 -21
- {pylocuszoom-0.3.0.dist-info → pylocuszoom-0.6.0.dist-info}/WHEEL +0 -0
- {pylocuszoom-0.3.0.dist-info → pylocuszoom-0.6.0.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -290,6 +290,179 @@ class MatplotlibBackend:
|
|
|
290
290
|
"""Close the figure and free resources."""
|
|
291
291
|
plt.close(fig)
|
|
292
292
|
|
|
293
|
+
def add_eqtl_legend(
|
|
294
|
+
self,
|
|
295
|
+
ax: Axes,
|
|
296
|
+
eqtl_positive_bins: List[Tuple[float, float, str, str]],
|
|
297
|
+
eqtl_negative_bins: List[Tuple[float, float, str, str]],
|
|
298
|
+
) -> None:
|
|
299
|
+
"""Add eQTL effect size legend using matplotlib Line2D markers."""
|
|
300
|
+
from matplotlib.lines import Line2D
|
|
301
|
+
|
|
302
|
+
legend_elements = []
|
|
303
|
+
|
|
304
|
+
# Positive effects (upward triangles)
|
|
305
|
+
for _, _, label, color in eqtl_positive_bins:
|
|
306
|
+
legend_elements.append(
|
|
307
|
+
Line2D(
|
|
308
|
+
[0],
|
|
309
|
+
[0],
|
|
310
|
+
marker="^",
|
|
311
|
+
color="w",
|
|
312
|
+
markerfacecolor=color,
|
|
313
|
+
markeredgecolor="black",
|
|
314
|
+
markersize=7,
|
|
315
|
+
label=label,
|
|
316
|
+
)
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
# Negative effects (downward triangles)
|
|
320
|
+
for _, _, label, color in eqtl_negative_bins:
|
|
321
|
+
legend_elements.append(
|
|
322
|
+
Line2D(
|
|
323
|
+
[0],
|
|
324
|
+
[0],
|
|
325
|
+
marker="v",
|
|
326
|
+
color="w",
|
|
327
|
+
markerfacecolor=color,
|
|
328
|
+
markeredgecolor="black",
|
|
329
|
+
markersize=7,
|
|
330
|
+
label=label,
|
|
331
|
+
)
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
ax.legend(
|
|
335
|
+
handles=legend_elements,
|
|
336
|
+
loc="upper right",
|
|
337
|
+
fontsize=8,
|
|
338
|
+
frameon=True,
|
|
339
|
+
framealpha=0.9,
|
|
340
|
+
title="eQTL effect",
|
|
341
|
+
title_fontsize=9,
|
|
342
|
+
handlelength=1.2,
|
|
343
|
+
handleheight=1.0,
|
|
344
|
+
labelspacing=0.3,
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
def add_finemapping_legend(
|
|
348
|
+
self,
|
|
349
|
+
ax: Axes,
|
|
350
|
+
credible_sets: List[int],
|
|
351
|
+
get_color_func: Any,
|
|
352
|
+
) -> None:
|
|
353
|
+
"""Add fine-mapping credible set legend using matplotlib Line2D markers."""
|
|
354
|
+
from matplotlib.lines import Line2D
|
|
355
|
+
|
|
356
|
+
if not credible_sets:
|
|
357
|
+
return
|
|
358
|
+
|
|
359
|
+
legend_elements = []
|
|
360
|
+
for cs_id in credible_sets:
|
|
361
|
+
color = get_color_func(cs_id)
|
|
362
|
+
legend_elements.append(
|
|
363
|
+
Line2D(
|
|
364
|
+
[0],
|
|
365
|
+
[0],
|
|
366
|
+
marker="o",
|
|
367
|
+
color="w",
|
|
368
|
+
markerfacecolor=color,
|
|
369
|
+
markeredgecolor="black",
|
|
370
|
+
markersize=7,
|
|
371
|
+
label=f"CS{cs_id}",
|
|
372
|
+
)
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
ax.legend(
|
|
376
|
+
handles=legend_elements,
|
|
377
|
+
loc="upper right",
|
|
378
|
+
fontsize=8,
|
|
379
|
+
frameon=True,
|
|
380
|
+
framealpha=0.9,
|
|
381
|
+
title="Credible sets",
|
|
382
|
+
title_fontsize=9,
|
|
383
|
+
handlelength=1.2,
|
|
384
|
+
handleheight=1.0,
|
|
385
|
+
labelspacing=0.3,
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
def add_simple_legend(
|
|
389
|
+
self,
|
|
390
|
+
ax: Axes,
|
|
391
|
+
label: str,
|
|
392
|
+
loc: str = "upper right",
|
|
393
|
+
) -> None:
|
|
394
|
+
"""Add simple legend for labeled scatter data."""
|
|
395
|
+
ax.legend(loc=loc, fontsize=9)
|
|
396
|
+
|
|
397
|
+
def axvline(
|
|
398
|
+
self,
|
|
399
|
+
ax: Axes,
|
|
400
|
+
x: float,
|
|
401
|
+
color: str = "grey",
|
|
402
|
+
linestyle: str = "--",
|
|
403
|
+
linewidth: float = 1.0,
|
|
404
|
+
alpha: float = 1.0,
|
|
405
|
+
zorder: int = 1,
|
|
406
|
+
) -> Any:
|
|
407
|
+
"""Add a vertical line across the axes."""
|
|
408
|
+
return ax.axvline(
|
|
409
|
+
x=x,
|
|
410
|
+
color=color,
|
|
411
|
+
linestyle=linestyle,
|
|
412
|
+
linewidth=linewidth,
|
|
413
|
+
alpha=alpha,
|
|
414
|
+
zorder=zorder,
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
def hbar(
|
|
418
|
+
self,
|
|
419
|
+
ax: Axes,
|
|
420
|
+
y: pd.Series,
|
|
421
|
+
width: pd.Series,
|
|
422
|
+
height: float = 0.8,
|
|
423
|
+
left: Union[float, pd.Series] = 0,
|
|
424
|
+
color: Union[str, List[str]] = "blue",
|
|
425
|
+
edgecolor: str = "black",
|
|
426
|
+
linewidth: float = 0.5,
|
|
427
|
+
zorder: int = 2,
|
|
428
|
+
) -> Any:
|
|
429
|
+
"""Create horizontal bar chart."""
|
|
430
|
+
return ax.barh(
|
|
431
|
+
y=y,
|
|
432
|
+
width=width,
|
|
433
|
+
height=height,
|
|
434
|
+
left=left,
|
|
435
|
+
color=color,
|
|
436
|
+
edgecolor=edgecolor,
|
|
437
|
+
linewidth=linewidth,
|
|
438
|
+
zorder=zorder,
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
def errorbar_h(
|
|
442
|
+
self,
|
|
443
|
+
ax: Axes,
|
|
444
|
+
x: pd.Series,
|
|
445
|
+
y: pd.Series,
|
|
446
|
+
xerr_lower: pd.Series,
|
|
447
|
+
xerr_upper: pd.Series,
|
|
448
|
+
color: str = "black",
|
|
449
|
+
linewidth: float = 1.5,
|
|
450
|
+
capsize: float = 3,
|
|
451
|
+
zorder: int = 3,
|
|
452
|
+
) -> Any:
|
|
453
|
+
"""Add horizontal error bars."""
|
|
454
|
+
xerr = [xerr_lower.values, xerr_upper.values]
|
|
455
|
+
return ax.errorbar(
|
|
456
|
+
x=x,
|
|
457
|
+
y=y,
|
|
458
|
+
xerr=xerr,
|
|
459
|
+
fmt="none",
|
|
460
|
+
ecolor=color,
|
|
461
|
+
elinewidth=linewidth,
|
|
462
|
+
capsize=capsize,
|
|
463
|
+
zorder=zorder,
|
|
464
|
+
)
|
|
465
|
+
|
|
293
466
|
def finalize_layout(
|
|
294
467
|
self,
|
|
295
468
|
fig: Figure,
|