Skip to content

Commit

Permalink
Modify M1 summary centroid calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
bkieft-usa committed May 13, 2024
1 parent 9946469 commit f960571
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions metatlas/io/feature_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ def calculate_ms1_summary(df, feature_filter=True):
summary['label'].append(label_group)
summary['num_datapoints'].append(label_data['i'].count())
summary['peak_area'].append(label_data['i'].sum())
sum_intensity = label_data['i'].sum()
idx = label_data['i'].idxmax()
summary['peak_height'].append(label_data.loc[idx,'i'])
summary['mz_centroid'].append(sum(label_data['i']*label_data['mz'])/sum_intensity)
summary['mz_centroid'].append(sum(label_data['i']*label_data['mz'])/summary['peak_area'])
summary['rt_peak'].append(label_data.loc[idx,'rt'])

return pd.DataFrame(summary)
Expand Down Expand Up @@ -482,4 +481,4 @@ def group_duplicates(df,group_col,make_string=False,precision={'i':0,'mz':4,'rt'
# df['peak_height']=np.diag(intensity[:,idx_max]) #I shouldn't have to do this and must be doing numpy slicing wrong!
# df['mz_centroid']=np.divide(np.sum(np.multiply(mz,intensity),axis=1),intensity.sum(axis=1))
# df['rt_peak']=rt[idx_max]
# return df
# return df

0 comments on commit f960571

Please sign in to comment.