Mercurial > repos > mvdbeek > damidseq_consecutive_peaks
diff consecutive_peaks.py @ 1:f3ca59e53b73 draft default tip
planemo upload for repository https://github.com/bardin-lab/damid_galaxy_tools commit c753dd4f3e1863aae7ba45dcc7efdf6937b03542-dirty
author | mvdbeek |
---|---|
date | Mon, 29 Oct 2018 06:49:17 -0400 |
parents | 7f827a8e4ec5 |
children |
line wrap: on
line diff
--- a/consecutive_peaks.py Fri Oct 26 11:58:06 2018 -0400 +++ b/consecutive_peaks.py Mon Oct 29 06:49:17 2018 -0400 @@ -19,11 +19,11 @@ grouped = df.groupby(groupby_column, sort=False) if add_number_of_peaks: df[PEAKS_PER_GROUP] = grouped[groupby_column].transform(np.size) - df[SHIFTED_PADJ_COLUMN] = grouped[8].shift() + df[SHIFTED_PADJ_COLUMN] = grouped[padj_column].shift() df[CONSECUTIVE_MAX] = df[[padj_column, SHIFTED_PADJ_COLUMN]].max(axis=1) grouped = df.groupby(groupby_column, sort=False) - idx = grouped[CONSECUTIVE_MAX].transform(min) # index of groupwise consecutive minimum - new_df = df[df[CONSECUTIVE_MAX] == idx] + idx = grouped[CONSECUTIVE_MAX].idxmin() # index of groupwise consecutive minimum + new_df = df.loc[idx] new_df.sort_values(by=CONSECUTIVE_MAX) new_df[padj_column].replace(new_df[CONSECUTIVE_MAX]) new_df = new_df.drop(labels=[CONSECUTIVE_MAX, SHIFTED_PADJ_COLUMN], axis=1)