Skip to content

Commit

Permalink
Merge pull request #200 from PixelgenTechnologies/feature/exe-2075-fa…
Browse files Browse the repository at this point in the history
…il-if-hard-and-dynamic-limit-both-set

Feature/exe 2075 fail if hard and dynamic size limits are both set
  • Loading branch information
johandahlberg authored Dec 10, 2024
2 parents d07eace + 8a5df55 commit 542cc28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support multiple targets in `plot_colocalization_diff_volcano` and `plot_colocalization_diff_heatmap`.
- If demultiplexing has a success rate lower than 50% the command will exit with a status of 1. This prevents further pipeline stages to be run on
what is probably bad data.
- Clarify that `--min-size` and `--max-size` in the `annotate` stage should not be used at the same time as `--dynamic-filter`.

### Added

Expand Down
23 changes: 14 additions & 9 deletions src/pixelator/cli/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,25 @@
required=False,
type=click.INT,
show_default=False,
help="The minimum size (edges) a component must have (default is disabled)",
help="The minimum size (edges) a component must have (default is disabled). Note that this cannot be set at the same time as --dynamic-filter.",
)
@click.option(
"--max-size",
default=None,
required=False,
type=click.INT,
show_default=False,
help="The maximum size (edges) a component must have (default is disabled)",
help="The maximum size (edges) a component must have (default is disabled). Note that this cannot be set at the same time as --dynamic-filter.",
)
@click.option(
"--dynamic-filter",
required=False,
default=None,
type=click.Choice(["both", "min", "max"]),
help=(
"Enable the estimation of dynamic size filters using a log-rank approach\n"
"\t both: estimate both min and max size"
"\t min: estimate min size (--min-size)"
"\t max: estimate max size (--max-size)"
"Enable the dynamic component size filters. The following modes are available: "
"both/max/min. both: estimates both min and max size, min: estimates min size, max: estimates max size. "
"Note that this cannot be set at the same time as --min-size or --max-size."
),
)
@click.option(
Expand Down Expand Up @@ -110,11 +109,17 @@ def annotate(

# sanity check on thresholds and input parameters
if min_size is not None and min_size < 0:
click.ClickException("--min-size cannot be less than 0")
raise click.ClickException("--min-size cannot be less than 0")
if max_size is not None and max_size < 0:
click.ClickException("--max-size cannot be less than 0")
raise click.ClickException("--max-size cannot be less than 0")
if max_size is not None and min_size is not None and max_size < min_size:
click.ClickException("--max-size cannot be less than --min-size")
raise click.ClickException("--max-size cannot be less than --min-size")

if min_size is not None or max_size is not None:
if dynamic_filter is not None:
raise click.ClickException(
"Cannot set --dynamic-filter and --min-size or --max-size at the same time"
)

# warn if both --dynamic-filter and hard-coded sizes are input
if min_size is not None and dynamic_filter in ["min", "both"]:
Expand Down

0 comments on commit 542cc28

Please sign in to comment.