Skip to content

Commit

Permalink
Fix case where integer plate names where treated as ints, not strs
Browse files Browse the repository at this point in the history
Down to this still open at time of writing 2.5 year old bug:
pandas-dev/pandas#9435
  • Loading branch information
alubbock committed Aug 25, 2017
1 parent 5126b8c commit f9b5521
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pydrc/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def read_vanderbilt_hts_single_df(file_or_source, plate_width=24,
d: datetime.strptime(
d, '%Y-%m-%d').date()
},
index_col=['upid', 'well'],
sep="\t"
)

df.set_index(['upid', 'well'], inplace=True)

return df


Expand Down Expand Up @@ -118,16 +119,21 @@ def read_vanderbilt_hts(file_or_source, plate_width=24, plate_height=16):
df_doses.sort_index(inplace=True)

# df_controls
df_controls = df[["cell.line", "time", 'cell.count']].xs(0, level='well')
df_controls.reset_index(inplace=True)
df_controls.columns = ['plate', 'cell_line', 'timepoint', 'value']
df_controls = df_controls.assign(well_id=list(
["{}__{}".format(a_, b_) for a_, b_ in
zip(df_controls['plate'], itertools.repeat(0))]))
df_controls['assay'] = assay_name
df_controls.set_index(['assay', 'cell_line', 'plate', 'well_id',
'timepoint'], inplace=True)
df_controls.sort_index(inplace=True)
try:
df_controls = df[["cell.line", "time", 'cell.count']].xs(0, level='well')
except KeyError:
df_controls = None

if df_controls is not None:
df_controls.reset_index(inplace=True)
df_controls.columns = ['plate', 'cell_line', 'timepoint', 'value']
df_controls = df_controls.assign(well_id=list(
["{}__{}".format(a_, b_) for a_, b_ in
zip(df_controls['plate'], itertools.repeat(0))]))
df_controls['assay'] = assay_name
df_controls.set_index(['assay', 'cell_line', 'plate', 'well_id',
'timepoint'], inplace=True)
df_controls.sort_index(inplace=True)

# df_vals
df_vals = df[['time', 'cell.count']]
Expand Down

0 comments on commit f9b5521

Please sign in to comment.