Skip to content

Commit d6d9d13

Browse files
authored
Ensure that missing CNVs are shown in a different colour in plot_diplotype_clustering_advanced (#670)
* Trying something * Updated the palette in plot_cnv_hmm
1 parent 6c27d20 commit d6d9d13

File tree

4 files changed

+6058
-10
lines changed

4 files changed

+6058
-10
lines changed

malariagen_data/anoph/cnv_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ def plot_cnv_hmm_heatmap_track(
825825
debug = self._log.debug
826826

827827
import bokeh.models as bkmod
828-
import bokeh.palettes as bkpal
829828
import bokeh.plotting as bkplt
830829

831830
region_prepped: Region = parse_single_region(self, region)
@@ -892,7 +891,7 @@ def plot_cnv_hmm_heatmap_track(
892891
)
893892

894893
debug("set up palette and color mapping")
895-
palette = ("#cccccc",) + bkpal.PuOr5
894+
palette = cnv_params.colorscale_default
896895
color_mapper = bkmod.LinearColorMapper(low=-1.5, high=4.5, palette=palette)
897896

898897
debug("plot the HMM copy number data as an image")

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,

0 commit comments

Comments
 (0)