@@ -119,7 +119,7 @@ def read_scans(fn, source, function_noise, min_scans=1, filter_scan_events=None)
119
119
return scans
120
120
121
121
122
- def average_replicate_scans (name , pls , ppm = 2.0 , min_fraction = 0.8 , rsd_thres = 30.0 , block_size = 5000 , ncpus = None ):
122
+ def average_replicate_scans (name , pls , ppm = 2.0 , min_fraction = 0.8 , rsd_thres = 30.0 , rsd_on = "intensity" , block_size = 5000 , ncpus = None ):
123
123
124
124
emlst = np .array (map (lambda x : x .size == 0 , pls ))
125
125
if np .sum (emlst ) > 0 :
@@ -137,18 +137,26 @@ def average_replicate_scans(name, pls, ppm=2.0, min_fraction=0.8, rsd_thres=30.0
137
137
if v is not None :
138
138
pl_avg .metadata [k ].append (v )
139
139
140
- pl_avg .add_attribute ("snr" , pm .attr_mean_vector ('snr' ), on_index = 2 )
140
+ if rsd_on != "intensity" :
141
+ pl_avg .add_attribute (rsd_on , pm .attr_mean_vector (rsd_on ), on_index = 2 )
142
+ rsd_label = "rsd_{}" .format (rsd_on )
143
+ shift = 1
144
+ else :
145
+ rsd_label = "rsd"
146
+ shift = 0
147
+
148
+ pl_avg .add_attribute ("snr" , pm .attr_mean_vector ('snr' ), on_index = 2 + shift )
141
149
pl_avg .add_attribute ("snr_flag" , np .ones (pl_avg .full_size ), flagged_only = False , is_flag = True )
142
150
143
- pl_avg .add_attribute ("rsd" , pm .rsd (flagged_only = False ), on_index = 5 )
151
+ pl_avg .add_attribute (rsd_label , pm .rsd (on_attr = rsd_on , flagged_only = False ), on_index = 5 + shift )
144
152
145
153
if min_fraction is not None :
146
154
pl_avg .add_attribute ("fraction_flag" , (pm .present / float (pm .shape [0 ])) >= min_fraction , flagged_only = False , is_flag = True )
147
155
if rsd_thres is not None :
148
156
if pm .shape [0 ] == 1 :
149
157
logging .warning ('applying RSD filter on single scan, all peaks removed' )
150
- rsd_flag = map (lambda x : not np .isnan (x ) and x < rsd_thres , pl_avg .get_attribute ("rsd" , flagged_only = False ))
151
- pl_avg .add_attribute ("rsd_flag" , rsd_flag , flagged_only = False , is_flag = True )
158
+ rsd_flag = map (lambda x : not np .isnan (x ) and x < rsd_thres , pl_avg .get_attribute (rsd_label , flagged_only = False ))
159
+ pl_avg .add_attribute ("{}_flag" . format ( rsd_label ) , rsd_flag , flagged_only = False , is_flag = True )
152
160
return pl_avg
153
161
154
162
0 commit comments