Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "arc-state"
version = "0.9.32"
version = "0.9.33"
description = "State is a machine learning model that predicts cellular perturbation response across diverse contexts."
readme = "README.md"
authors = [
Expand Down
8 changes: 8 additions & 0 deletions src/state/_cli/_tx/_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def add_arguments_predict(parser: ap.ArgumentParser):
help="If set, evaluate the model on the training data rather than on the test data.",
)

parser.add_argument(
"--fdr-threshold",
type=float,
default=1e-3,
help="FDR threshold for DE significance in cell-eval metrics. Default is 1e-3.",
)
Comment on lines +55 to +60

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new --fdr-threshold argument accepts any float value, which could lead to errors or unexpected behavior in cell-eval if an invalid value (e.g., negative or > 1) is provided. It would be more robust to add validation to ensure the input is within a sensible range, like (0, 1).

You can achieve this by using a custom type function with argparse.

For example:

import argparse

def fdr_threshold_range(value):
    try:
        f_value = float(value)
    except ValueError:
        raise argparse.ArgumentTypeError(f"{value} is not a floating-point number")
    if not (0.0 < f_value < 1.0):
        raise argparse.ArgumentTypeError(f"{value} is not a valid FDR threshold, it must be between 0 and 1.")
    return f_value

# ... in add_arguments_predict ...
parser.add_argument(
    "--fdr-threshold",
    type=fdr_threshold_range,
    default=1e-3,
    help="FDR threshold for DE significance in cell-eval metrics. Default is 1e-3.",
)



def run_tx_predict(args: ap.ArgumentParser):
import logging
Expand Down Expand Up @@ -422,6 +429,7 @@ def load_config(cfg_path: str) -> dict:
prefix=ct,
pdex_kwargs=pdex_kwargs,
batch_size=2048,
fdr_threshold=args.fdr_threshold,
)

evaluator.compute(
Expand Down