Skip to content

Commit

Permalink
Add sample_query_options to CNV data functions
Browse files Browse the repository at this point in the history
  • Loading branch information
leehart committed Sep 27, 2024
1 parent ed83b3c commit 6b25aa3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions malariagen_data/anoph/cnv_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def cnv_hmm(
region: base_params.regions,
sample_sets: Optional[base_params.sample_sets] = None,
sample_query: Optional[base_params.sample_query] = None,
sample_query_options: Optional[base_params.sample_query_options] = None,
max_coverage_variance: cnv_params.max_coverage_variance = cnv_params.max_coverage_variance_default,
inline_array: base_params.inline_array = base_params.inline_array_default,
chunks: base_params.chunks = base_params.native_chunks,
Expand Down Expand Up @@ -241,7 +242,10 @@ def cnv_hmm(
)

debug("apply the query")
loc_query_samples = df_samples_cnv.eval(sample_query).values
sample_query_options = sample_query_options or {}
loc_query_samples = df_samples_cnv.eval(
sample_query, **sample_query_options
).values
if np.count_nonzero(loc_query_samples) == 0:
raise ValueError(f"No samples found for query {sample_query!r}")

Expand Down Expand Up @@ -536,6 +540,7 @@ def cnv_discordant_read_calls(
contig: base_params.contigs,
sample_sets: Optional[base_params.sample_sets] = None,
sample_query: Optional[base_params.sample_query] = None,
sample_query_options: Optional[base_params.sample_query_options] = None,
inline_array: base_params.inline_array = base_params.inline_array_default,
chunks: base_params.chunks = base_params.native_chunks,
) -> xr.Dataset:
Expand Down Expand Up @@ -588,7 +593,10 @@ def cnv_discordant_read_calls(
)

debug("apply the query")
loc_query_samples = df_samples_cnv.eval(sample_query).values
sample_query_options = sample_query_options or {}
loc_query_samples = df_samples_cnv.eval(
sample_query, **sample_query_options
).values
if np.count_nonzero(loc_query_samples) == 0:
raise ValueError(f"No samples found for query {sample_query!r}")

Expand Down Expand Up @@ -801,6 +809,7 @@ def plot_cnv_hmm_heatmap_track(
region: base_params.region,
sample_sets: Optional[base_params.sample_sets] = None,
sample_query: Optional[base_params.sample_query] = None,
sample_query_options: Optional[base_params.sample_query_options] = None,
max_coverage_variance: cnv_params.max_coverage_variance = cnv_params.max_coverage_variance_default,
sizing_mode: gplt_params.sizing_mode = gplt_params.sizing_mode_default,
width: gplt_params.width = gplt_params.width_default,
Expand All @@ -823,6 +832,7 @@ def plot_cnv_hmm_heatmap_track(
region=region_prepped,
sample_sets=sample_sets,
sample_query=sample_query,
sample_query_options=sample_query_options,
max_coverage_variance=max_coverage_variance,
)

Expand Down Expand Up @@ -942,6 +952,7 @@ def plot_cnv_hmm_heatmap(
region: base_params.region,
sample_sets: Optional[base_params.sample_sets] = None,
sample_query: Optional[base_params.sample_query] = None,
sample_query_options: Optional[base_params.sample_query_options] = None,
max_coverage_variance: cnv_params.max_coverage_variance = cnv_params.max_coverage_variance_default,
sizing_mode: gplt_params.sizing_mode = gplt_params.sizing_mode_default,
width: gplt_params.width = gplt_params.width_default,
Expand All @@ -960,6 +971,7 @@ def plot_cnv_hmm_heatmap(
region=region,
sample_sets=sample_sets,
sample_query=sample_query,
sample_query_options=sample_query_options,
max_coverage_variance=max_coverage_variance,
sizing_mode=sizing_mode,
width=width,
Expand Down

0 comments on commit 6b25aa3

Please sign in to comment.