def galaxy_extra(self, id=None, *args, **kwargs): from pyqlb.nstats.well import above_min_amplitude_peaks from qtools.lib.mplot import galaxy_extracluster, cleanup, render as plt_render from qtools.lib.nstats.peaks import extracluster_peaks response.content_type = 'image/png' qlwell = self.__qlwell_from_threshold_form(id) self.__set_threshold_context(qlwell) channel_idx = int(request.params.get("channel", 0)) peaks = above_min_amplitude_peaks(qlwell) threshold = c.vic_threshold if channel_idx == 1 else c.fam_threshold extra_data = extracluster_peaks(qlwell, channel_idx, threshold=threshold) extra_peaks, rain_boundaries, width_gates = extra_data pos, midhigh, midlow, neg = rain_boundaries min_gate, max_gate = width_gates title = 'GalaxyEX - %s, %s, %s' % (c.well.plate.plate.name, c.well.well_name, 'VIC' if channel_idx == 1 else 'FAM') fig = galaxy_extracluster(title, peaks, channel_idx, threshold, min_gate, max_gate, pos, midhigh, midlow, neg, extra_peaks, min_amplitude_excluded=True) imgdata = plt_render(fig, dpi=72) cleanup(fig) return imgdata
def compute(self, qlwell, qlwell_channel, well_channel_metric): # only return for >= 1000 peaks if len(qlwell.peaks) < 1000: return well_channel_metric data = extracluster_peaks(qlwell, qlwell_channel.channel_num, threshold=qlwell_channel.statistics.threshold) peaks, rain_gates, width_gates = data # have to worry about min amplitude peaks here # found in well_metric but don't have access to wm in compute() above_min_amp_peaks = above_min_amplitude_peaks(qlwell) if len(above_min_amp_peaks) == 0: well_channel_metric.extracluster = 0 else: well_channel_metric.extracluster = float(len(peaks))/len(above_min_amp_peaks) if hasattr(qlwell, 'sum_amplitude_bins') and len(qlwell.sum_amplitude_bins) > 0: data = revb_extracluster_peaks(qlwell, qlwell_channel.channel_num, threshold=qlwell_channel.statistics.threshold) peaks, rain_gates, mean_amps = data if len(above_min_amp_peaks) == 0: well_channel_metric.revb_extracluster = 0 else: well_channel_metric.revb_extracluster = float(len(peaks))/len(above_min_amp_peaks) else: well_channel_metric.revb_extracluster = None return well_channel_metric