From d764fd6160fa0355b46ae035a7aed515a56127ff Mon Sep 17 00:00:00 2001 From: jwuillou8 Date: Sun, 13 Aug 2023 15:49:09 +0100 Subject: [PATCH 1/3] adapted code for pandas2.0, where append is deprecated and replaced by concat 1) file methylprep/files/sample_sheets.py adjusted 2) file methylprep/processing/infer_channel_switch.py adjusted --- methylprep/files/sample_sheets.py | 4 +++- methylprep/processing/infer_channel_switch.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/methylprep/files/sample_sheets.py b/methylprep/files/sample_sheets.py index 5369e5d..a243bb1 100644 --- a/methylprep/files/sample_sheets.py +++ b/methylprep/files/sample_sheets.py @@ -511,5 +511,7 @@ def build_meta_data(self, samples = None): # add the UID that matches m_value/beta value pickles #... unless there's a GSM_ID too row['Sample_ID'] = f"{row['Sentrix_ID']}_{row['Sentrix_Position']}" - meta_frame = meta_frame.append(row, ignore_index=True) + df_row = pd.DataFrame.from_dict(dict(((k,[v]) for k,v in row.items()))) + meta_frame = pd.concat([meta_frame, df_row], ignore_index=True) # jair + return meta_frame diff --git a/methylprep/processing/infer_channel_switch.py b/methylprep/processing/infer_channel_switch.py index c9fd4e4..ed92618 100644 --- a/methylprep/processing/infer_channel_switch.py +++ b/methylprep/processing/infer_channel_switch.py @@ -168,8 +168,8 @@ def get_infer_channel_probes(manifest, green_idat, red_idat, debug=False): green_in_band['unmeth'] = oobR_meth # next, add the green-in-band to oobG and red-in-band to oobR - oobG_IG = oobG.append(green_in_band).sort_index() - oobR_IR = oobR.append(red_in_band).sort_index() + oobG_IG = pd.concat([oobG, green_in_band]).sort_index() + oobR_IR = pd.concat([oobR, red_in_band]).sort_index() # channel swap requires a way to update idats with illumina_ids lookupIR = probe_details_IR.merge( @@ -186,7 +186,8 @@ def get_infer_channel_probes(manifest, green_idat, red_idat, debug=False): right_index=True, suffixes=(False, False), )[['AddressA_ID','AddressB_ID']] - lookup = lookupIG.append(lookupIR).sort_index() + #lookup = lookupIG.append(lookupIR).sort_index() + lookup = pd.concat([lookupIG, lookupIR]).sort_index() if debug: return {'green': oobG_IG, 'red': oobR_IR, 'oobG': oobG, 'oobR':oobR, 'IG': green_in_band, 'IR': red_in_band, 'lookup': lookup} From a0ca70431916377e4e2f3b8ecb88886a0839a9e2 Mon Sep 17 00:00:00 2001 From: jwuillou8 Date: Thu, 17 Aug 2023 10:02:47 +0100 Subject: [PATCH 2/3] removed ug --- methylprep/files/sample_sheets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/methylprep/files/sample_sheets.py b/methylprep/files/sample_sheets.py index a243bb1..bceb3b3 100644 --- a/methylprep/files/sample_sheets.py +++ b/methylprep/files/sample_sheets.py @@ -512,6 +512,7 @@ def build_meta_data(self, samples = None): #... unless there's a GSM_ID too row['Sample_ID'] = f"{row['Sentrix_ID']}_{row['Sentrix_Position']}" df_row = pd.DataFrame.from_dict(dict(((k,[v]) for k,v in row.items()))) - meta_frame = pd.concat([meta_frame, df_row], ignore_index=True) # jair + meta_frame = pd.concat([meta_frame, df_row]) # jair + # meta_frame = pd.concat([meta_frame, df_row], ignore_index=True) # jair return meta_frame From 146173e3db81e36a4ae137c4de24a7bdd2fb2d56 Mon Sep 17 00:00:00 2001 From: jwuillou8 Date: Thu, 17 Aug 2023 17:32:53 +0100 Subject: [PATCH 3/3] simpler row handling --- methylprep/files/sample_sheets.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/methylprep/files/sample_sheets.py b/methylprep/files/sample_sheets.py index bceb3b3..b2cad77 100644 --- a/methylprep/files/sample_sheets.py +++ b/methylprep/files/sample_sheets.py @@ -499,6 +499,7 @@ def build_meta_data(self, samples = None): cols = list(self.fields.values()) + ['Sample_ID'] meta_frame = pd.DataFrame(columns=cols) # row contains the renamed fields, and pulls in the original data from sample_sheet + rows = [] for sample in samples: row = {} for field in self.fields.keys(): @@ -511,8 +512,8 @@ def build_meta_data(self, samples = None): # add the UID that matches m_value/beta value pickles #... unless there's a GSM_ID too row['Sample_ID'] = f"{row['Sentrix_ID']}_{row['Sentrix_Position']}" - df_row = pd.DataFrame.from_dict(dict(((k,[v]) for k,v in row.items()))) - meta_frame = pd.concat([meta_frame, df_row]) # jair - # meta_frame = pd.concat([meta_frame, df_row], ignore_index=True) # jair - + rows.append(row) + + meta_frame = pd.DataFrame(columns=cols, data=rows) + return meta_frame