Skip to content

Commit

Permalink
Small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wflynny committed Jul 1, 2020
1 parent 2564977 commit 32ddc29
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions post_processing/hcs_data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
INDEX_384_C = pd.Index([f"{r}{c}" for r,c in product(ROWS_384, COLS_384)])
INDEX_384_F = pd.Index(INDEX_384_C.values.reshape(len(ROWS_384), -1).ravel(order="F"))


assert len(INDEX_96_C) == len(INDEX_96_F) == 96
assert len(INDEX_384_C) == len(INDEX_384_F) == 384

Expand Down Expand Up @@ -78,7 +79,7 @@ def convert_96_to_384(data_96, name, quad=None, colwise=False):
quads = np.ones(96, dtype=np.uint8) * (quad + 1)

s = pd.DataFrame(data_96, index=index, columns=[name])
s["quad"] = quads
s["Quadrant"] = quads

return s

Expand Down Expand Up @@ -175,8 +176,8 @@ def construct_randomization(self):
quads.append(quad)

randomization_data = pd.concat(quads, axis=0)
randomization_data[["Source row 96", "Source col 96"]] = self.split_row_col(randomization_data["Source well 96"])
randomization_data[["Row 384", "Col 384"]] = self.split_row_col(randomization_data.index)
randomization_data["Source row 96"], randomization_data["Source col 96"] = self.split_row_col(randomization_data["Source well 96"]).values.T
randomization_data["Row 384"], randomization_data["Col 384"] = self.split_row_col(randomization_data.index).values.T
self.data.append(randomization_data)
self.has_randomization = True
self.randomization_mapping = randomization_data.iloc[:,0].to_dict()
Expand Down Expand Up @@ -233,6 +234,7 @@ def register_data(self, measurements={}, randomization=None):

def aggregate_data(self):
merged = pd.concat(self.data, axis=1)
merged.index.name = "Well 384"

for col in merged.columns:
merged[col] = pd.to_numeric(merged[col], errors="ignore")
Expand All @@ -244,9 +246,9 @@ def aggregate_data(self):

def incorporate_plate_variables(self, merged):
if self.variables is not None:
n_plates = daughter_info.shape[1]
n_plates = self.variables.shape[1]
expanded = pd.concat([merged] * n_plates, axis=0)
repeat = lambda x: np.repeat(x, final.shape[0])
repeat = lambda x: np.repeat(x, merged.shape[0])
expanded["plate"] = repeat(np.arange(n_plates, dtype=int) + 1)
for key, row in self.variables.iterrows():
expanded[key] = repeat(row.values)
Expand Down

0 comments on commit 32ddc29

Please sign in to comment.