def get_notebook_code(self, idx): view = TableView() view.copy_traits(self, view.copyable_trait_names()) return dedent(""" {repr}.plot(ex_{idx}) """.format(repr=repr(view), idx=idx))
def get_notebook_code(self, idx): view = RangeSelection() view.copy_traits(self, view.copyable_trait_names()) return dedent(""" op_{idx}.default_view({traits}).plot(ex_{prev_idx}) """.format(idx=idx, traits=traits_str(view), prev_idx=idx - 1))
def get_notebook_code(self, idx): view = BinningView() view.copy_traits(self, view.copyable_trait_names()) return dedent(""" op_{idx}.default_view({traits}).plot(ex_{idx}) """.format(idx=idx, traits=traits_str(view)))
def get_notebook_code(self, idx): view = BeadCalibrationDiagnostic() view.copy_traits(self, view.copyable_trait_names()) return dedent(""" op_{idx}.default_view({traits}).plot(ex_{prev_idx}) """.format(traits=traits_str(view), idx=idx, prev_idx=idx - 1))
def get_notebook_code(self, idx): view = BleedthroughPiecewiseDiagnostic() view.copy_traits(self, view.copyable_trait_names()) view.subset = self.subset return dedent(""" op_{idx}.default_view({traits}).plot(ex_{prev_idx}) """.format(traits=traits_str(view), idx=idx, prev_idx=idx - 1))
def get_notebook_code(self, idx): view = GaussianMixture1DView() view.copy_traits(self, view.copyable_trait_names()) view.subset = self.subset return dedent(""" op_{idx}.default_view({traits}).plot(ex_{idx}) """.format(traits=traits_str(view), idx=idx))
def get_notebook_code(self, idx): op = BinningOp() op.copy_traits(self, op.copyable_trait_names()) return dedent(""" op_{idx} = {repr} ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """.format(repr=repr(op), idx=idx, prev_idx=idx - 1))
def get_notebook_code(self, idx): view = ThresholdSelection() view.copy_traits(self, view.copyable_trait_names()) plot_params_str = traits_str(self.plot_params) return dedent(""" op_{idx}.default_view({traits}).plot(ex_{prev_idx}{plot_params}) """.format(idx=idx, traits=traits_str(view), prev_idx=idx - 1, plot_params=", " + plot_params_str if plot_params_str else ""))
def get_notebook_code(self, idx): view = ScatterplotView() view.copy_traits(self, view.copyable_trait_names()) plot_params_str = traits_str(self.plot_params) return dedent(""" {repr}.plot(ex_{idx}{plot}{plot_params}) """ .format(repr = repr(view), idx = idx, plot = ", plot_name = " + repr(self.current_plot) if self.plot_names else "", plot_params = ", " + plot_params_str if plot_params_str else ""))
def get_notebook_code(self, idx): view = KMeans2DView() view.copy_traits(self, view.copyable_trait_names()) view.subset = self.subset plot_params_str = traits_str(self.plot_params) return dedent(""" op_{idx}.default_view({traits}).plot(ex_{idx}{plot_params}) """.format(traits=traits_str(view), idx=idx, plot_params=", " + plot_params_str if plot_params_str else ""))
def get_notebook_code(self, idx): op = TransformStatisticOp() op.copy_traits(self, op.copyable_trait_names()) fn_import = {"Mean" : "from numpy import mean", "Geom.Mean" : None, "Count" : None, "Std.Dev" : "from numpy import std", "Geom.SD" : None, "SEM" : "from scipy.stats import sem", "Geom.SEM" : None, "Mean 95% CI" : "from numpy import mean\nmean_ci = lambda x: ci(x, mean, boots = 100)", "Geom.Mean 95% CI" : "geom_mean_ci = lambda x: ci(x, geom_mean, boots = 100)", "Sum" : "from numpy import sum", "Proportion" : "from pandas import Series; proportion = lambda a: Series(a / a.sum())", "Percentage" : "from pandas import Series; percentage = lambda a: Series(a / a.sum()) * 100.0", "Fold" : "from pandas import Series; fold = lambda a: Series(a / a.min())" } fn_name = {"Mean" : "mean", "Geom.Mean" : "geom_mean", "Count" : "len", "Std.Dev" : "std", "Geom.SD" : "geom_sd_range", "SEM" : "sem", "Geom.SEM" : "geom_sem_range", "Mean 95% CI" : "mean_ci", "Geom.Mean 95% CI" : "geom_mean_ci", "Sum" : "sum", "Proportion" : "proportion", "Percentage" : "percentage", "Fold" : "fold" } op.function = transform_functions[self.statistic_name] op.function.__name__ = fn_name[self.statistic_name] return dedent(""" {import_statement} op_{idx} = {repr} ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """ .format(import_statement = (fn_import[self.statistic_name] + "\n" if fn_import[self.statistic_name] is not None else ""), repr = repr(op), idx = idx, prev_idx = idx - 1)) pass
def get_notebook_code(self, idx): op = KMeansOp() op.copy_traits(self, op.copyable_trait_names()) return dedent(""" op_{idx} = {repr} op_{idx}.estimate(ex_{prev_idx}{subset}) ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """.format(repr=repr(op), idx=idx, prev_idx=idx - 1, subset=", subset = " + repr(self.subset) if self.subset else ""))
def get_notebook_code(self, idx): return dedent(""" # Autofluorescence op_{idx}_af.default_view().plot(ex_{prev_idx}) # Bleedthrough op_{idx}_bleedthrough.default_view().plot(ex_{idx}_af) # Bead calibration op_{idx}_beads.default_view().plot(ex_{idx}_bleedthrough) # Color translation op_{idx}_color.default_view().plot(ex_{idx}_beads) """.format(idx=idx, prev_idx=idx - 1))
def get_notebook_code(self, idx): view = FlowPeaks2DView() view.copy_traits(self, view.copyable_trait_names()) view.subset = self.subset if self.show_density: plot_params_str = traits_str(self.density_plot_params) else: plot_params_str = traits_str(self.scatterplot_plot_params) return dedent(""" op_{idx}.default_view({traits}).plot(ex_{idx}{plot_params}) """.format(traits=traits_str(view), idx=idx, plot_params=", " + plot_params_str if plot_params_str else ""))
def get_notebook_code(self, idx): view = RadvizView() view.copy_traits(self, view.copyable_trait_names()) for channel in self.channels_list: view.channels.append(channel.channel) view.scale[channel.channel] = channel.scale plot_params_str = traits_str(self.plot_params) return dedent(""" {repr}.plot(ex_{idx}{plot}{plot_params}) """ .format(repr = repr(view), idx = idx, plot = ", plot_name = " + repr(self.current_plot) if self.plot_names else "", plot_params = ", " + plot_params_str if plot_params_str else ""))
def get_notebook_code(self, idx): op = ColorTranslationOp() op.copy_traits(self, op.copyable_trait_names()) for control in self.controls_list: op.controls[(control.from_channel, control.to_channel)] = control.file return dedent(""" op_{idx} = {repr} op_{idx}.estimate(ex_{prev_idx}{subset}) ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """ .format(repr = repr(op), idx = idx, prev_idx = idx - 1, subset = ", subset = " + repr(self.subset) if self.subset else ""))
def get_notebook_code(self, idx): op = BleedthroughLinearOp() op.copy_traits(self, op.copyable_trait_names()) for control in self.controls_list: op.controls[control.channel] = control.file return dedent(""" op_{idx} = {repr} op_{idx}.estimate(ex_{prev_idx}{subset}) ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """ .format(repr = repr(op), idx = idx, prev_idx = idx - 1, subset = ", subset = " + repr(self.subset) if self.subset else ""))
def get_notebook_code(self, idx): op = ChannelStatisticOp() op.copy_traits(self, op.copyable_trait_names()) fn_import = {"Mean" : "from numpy import mean", "Geom.Mean" : None, "Count" : None, "Std.Dev" : "from numpy import std", "Geom.SD" : None, "SEM" : "from scipy.stats import sem", "Geom.SEM" : None, "Mean 95% CI" : "from numpy import mean\nmean_ci = lambda x: ci(x, mean, boots = 100)", "Geom.Mean 95% CI" : "geom_mean_ci = lambda x: ci(x, geom_mean, boots = 100)" } fn_name = {"Mean" : "mean", "Geom.Mean" : "geom_mean", "Count" : "len", "Std.Dev" : "std", "Geom.SD" : "geom_sd_range", "SEM" : "sem", "Geom.SEM" : "geom_sem_range", "Mean 95% CI" : "mean_ci", "Geom.Mean 95% CI" : "geom_mean_ci" } op.function = summary_functions[self.statistic_name] try: # this doesn't work for builtins like "len" op.function.__name__ = fn_name[self.statistic_name] except: pass return dedent(""" {import_statement} op_{idx} = {repr} ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """ .format(import_statement = (fn_import[self.statistic_name] + "\n" if fn_import[self.statistic_name] is not None else ""), repr = repr(op), idx = idx, prev_idx = idx - 1))
def get_notebook_code(self, idx): op = PCAOp() op.copy_traits(self, op.copyable_trait_names()) for channel in self.channels_list: op.channels.append(channel.channel) op.scale[channel.channel] = channel.scale return dedent(""" op_{idx} = {repr} op_{idx}.estimate(ex_{prev_idx}{subset}) ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """ .format(repr = repr(op), idx = idx, prev_idx = idx - 1, subset = ", subset = " + repr(self.subset) if self.subset else ""))
def get_notebook_code(self, idx): op = BeadCalibrationOp() op.copy_traits(self, op.copyable_trait_names()) for unit in self.units_list: op.units[unit.channel] = unit.unit op.beads = self.BEADS[self.beads_name] return dedent(""" # Beads: {beads} op_{idx} = {repr} op_{idx}.estimate(ex_{prev_idx}) ex_{idx} = op_{idx}.apply(ex_{prev_idx}) """.format(beads=self.beads_name, repr=repr(op), idx=idx, prev_idx=idx - 1))
def get_notebook_code(self, idx): self._af_op.channels = self.channels self._af_op.blank_file = self.blank_file self._bleedthrough_op.controls.clear() for control in self.bleedthrough_list: self._bleedthrough_op.controls[control.channel] = control.file self._bead_calibration_op.beads = BeadCalibrationOp.BEADS[self.beads_name] self._bead_calibration_op.beads_file = self.beads_file self._bead_calibration_op.bead_peak_quantile = self.bead_peak_quantile self._bead_calibration_op.bead_brightness_threshold = self.bead_brightness_threshold self._bead_calibration_op.bead_brightness_cutoff = self.bead_brightness_cutoff self._bead_calibration_op.units.clear() self._bead_calibration_op.units[self.to_channel] = self.beads_unit self._color_translation_op.mixture_model = self.mixture_model self._color_translation_op.controls.clear() for control in self.translation_list: self._color_translation_op.controls[(control.from_channel, control.to_channel)] = control.file return dedent(""" # the TASBE-style calibration is not a single Cytoflow module. Instead, it # is a specific sequence of four calibrations: autofluorescence correction, # bleedthrough, bead calibration and color translation. # autofluorescence op_{idx}_af = {af_repr} op_{idx}_af.estimate(ex_{prev_idx}{subset}) ex_{idx}_af = op_{idx}_af.apply(ex_{prev_idx}) # bleedthrough op_{idx}_bleedthrough = {bleedthrough_repr} op_{idx}_bleedthrough.estimate(ex_{idx}_af{subset}) ex_{idx}_bleedthrough = op_{idx}_bleedthrough.apply(ex_{idx}_af) # bead calibration # beads: {beads} op_{idx}_beads = {beads_repr} op_{idx}_beads.estimate(ex_{idx}_bleedthrough) ex_{idx}_beads = op_{idx}_beads.apply(ex_{idx}_bleedthrough) # color translation op_{idx}_color = {color_repr} op_{idx}_color.estimate(ex_{idx}_beads{subset}) ex_{idx} = op_{idx}_color.apply(ex_{idx}_beads) """ .format(idx = idx, prev_idx = idx - 1, af_repr = repr(self._af_op), bleedthrough_repr = repr(self._bleedthrough_op), color_repr = repr(self._color_translation_op), beads = self.beads_name, beads_repr = repr(self._bead_calibration_op), subset = ", subset = " + repr(self.subset) if self.subset else ""))