Skip to content

Commit 1321ede

Browse files
authored
Merge branch 'master' into 367-haps-freq
2 parents c9d8ec4 + d6d9d13 commit 1321ede

32 files changed

+8017
-817
lines changed

docs/source/Af1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ SNP data access
7171
is_accessible
7272
biallelic_snp_calls
7373
biallelic_diplotypes
74+
biallelic_snps_to_plink
7475

7576
Haplotype data access
7677
---------------------

docs/source/Ag3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ SNP data access
7272
is_accessible
7373
biallelic_snp_calls
7474
biallelic_diplotypes
75+
biallelic_snps_to_plink
7576

7677
Haplotype data access
7778
---------------------

malariagen_data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .amin1 import Amin1
55
from .anopheles import AnophelesDataResource, Region
66
from .pf7 import Pf7
7+
from .pf8 import Pf8
78
from .pv4 import Pv4
89
from .util import SiteClass
910

malariagen_data/anoph/cnv_data.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ def plot_cnv_hmm_coverage(
751751
line_kwargs: Optional[gplt_params.line_kwargs] = None,
752752
show: gplt_params.show = True,
753753
output_backend: gplt_params.output_backend = gplt_params.output_backend_default,
754+
gene_labels: Optional[gplt_params.gene_labels] = None,
755+
gene_labelset: Optional[gplt_params.gene_labelset] = None,
754756
) -> gplt_params.figure:
755757
debug = self._log.debug
756758

@@ -782,6 +784,8 @@ def plot_cnv_hmm_coverage(
782784
x_range=fig1.x_range,
783785
show=False,
784786
output_backend=output_backend,
787+
gene_labels=gene_labels,
788+
gene_labelset=gene_labelset,
785789
)
786790

787791
debug("combine plots into a single figure")
@@ -821,7 +825,6 @@ def plot_cnv_hmm_heatmap_track(
821825
debug = self._log.debug
822826

823827
import bokeh.models as bkmod
824-
import bokeh.palettes as bkpal
825828
import bokeh.plotting as bkplt
826829

827830
region_prepped: Region = parse_single_region(self, region)
@@ -888,7 +891,7 @@ def plot_cnv_hmm_heatmap_track(
888891
)
889892

890893
debug("set up palette and color mapping")
891-
palette = ("#cccccc",) + bkpal.PuOr5
894+
palette = cnv_params.colorscale_default
892895
color_mapper = bkmod.LinearColorMapper(low=-1.5, high=4.5, palette=palette)
893896

894897
debug("plot the HMM copy number data as an image")
@@ -960,6 +963,8 @@ def plot_cnv_hmm_heatmap(
960963
track_height: Optional[gplt_params.track_height] = None,
961964
genes_height: gplt_params.genes_height = gplt_params.genes_height_default,
962965
show: gplt_params.show = True,
966+
gene_labels: Optional[gplt_params.gene_labels] = None,
967+
gene_labelset: Optional[gplt_params.gene_labelset] = None,
963968
) -> gplt_params.figure:
964969
debug = self._log.debug
965970

@@ -989,6 +994,8 @@ def plot_cnv_hmm_heatmap(
989994
height=genes_height,
990995
x_range=fig1.x_range,
991996
show=False,
997+
gene_labels=gene_labels,
998+
gene_labelset=gene_labelset,
992999
)
9931000

9941001
debug("combine plots into a single figure")

malariagen_data/anoph/cnv_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020
`coverage_calls_analysis_ids` property for available values.
2121
""",
2222
]
23+
24+
# This is grey followed by PuOr5
25+
colorscale_default = ["#cccccc", "#5e3c99", "#b2abd2", "#f7f7f7", "#fdb863", "#e66101"]

malariagen_data/anoph/dipclust.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,18 @@ def _dipclust_cnv_bar_trace(
425425
n if not pd.isna(n) else gene_ids[i] for i, n in enumerate(gene_names)
426426
]
427427

428+
cn_mode_no_nan = np.nan_to_num(cn_mode, nan=-1)
429+
428430
# Plot the copy number data.
429431
# N.B., here we have to use go.Heatmap directly rather than
430432
# px.imshow because the latter fails to incorporate zmin,
431433
# zmax and colorscale within the trace data, and so these
432434
# then get lost later when we try to combined into a single
433435
# figure.
434436
trace = go.Heatmap(
435-
z=cn_mode,
437+
z=cn_mode_no_nan,
436438
y=gene_labels,
437-
zmin=0,
439+
zmin=-1,
438440
zmax=4,
439441
colorscale=colorscale,
440442
showlegend=False,
@@ -564,7 +566,7 @@ def plot_diplotype_clustering_advanced(
564566
snp_filter_min_maf: float = 0.05,
565567
snp_query: Optional[base_params.snp_query] = AA_CHANGE_QUERY,
566568
cnv_region: Optional[base_params.regions] = None,
567-
cnv_colorscale: plotly_params.color_continuous_scale = "PuOr_r",
569+
cnv_colorscale: plotly_params.color_continuous_scale = cnv_params.colorscale_default,
568570
cnv_max_coverage_variance: cnv_params.max_coverage_variance = 0.2,
569571
site_mask: Optional[base_params.site_mask] = None,
570572
sample_sets: Optional[base_params.sample_sets] = None,

malariagen_data/anoph/distance.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numba # type: ignore
77
import numpy as np
88
from numpydoc_decorator import doc # type: ignore
9-
import anjl.params # type: ignore
109

1110
# Internal imports.
1211
from .snp_data import AnophelesSnpData
@@ -410,10 +409,10 @@ def plot_njt(
410409
metric: distance_params.distance_metric = distance_params.default_distance_metric,
411410
distance_sort: Optional[tree_params.distance_sort] = None,
412411
count_sort: Optional[tree_params.count_sort] = None,
413-
center_x: anjl.params.center_x = 0,
414-
center_y: anjl.params.center_y = 0,
415-
arc_start: anjl.params.arc_start = 0,
416-
arc_stop: anjl.params.arc_stop = 2 * math.pi,
412+
center_x: distance_params.center_x = 0,
413+
center_y: distance_params.center_y = 0,
414+
arc_start: distance_params.arc_start = 0,
415+
arc_stop: distance_params.arc_stop = 2 * math.pi,
417416
width: plotly_params.fig_width = 800,
418417
height: plotly_params.fig_height = 600,
419418
show: plotly_params.show = True,
@@ -426,8 +425,8 @@ def plot_njt(
426425
color_discrete_sequence: plotly_params.color_discrete_sequence = None,
427426
color_discrete_map: plotly_params.color_discrete_map = None,
428427
category_orders: plotly_params.category_order = None,
429-
edge_legend: anjl.params.edge_legend = False,
430-
leaf_legend: anjl.params.leaf_legend = True,
428+
edge_legend: distance_params.edge_legend = False,
429+
leaf_legend: distance_params.leaf_legend = True,
431430
legend_sizing: plotly_params.legend_sizing = "constant",
432431
thin_offset: base_params.thin_offset = 0,
433432
sample_sets: Optional[base_params.sample_sets] = None,
@@ -449,6 +448,10 @@ def plot_njt(
449448
inline_array: base_params.inline_array = base_params.inline_array_default,
450449
chunks: base_params.chunks = base_params.native_chunks,
451450
) -> plotly_params.figure:
451+
# Only import anjl if needed, as it requires a couple of seconds to compile
452+
# functions.
453+
import anjl # type: ignore
454+
452455
# Normalise params.
453456
if count_sort is None and distance_sort is None:
454457
count_sort = True

malariagen_data/anoph/distance_params.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,20 @@
1919
]
2020

2121
default_nj_algorithm: nj_algorithm = "dynamic"
22+
23+
center_x: TypeAlias = Annotated[int | float, "X coordinate where plotting is centered."]
24+
25+
center_y: TypeAlias = Annotated[int | float, "Y coordinate where plotting is centered."]
26+
27+
arc_start: TypeAlias = Annotated[int | float, "Angle where tree layout begins."]
28+
29+
arc_stop: TypeAlias = Annotated[int | float, "Angle where tree layout ends."]
30+
31+
edge_legend: TypeAlias = Annotated[
32+
bool, "Show legend entries for the different edge (line) colors."
33+
]
34+
35+
leaf_legend: TypeAlias = Annotated[
36+
bool,
37+
"Show legend entries for the different leaf node (scatter) colors and symbols.",
38+
]

malariagen_data/anoph/fst.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ def plot_fst_gwss(
293293
show: gplt_params.show = True,
294294
output_backend: gplt_params.output_backend = gplt_params.output_backend_default,
295295
clip_min: fst_params.clip_min = 0.0,
296+
gene_labels: Optional[gplt_params.gene_labels] = None,
297+
gene_labelset: Optional[gplt_params.gene_labelset] = None,
296298
) -> gplt_params.figure:
297299
# gwss track
298300
fig1 = self.plot_fst_gwss_track(
@@ -327,6 +329,8 @@ def plot_fst_gwss(
327329
x_range=fig1.x_range,
328330
show=False,
329331
output_backend=output_backend,
332+
gene_labels=gene_labels,
333+
gene_labelset=gene_labelset,
330334
)
331335

332336
# combine plots into a single figure

malariagen_data/anoph/g123.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ def plot_g123_gwss(
438438
output_backend: gplt_params.output_backend = gplt_params.output_backend_default,
439439
inline_array: base_params.inline_array = base_params.inline_array_default,
440440
chunks: base_params.chunks = base_params.native_chunks,
441+
gene_labels: Optional[gplt_params.gene_labels] = None,
442+
gene_labelset: Optional[gplt_params.gene_labelset] = None,
441443
) -> gplt_params.figure:
442444
# gwss track
443445
fig1 = self.plot_g123_gwss_track(
@@ -472,6 +474,8 @@ def plot_g123_gwss(
472474
x_range=fig1.x_range,
473475
show=False,
474476
output_backend=output_backend,
477+
gene_labels=gene_labels,
478+
gene_labelset=gene_labelset,
475479
)
476480

477481
# combine plots into a single figure

0 commit comments

Comments
 (0)