Skip to content
Merged
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
22 changes: 17 additions & 5 deletions amygda/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"GPALL1F",
"CHNMCMM2",
"GB1ECSDP",
"EUST2",
"EUSTAPF",
}

PINK = (138, 41, 231)
Expand All @@ -41,12 +43,16 @@ def build_parser() -> argparse.ArgumentParser:
_add_common_image_arguments(filter_parser)
filter_parser.set_defaults(handler=handle_filter)

segment_parser = subparsers.add_parser("segment", help="Identify wells in an input image.")
segment_parser = subparsers.add_parser(
"segment", help="Identify wells in an input image."
)
_add_common_image_arguments(segment_parser)
_add_segment_arguments(segment_parser)
segment_parser.set_defaults(handler=handle_segment)

measure_parser = subparsers.add_parser("measure", help="Measure growth from an input image.")
measure_parser = subparsers.add_parser(
"measure", help="Measure growth from an input image."
)
_add_common_image_arguments(measure_parser)
_add_plate_design_argument(measure_parser)
_add_measure_arguments(measure_parser)
Expand Down Expand Up @@ -136,7 +142,9 @@ def handle_run(options: argparse.Namespace) -> None:
plate = _build_plate(raw_info, options.plate_design)

filtered_info = run_filter_stage(plate, raw_info)
segmented_info = run_segment_stage(plate, filtered_info, options, reuse_loaded_image=True)
segmented_info = run_segment_stage(
plate, filtered_info, options, reuse_loaded_image=True
)
run_measure_stage(plate, segmented_info, options, reuse_loaded_state=True)


Expand Down Expand Up @@ -364,7 +372,9 @@ def save_drug_images(
groups,
key=lambda group: float(np.min(well_drug_conc[group[:, 0], group[:, 1]])),
)
panels = [_extract_oriented_drug_panel(plate, group) for group in ordered_groups]
panels = [
_extract_oriented_drug_panel(plate, group) for group in ordered_groups
]
panel = _concatenate_panels_horizontally(panels)
if control_panel is not None:
panel = _stack_panels_vertically_left_aligned([control_panel, panel])
Expand Down Expand Up @@ -739,7 +749,9 @@ def _build_positive_control_panel(plate: PlateMeasurement) -> np.ndarray:

control_positions = np.array(plate.well_positive_controls, dtype=int)
if control_positions.size == 0:
raise RuntimeError("No positive control wells were found for this plate design.")
raise RuntimeError(
"No positive control wells were found for this plate design."
)

groups = _group_drug_positions(control_positions)
ordered_groups = sorted(groups, key=lambda group: int(np.min(group[:, 1])))
Expand Down
8 changes: 8 additions & 0 deletions amygda/config/EUST2-conc-matrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
32, 32, 4, 4, 8, 256, 8, 4, 8, 16, 32, 64
16, 16, 2, 2, 4, 2, 4, 0.25, 0.5, 1, 2, 4
8, 8, 1, 1, 2, 1, 2, 0.06, 0.12, 0.25, 0.5, 1
4, 4, 0.5, 0.5, 1, 0.5, 1, 1, 2, 4, 8, 16
0.015, 0.03, 0.06, 0.12, 0.25, 0.5, 0.12, 0.25, 0.5, 1, 2, 4
0.25, 0.5, 1, 2, 4, 8, 0.5, 1, 2, 4, 8, 16
0.25, 0.5, 1, 2, 4, 8, 0.5, 1, 2, 4, 8, 16
0.5, 1, 2, 4, 8, 16, 64, 128, 256, 512, 0, 0
8 changes: 8 additions & 0 deletions amygda/config/EUST2-dilution-matrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
4, 4, 4, 4, 4, 4, 4, 1, 2, 3, 4, 5
3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 4, 5
2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5
1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6
1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6
1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6
1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 0, 0
8 changes: 8 additions & 0 deletions amygda/config/EUST2-drug-matrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
KAN,STR,TIA,SYN,LZD,MUP,VAN,CHL,CHL,CHL,CHL,CHL
KAN,STR,TIA,SYN,LZD,MUP,VAN,FUS,FUS,FUS,FUS,FUS
KAN,STR,TIA,SYN,LZD,MUP,VAN,PEN,PEN,PEN,PEN,PEN
KAN,STR,TIA,SYN,LZD,MUP,VAN,TMP,TMP,TMP,TMP,TMP
RIF,RIF,RIF,RIF,RIF,RIF,CLI,CLI,CLI,CLI,CLI,CLI
ERY,ERY,ERY,ERY,ERY,ERY,FOX,FOX,FOX,FOX,FOX,FOX
CIP,CIP,CIP,CIP,CIP,CIP,GEN,GEN,GEN,GEN,GEN,GEN
TET,TET,TET,TET,TET,TET,SMX,SMX,SMX,SMX,POS,POS
8 changes: 8 additions & 0 deletions amygda/config/EUSTAPF-conc-matrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
0.5, 1, 2, 0.5, 1, 0.25, 0.03, 0.25, 0.25, 0.5, 0.03, 0.5
1, 2, 4, 1, 2, 0.5, 0.06, 0.5, 0.5, 1, 0.06, 1
2, 4, 8, 2, 4, 1, 0.12, 1, 1, 2, 0.12, 2
4, 8, 16, 4, 8, 2, 0.25, 2, 2, 4, 0.25, 4
0.5, 0.5, 0.12, 0.5, 16, 4, 0.5, 4, 4, 8, 0.5, 8
1, 1, 0.25, 1, 4, 0, 1, 8, 8, 16, 1, 256
2, 2, 0.5, 2, 8, 0, 0.25, 0.5, 1, 2, 0, 0
4, 4, 1, 4, 16, 1, 2, 4, 8, 6, 0, 0
8 changes: 8 additions & 0 deletions amygda/config/EUSTAPF-dilution-matrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5
2, 2, 2, 2, 1, 0, 6, 6, 6, 6, 6, 6
3, 3, 3, 3, 2, 0, 1, 2, 3, 4, 0, 0
4, 4, 4, 4, 3, 1, 2, 3, 4, 1, 0, 0
8 changes: 8 additions & 0 deletions amygda/config/EUSTAPF-drug-matrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CPT,SXT,LZD,TET,TEI,ERY,TLA,TOB,GEN,VAN,RIF,MUP
CPT,SXT,LZD,TET,TEI,ERY,TLA,TOB,GEN,VAN,RIF,MUP
CPT,SXT,LZD,TET,TEI,ERY,TLA,TOB,GEN,VAN,RIF,MUP
CPT,SXT,LZD,TET,TEI,ERY,TLA,TOB,GEN,VAN,RIF,MUP
FUS,DAP,CLI,LEVO,TEI,ERY,TLA,TOB,GEN,VAN,RIF,MUP
FUS,DAP,CLI,LEVO,NOR,DT1,TLA,TOB,GEN,VAN,RIF,MUP
FUS,DAP,CLI,LEVO,NOR,DT2,MXF,MXF,MXF,MXF,POS,NEG
FUS,DAP,CLI,LEVO,NOR,FOX,FOX,FOX,FOX,FOX2,POS,POS
8 changes: 0 additions & 8 deletions config/CHNMCMM2-conc-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/CHNMCMM2-dilution-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/CHNMCMM2-drug-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/GB1ECSDP-conc-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/GB1ECSDP-dilution-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/GB1ECSDP-drug-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/GPALL1F-conc-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/GPALL1F-dilution-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/GPALL1F-drug-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/UKMYC5-conc-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/UKMYC5-dilution-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/UKMYC5-drug-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/UKMYC6-conc-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/UKMYC6-dilution-matrix.txt

This file was deleted.

8 changes: 0 additions & 8 deletions config/UKMYC6-drug-matrix.txt

This file was deleted.

23 changes: 23 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,29 @@ def test_identify_wells_finds_synthetic_grid(tmp_path: Path) -> None:
assert np.count_nonzero(plate.well_radii) == 6


@pytest.mark.parametrize(
("design", "expected_pos_count"),
[
("EUST2", 2),
("EUSTAPF", 3),
],
)
def test_initialize_plate_layout_for_new_designs(
tmp_path: Path, design: str, expected_pos_count: int
) -> None:
plate = PlateMeasurement(
tmp_path,
categories={"ImageFileName": "plate"},
plate_design=design,
)
plate.initialize_plate_layout()

assert plate.well_drug_name is not None
assert plate.well_drug_name.shape == (8, 12)
assert plate.well_positive_controls_number == expected_pos_count
assert "POS" in plate.drug_names


def test_legacy_arguments_emit_deprecation_warnings(tmp_path: Path) -> None:
with pytest.deprecated_call():
PlateMeasurement(
Expand Down
Loading