Browse Source

function mbp.normalize() now only normalizes available columns

main
Holger Frey 1 year ago
parent
commit
e0a0d09bd4
  1. 25
      src/conda_helpers/mbp.py

25
src/conda_helpers/mbp.py

@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
import contextlib
import pandas as pd
from sensospot_tools import (
normalize as normalize_xdr_data,
@ -7,10 +9,15 @@ from sensospot_tools import ( @@ -7,10 +9,15 @@ from sensospot_tools import (
split,
)
# column names
EXPOSURE_ID = "Exposure.Id"
EXPOSURE_CHANNEL = "Exposure.Channel"
EXPOSURE_TIME = "Exposure.Time"
EXPOSURE_TIME_NORMALIZED = "Exposure.Time.Normalized"
NET_SIGNAL = "NetSignal"
SPOT_SATURATION = "Spot.Saturation"
TEST_OVERFLOW = "Test.Spot.Overflow"
EXPOSURE_COLUMNS = [
EXPOSURE_ID,
@ -19,11 +26,6 @@ EXPOSURE_COLUMNS = [ @@ -19,11 +26,6 @@ EXPOSURE_COLUMNS = [
EXPOSURE_TIME_NORMALIZED,
]
SATURATION_LIMIT = 2
SPOT_SATURATION = "Spot.Saturation"
TEST_OVERFLOW = "Test.Spot.Overflow"
SPOT_ID_COLUMNS = ["Analysis.Name", "Well.Name", "Pos.Id"]
TIME_DEPENDENT_COLUMNS = [
@ -37,6 +39,8 @@ TIME_DEPENDENT_COLUMNS = [ @@ -37,6 +39,8 @@ TIME_DEPENDENT_COLUMNS = [
"Spot.Sum",
]
SATURATION_LIMIT = 2
def add_exposure_info(data: pd.DataFrame, analysis="hyb") -> pd.DataFrame:
time_cy3 = 100 if "1" in analysis else 200
@ -61,7 +65,7 @@ def normalize(raw_data: pd.DataFrame, analysis="hyb"): @@ -61,7 +65,7 @@ def normalize(raw_data: pd.DataFrame, analysis="hyb"):
_normalize_channel(data)
for _, data in split(overflow_tested, EXPOSURE_CHANNEL)
)
return pd.concat(normalized_data).reset_index()
return pd.concat(normalized_data).reset_index(drop=True)
def _normalize_channel(data: pd.DataFrame) -> pd.DataFrame:
@ -72,10 +76,17 @@ def _normalize_channel(data: pd.DataFrame) -> pd.DataFrame: @@ -72,10 +76,17 @@ def _normalize_channel(data: pd.DataFrame) -> pd.DataFrame:
available_columns = [
c for c in hdr_data.columns if c in TIME_DEPENDENT_COLUMNS
]
return normalize_xdr_data(
normalized = normalize_xdr_data(
hdr_data,
normalized_time,
EXPOSURE_TIME,
available_columns,
"{}.Normalized",
)
with contextlib.suppress(KeyError):
normalized[NET_SIGNAL] = (
normalized["Spot.Mean.Normalized"]
- normalized["Bkg.Median.Normalized"]
)
return normalized

Loading…
Cancel
Save