Browse Source

remove custom normalization map

normilization of exposure time is always to the largest time available
xmlparsing
Holger Frey 4 years ago
parent
commit
0ac616648c
  1. 12
      CHANGES.md
  2. 2
      sensospot_data/__init__.py
  3. 23
      sensospot_data/normalisation.py
  4. 11
      tests/test_normailsation.py

12
CHANGES.md

@ -1,3 +1,15 @@ @@ -1,3 +1,15 @@
0.2.0 - remove custom normalization map
----------------------------------------
- normilization of exposure time is always to the largest time available
0.1.0 - first working version
------------------------------
- woohoo
0.0.1 - first version
----------------------

2
sensospot_data/__init__.py

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
Parsing the numerical output from Sensovations Sensospot image analysis.
"""
__version__ = "0.1.0"
__version__ = "0.2.0"
VERSION_TABLE_NAME = f"v{__version__}".replace(".", "_")

23
sensospot_data/normalisation.py

@ -123,21 +123,14 @@ def _infer_normalization_map(split_data_frames): @@ -123,21 +123,14 @@ def _infer_normalization_map(split_data_frames):
}
def normalize_exposure_time(split_data_frames, normalization_map=None):
def normalize_exposure_time(split_data_frames):
""" add time normalized values to the split data frames
normalization_map:
keys: channel identifier (e.g. "Cy5")
values: target exposure time for normalization
If normalization_map is None, the max exposure time per channel is used
The max exposure time per channel is used for normalization.
"""
complete_map = _infer_normalization_map(split_data_frames)
if normalization_map is not None:
complete_map.update(normalization_map)
normalization_map = _infer_normalization_map(split_data_frames)
return {
key: _normalize_exposure(frame, complete_map[key])
key: _normalize_exposure(frame, normalization_map[key])
for key, frame in split_data_frames.items()
}
@ -157,7 +150,6 @@ def _normalize_exposure(channel_frame, normalized_time): @@ -157,7 +150,6 @@ def _normalize_exposure(channel_frame, normalized_time):
def normalize_measurement(
data_frame,
exposure_map=None,
normalization_map=None,
overflow_column=COL_NAME_SPOT_MEAN,
overflow_limit=0.5,
):
@ -169,14 +161,11 @@ def normalize_measurement( @@ -169,14 +161,11 @@ def normalize_measurement(
if the exposure map is None, the values from the optionally parsed
measurement parameters are used.
normalization_map:
keys: channel identifier (e.g. "Cy5")
values: target exposure time for normalization
If normalization_map is None, the max exposure time per channel is used
The max exposure time per channel is used for normalization.
"""
exposure_data_frame = apply_exposure_map(data_frame, exposure_map)
split_data_frames = reduce_overflow(
exposure_data_frame, overflow_column, overflow_limit
)
return normalize_exposure_time(split_data_frames, normalization_map)
return normalize_exposure_time(split_data_frames)

11
tests/test_normailsation.py

@ -228,7 +228,7 @@ def test_normalize_exposure(normalization_data_frame): @@ -228,7 +228,7 @@ def test_normalize_exposure(normalization_data_frame):
sorted_results = result.sort_values(
by=["Well.Row", "Well.Column", "Pos.Id"]
)
expected_values = [2, 8, 30, 2, 20, 20, 20, 20, 200, 200, 200, 200]
expected_values = [1, 4, 15, 1, 10, 10, 10, 10, 100, 100, 100, 100]
for normalized_col in COLUMN_NORMALIZATION.values():
list(sorted_results[normalized_col]) == expected_values
@ -241,14 +241,14 @@ def test_normalize_exposure_time(normalization_data_frame): @@ -241,14 +241,14 @@ def test_normalize_exposure_time(normalization_data_frame):
)
reduced = reduce_overflow(normalization_data_frame, "Saturation", 1)
result = normalize_exposure_time(reduced, {"Cy5": 100, "Cy3": 0})
result = normalize_exposure_time(reduced)
assert "Cy5" in result
sorted_results = result["Cy5"].sort_values(
by=["Well.Row", "Well.Column", "Pos.Id"]
)
expected_values = [2, 8, 30, 2, 20, 20, 20, 20, 200, 200, 200, 200]
expected_values = [1, 4, 15, 1, 10, 10, 10, 10, 100, 100, 100, 100]
assert list(sorted_results["Normalized.Spot.Mean"]) == expected_values
@ -284,11 +284,10 @@ def test_normalize_measurement(example_dir): @@ -284,11 +284,10 @@ def test_normalize_measurement(example_dir):
2: ExposureSetting("Cy5", 15),
3: ExposureSetting("Cy5", 150),
}
normalization_map = {"Cy5": 25}
result = normalize_measurement(data_frame, exposure_map, normalization_map)
result = normalize_measurement(data_frame, exposure_map)
cy3_df, cy5_df = result["Cy3"], result["Cy5"]
assert set(result.keys()) == {"Cy3", "Cy5"}
assert cy3_df["Normalized.Exposure.Time"].unique() == 100
assert cy5_df["Normalized.Exposure.Time"].unique() == 25
assert cy5_df["Normalized.Exposure.Time"].unique() == 150

Loading…
Cancel
Save