def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} widget2_layout = {'width': '10%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} divider_button_layout = {'width': '40%'} div_row1 = Button(description='---Domain Options---', disabled=True, layout=divider_button_layout) param_name1 = Button(description='type_of_death_model', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'tan' self.type_of_death_model = FloatText(value=1, step=0.1, style=style, layout=widget_layout) param_name2 = Button(description='initial_tumor_radius', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'lightgreen' self.initial_tumor_radius = FloatText(value=150, step=10, style=style, layout=widget_layout) div_row2 = Button(description='---Apoptosis---', disabled=True, layout=divider_button_layout) param_name3 = Button(description='apoptosis_rate', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'lightgreen' self.apoptosis_rate = FloatText(value=0.0014, step=0.0001, style=style, layout=widget_layout) div_row3 = Button(description='---Necrosis---', disabled=True, layout=divider_button_layout) param_name4 = Button(description='necrosis_rate', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.necrosis_rate = FloatText(value=0.00277777777, step=0.0001, style=style, layout=widget_layout) param_name5 = Button(description='necrosis_type', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'lightgreen' self.necrosis_type = FloatText(value=2, step=0.1, style=style, layout=widget_layout) param_name6 = Button(description='o2_necrosis_threshold', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.o2_necrosis_threshold = FloatText(value=5.0, step=0.1, style=style, layout=widget_layout) param_name7 = Button(description='o2_necrosis_max', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'lightgreen' self.o2_necrosis_max = FloatText(value=2.5, step=0.1, style=style, layout=widget_layout) div_row4 = Button(description='---Fluid change rates---', disabled=True, layout=divider_button_layout) param_name8 = Button(description='cytoplasmic_biomass_change_rate', disabled=True, layout=name_button_layout) param_name8.style.button_color = 'tan' self.cytoplasmic_biomass_change_rate = FloatText(value=0.01666666, step=0.001, style=style, layout=widget_layout) param_name9 = Button(description='nuclear_biomass_change_rate', disabled=True, layout=name_button_layout) param_name9.style.button_color = 'lightgreen' self.nuclear_biomass_change_rate = FloatText(value=0.00583333333, step=0.001, style=style, layout=widget_layout) param_name10 = Button(description='lysed_fluid_change_rate', disabled=True, layout=name_button_layout) param_name10.style.button_color = 'tan' self.lysed_fluid_change_rate = FloatText(value=0.00083333333, step=0.0001, style=style, layout=widget_layout) param_name11 = Button(description='unlysed_fluid_change_rate', disabled=True, layout=name_button_layout) param_name11.style.button_color = 'lightgreen' self.unlysed_fluid_change_rate = FloatText(value=0.01666666, step=0.001, style=style, layout=widget_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='micrometer', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'lightgreen' units_button4 = Button(description='', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'tan' units_button5 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'lightgreen' units_button6 = Button(description='', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'lightgreen' units_button7 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'tan' units_button8 = Button(description='', disabled=True, layout=units_button_layout) units_button8.style.button_color = 'lightgreen' units_button9 = Button(description='mmHG', disabled=True, layout=units_button_layout) units_button9.style.button_color = 'tan' units_button10 = Button(description='mmHG', disabled=True, layout=units_button_layout) units_button10.style.button_color = 'lightgreen' units_button11 = Button(description='', disabled=True, layout=units_button_layout) units_button11.style.button_color = 'lightgreen' units_button12 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button12.style.button_color = 'tan' units_button13 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button13.style.button_color = 'lightgreen' units_button14 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button14.style.button_color = 'tan' units_button15 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button15.style.button_color = 'lightgreen' desc_button2 = Button(description='1->apoptosis 2->necrosis', tooltip='1->apoptosis 2->necrosis', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button(description='initial tumor radius', tooltip='initial tumor radius', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button5 = Button(description='mean apoptosis rate', tooltip='mean apoptosis rate', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button(description='mean necrosis rate', tooltip='mean necrosis rate', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' desc_button7 = Button(description='1->deterministic 2->stochastic', tooltip='1->deterministic 2->stochastic', disabled=True, layout=desc_button_layout) desc_button7.style.button_color = 'lightgreen' desc_button10 = Button( description='oxygen threshold level for dying with necrotic death', tooltip='oxygen threshold level for dying with necrotic death', disabled=True, layout=desc_button_layout) desc_button10.style.button_color = 'tan' desc_button11 = Button( description= 'oxygen threshold level for maximum rate of necrotic death', tooltip='oxygen threshold level for maximum rate of necrotic death', disabled=True, layout=desc_button_layout) desc_button11.style.button_color = 'lightgreen' desc_button12 = Button( description= 'rate of degradation for solids in the cytoplasm other than the nucleus', tooltip= 'rate of degradation for solids in the cytoplasm other than the nucleus', disabled=True, layout=desc_button_layout) desc_button12.style.button_color = 'tan' desc_button13 = Button( description='rate of degradation for nucleus solids', tooltip='rate of degradation for nucleus solids', disabled=True, layout=desc_button_layout) desc_button13.style.button_color = 'lightgreen' desc_button14 = Button( description= 'rate of fluid change (cytoplasmic fluid) after cell lysis ', tooltip= 'rate of fluid change (cytoplasmic fluid) after cell lysis ', disabled=True, layout=desc_button_layout) desc_button14.style.button_color = 'tan' desc_button15 = Button( description= 'rate of fluid change (cytoplasmic fluid) before cell lysis', tooltip= 'rate of fluid change (cytoplasmic fluid) before cell lysis', disabled=True, layout=desc_button_layout) desc_button15.style.button_color = 'lightgreen' row2 = [ param_name1, self.type_of_death_model, units_button2, desc_button2 ] row3 = [ param_name2, self.initial_tumor_radius, units_button3, desc_button3 ] row5 = [param_name3, self.apoptosis_rate, units_button5, desc_button5] row6 = [param_name4, self.necrosis_rate, units_button7, desc_button6] row7 = [param_name5, self.necrosis_type, units_button8, desc_button7] row10 = [ param_name6, self.o2_necrosis_threshold, units_button9, desc_button10 ] row11 = [ param_name7, self.o2_necrosis_max, units_button10, desc_button11 ] row12 = [ param_name8, self.cytoplasmic_biomass_change_rate, units_button12, desc_button12 ] row13 = [ param_name9, self.nuclear_biomass_change_rate, units_button13, desc_button13 ] row14 = [ param_name10, self.lysed_fluid_change_rate, units_button14, desc_button14 ] row15 = [ param_name11, self.unlysed_fluid_change_rate, units_button15, desc_button15 ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box10 = Box(children=row10, layout=box_layout) box11 = Box(children=row11, layout=box_layout) box12 = Box(children=row12, layout=box_layout) box13 = Box(children=row13, layout=box_layout) box14 = Box(children=row14, layout=box_layout) box15 = Box(children=row15, layout=box_layout) self.tab = VBox([ div_row1, box2, box3, div_row2, box5, div_row3, box6, box7, box10, box11, div_row4, box12, box13, box14, box15, ])
def _widget(self): """ Create IPython widget for display within a notebook """ try: return self._cached_widget except AttributeError: pass from ipywidgets import Layout, VBox, HBox, IntText, Button, HTML, Accordion layout = Layout(width="150px") if "dashboard" in self.scheduler.services: link = self.dashboard_link link = '<p><b>Dashboard: </b><a href="%s" target="_blank">%s</a></p>\n' % ( link, link, ) else: link = "" title = "<h2>%s</h2>" % type(self).__name__ title = HTML(title) dashboard = HTML(link) status = HTML(self._widget_status(), layout=Layout(min_width="150px")) request = IntText(0, description="Workers", layout=layout) scale = Button(description="Scale", layout=layout) minimum = IntText(0, description="Minimum", layout=layout) maximum = IntText(0, description="Maximum", layout=layout) adapt = Button(description="Adapt", layout=layout) accordion = Accordion( [HBox([request, scale]), HBox([minimum, maximum, adapt])], layout=Layout(min_width="500px"), ) accordion.selected_index = None accordion.set_title(0, "Manual Scaling") accordion.set_title(1, "Adaptive Scaling") box = VBox([title, HBox([status, accordion]), dashboard]) self._cached_widget = box def adapt_cb(b): self.adapt(minimum=minimum.value, maximum=maximum.value) adapt.on_click(adapt_cb) def scale_cb(b): with log_errors(): n = request.value with ignoring(AttributeError): self._adaptive.stop() self.scale(n) scale.on_click(scale_cb) scheduler_ref = ref(self.scheduler) def update(): status.value = self._widget_status() pc = PeriodicCallback(update, 500, io_loop=self.scheduler.loop) self.scheduler.periodic_callbacks["cluster-repr"] = pc pc.start() return box
def multi_label_annotate(examples, example_labels=None, options=None, shuffle=False, display_fn=display, include_skip=False, save_file='annotations'): """ Build an interactive widget for annotating a list of input examples. Parameters ---------- examples: list(any), list of items to annotate example_labels: list(string), if examples are one large numpy array options: Dict dictionary of category names and category classes ex {'gender':['male', 'female', 'unisex']} shuffle: bool, shuffle the examples before annotating display_fn: func, function for displaying an example to the user Returns ------- annotations : defaultdict of dicts, dict of annotated examples (example, {task:[label... label],task2:[label]}) """ examples = list(examples) use_example_labels = True if example_labels is None: use_example_labels = False example_labels = examples if shuffle: ind_shuff = np.arange(len(examples)) # set seed random.Random(42).shuffle(ind_shuff) examples = examples[ind_shuff] example_labels = example_labels[ind_shuff] annotation_dict = defaultdict(dict) all_buttons = [] current_index = -1 def set_label_text(): nonlocal count_label if current_index < len(examples): count_label.value = ( '{} examples annotated, {} examples left<br>Asset name: <code>{}</code><hr>' .format(len(annotation_dict), len(examples) - current_index, example_labels[current_index])) else: count_label.value = '{} examples annotated, {} examples left<br>Annoation done.<hr>'.format( len(annotation_dict), len(examples) - current_index) def save_current(): nonlocal current_index np.save(save_file + '{:d}.npy'.format(current_index), annotation_dict) def show_next(): clear_colors() nonlocal current_index current_index += 1 set_label_text() if current_index >= len(examples): for btn in buttons: btn.disabled = True with out: clear_output() return with out: clear_output(wait=True) display_fn(examples[current_index]) def go_back(): clear_colors() nonlocal current_index current_index -= 1 if current_index < 0: print('cannot go back') return with out: clear_output(wait=True) try: del annotation_dict[example_labels[current_index]] set_label_text() display_fn(examples[current_index]) except KeyError: print("Key 'testing' not found") def del_current_annotation(): nonlocal current_index del annotation_dict[example_labels[current_index]] current_index -= 1 show_next() def add_annotation(annotation_dict, annotation, task_name): if task_name not in annotation_dict[ example_labels[current_index]].keys(): annotation_dict[example_labels[current_index]][task_name] = [ annotation ] else: # check if the annotation is already in the `annotation_dict`, if so, that means # it has been clicked a second time, and we should remove both the color and # the annotation if annotation in annotation_dict[ example_labels[current_index]][task_name]: annotation_dict[example_labels[current_index]][ task_name].remove(annotation) else: annotation_dict[example_labels[current_index]][ task_name].append(annotation) def skip(btn): show_next() def done(btn): show_next() def save(btn): save_current() def back(btn): go_back() def clear_annotation(btn): del_current_annotation() def clear_colors(): nonlocal all_buttons for button in all_buttons: button.style.button_color = None count_label = HTML() set_label_text() display(count_label) if type(options) == dict: task_type = 'classification' else: raise ValueError('Invalid options. Must be classification dictionary.') if task_type == 'classification': for key, value in options.items(): buttons = [] print(key) for label in value: btn = MultiLabelButton(description=label, task_name=key) def on_click(label, task_name, btn): # if button has a color, clear it! if not, give it a color! if btn.style.button_color is None: btn.style.button_color = 'lightgreen' else: btn.style.button_color = None add_annotation(annotation_dict, label, task_name) btn.button.on_click( functools.partial(on_click, label, btn.task_name)) buttons.append(btn.button) all_buttons.append(btn.button) box = HBox(buttons) display(box) print('') buttons = [] btn = Button(description='done') btn.on_click(skip) buttons.append(btn) btn = Button(description='back') btn.on_click(back) buttons.append(btn) btn = Button(description='clear current') btn.on_click(clear_annotation) buttons.append(btn) btn = Button(description='save') btn.on_click(save) buttons.append(btn) if include_skip: btn = Button(description='skip') btn.on_click(skip) buttons.append(btn) all_buttons += buttons box = HBox(buttons) display(box) out = Output() display(out) show_next() return annotation_dict
if not o.layout.flex: o.layout.flex = '0 0 auto' # export def carousel(children=(), **layout): "A horizontally scrolling carousel" def_layout = dict(overflow='scroll hidden', flex_flow='row', display='flex') res = Box([], layout=merge(def_layout, layout)) res.observe(_update_children, names='children') res.children = children return res # + ts = [VBox([widget(im, max_width='192px'), Button(description='click')]) for o in range(3)] carousel(ts, width='450px') # - # export def _open_thumb(fn, h, w): return Image.open(fn).to_thumb(h, w).convert('RGBA') # export class ImagesCleaner: "A widget that displays all images in `fns` along with a `Dropdown`" def __init__(self, opts=(), height=128, width=256, max_n=30):
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} param_name1 = Button(description='immune_activation_time', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'lightgreen' self.immune_activation_time = FloatText(value=20160, step=1000, style=style, layout=widget_layout) param_name2 = Button(description='number_of_immune_cells', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'tan' self.number_of_immune_cells = IntText(value=125, step=10, style=style, layout=widget_layout) param_name3 = Button(description='save_interval_after_therapy_start', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'lightgreen' self.save_interval_after_therapy_start = FloatText( value=60, step=1, style=style, layout=widget_layout) param_name4 = Button(description='immune_apoptosis_rate', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.immune_apoptosis_rate = FloatText(value=6.944e-5, step=1e-05, style=style, layout=widget_layout) param_name5 = Button(description='oncoprotein_threshold', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'lightgreen' self.oncoprotein_threshold = FloatText(value=0.1, step=0.01, style=style, layout=widget_layout) param_name6 = Button(description='immune_kill_rate', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.immune_kill_rate = FloatText(value=0.8762, step=0.1, style=style, layout=widget_layout) param_name7 = Button(description='immune_attachment_rate', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'lightgreen' self.immune_attachment_rate = FloatText(value=0.72138388, step=0.1, style=style, layout=widget_layout) param_name8 = Button(description='immune_attachment_lifetime', disabled=True, layout=name_button_layout) param_name8.style.button_color = 'tan' self.immune_attachment_lifetime = FloatText(value=90.0, step=1, style=style, layout=widget_layout) param_name9 = Button(description='immune_migration_bias', disabled=True, layout=name_button_layout) param_name9.style.button_color = 'lightgreen' self.immune_migration_bias = FloatText(value=0.679587213, step=0.1, style=style, layout=widget_layout) param_name10 = Button(description='immune_motility_persistence_time', disabled=True, layout=name_button_layout) param_name10.style.button_color = 'tan' self.immune_motility_persistence_time = FloatText(value=10, step=1, style=style, layout=widget_layout) param_name11 = Button(description='immune_migration_speed', disabled=True, layout=name_button_layout) param_name11.style.button_color = 'lightgreen' self.immune_migration_speed = FloatText(value=1.0, step=0.1, style=style, layout=widget_layout) param_name12 = Button(description='tumor_radius', disabled=True, layout=name_button_layout) param_name12.style.button_color = 'tan' self.tumor_radius = FloatText(value=250, step=10, style=style, layout=widget_layout) param_name13 = Button(description='tumor_mean_immunogenicity', disabled=True, layout=name_button_layout) param_name13.style.button_color = 'lightgreen' self.tumor_mean_immunogenicity = FloatText(value=1.0, step=0.1, style=style, layout=widget_layout) param_name14 = Button( description='tumor_immunogenicity_standard_deviation', disabled=True, layout=name_button_layout) param_name14.style.button_color = 'tan' self.tumor_immunogenicity_standard_deviation = FloatText( value=0.25, step=0.01, style=style, layout=widget_layout) units_button1 = Button(description='min', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='min', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'lightgreen' units_button4 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'tan' units_button5 = Button(description='', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'lightgreen' units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'tan' units_button7 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'lightgreen' units_button8 = Button(description='min', disabled=True, layout=units_button_layout) units_button8.style.button_color = 'tan' units_button9 = Button(description='', disabled=True, layout=units_button_layout) units_button9.style.button_color = 'lightgreen' units_button10 = Button(description='min', disabled=True, layout=units_button_layout) units_button10.style.button_color = 'tan' units_button11 = Button(description='micron/min', disabled=True, layout=units_button_layout) units_button11.style.button_color = 'lightgreen' units_button12 = Button(description='micron', disabled=True, layout=units_button_layout) units_button12.style.button_color = 'tan' units_button13 = Button(description='', disabled=True, layout=units_button_layout) units_button13.style.button_color = 'lightgreen' units_button14 = Button(description='', disabled=True, layout=units_button_layout) units_button14.style.button_color = 'tan' desc_button1 = Button(description='time at which therapy begins', disabled=True, layout=desc_button_layout) desc_button1.style.button_color = 'lightgreen' desc_button2 = Button( description='number of immune cells at start of therapy', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button( description='save (output) interval after therapy begins', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button4 = Button(description='immune cell apoptosis rate (d1)', disabled=True, layout=desc_button_layout) desc_button4.style.button_color = 'tan' desc_button5 = Button( description= 'cancer cells are not immunogenic for p below this value (d2)', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button( description= 'rate that attached immune cells can apoptose cancer cells (d3)', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' desc_button7 = Button( description= 'rate that immune cells can attach to a cell in close contact (d4)', disabled=True, layout=desc_button_layout) desc_button7.style.button_color = 'lightgreen' desc_button8 = Button( description= 'max time immune cells remain attached to a target cell (d5)', disabled=True, layout=desc_button_layout) desc_button8.style.button_color = 'tan' desc_button9 = Button(description='immune cell migration bias (d6)', disabled=True, layout=desc_button_layout) desc_button9.style.button_color = 'lightgreen' desc_button10 = Button( description='mean immune cell migration persistence time', disabled=True, layout=desc_button_layout) desc_button10.style.button_color = 'tan' desc_button11 = Button(description='immune cell migration speed', disabled=True, layout=desc_button_layout) desc_button11.style.button_color = 'lightgreen' desc_button12 = Button(description='initial tumor radius', disabled=True, layout=desc_button_layout) desc_button12.style.button_color = 'tan' desc_button13 = Button(description='mean oncoprotein p at start', disabled=True, layout=desc_button_layout) desc_button13.style.button_color = 'lightgreen' desc_button14 = Button( description='standard deviation of tumor p at start', disabled=True, layout=desc_button_layout) desc_button14.style.button_color = 'tan' row1 = [ param_name1, self.immune_activation_time, units_button1, desc_button1 ] row2 = [ param_name2, self.number_of_immune_cells, units_button2, desc_button2 ] row3 = [ param_name3, self.save_interval_after_therapy_start, units_button3, desc_button3 ] row4 = [ param_name4, self.immune_apoptosis_rate, units_button4, desc_button4 ] row5 = [ param_name5, self.oncoprotein_threshold, units_button5, desc_button5 ] row6 = [ param_name6, self.immune_kill_rate, units_button6, desc_button6 ] row7 = [ param_name7, self.immune_attachment_rate, units_button7, desc_button7 ] row8 = [ param_name8, self.immune_attachment_lifetime, units_button8, desc_button8 ] row9 = [ param_name9, self.immune_migration_bias, units_button9, desc_button9 ] row10 = [ param_name10, self.immune_motility_persistence_time, units_button10, desc_button10 ] row11 = [ param_name11, self.immune_migration_speed, units_button11, desc_button11 ] row12 = [ param_name12, self.tumor_radius, units_button12, desc_button12 ] row13 = [ param_name13, self.tumor_mean_immunogenicity, units_button13, desc_button13 ] row14 = [ param_name14, self.tumor_immunogenicity_standard_deviation, units_button14, desc_button14 ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box8 = Box(children=row8, layout=box_layout) box9 = Box(children=row9, layout=box_layout) box10 = Box(children=row10, layout=box_layout) box11 = Box(children=row11, layout=box_layout) box12 = Box(children=row12, layout=box_layout) box13 = Box(children=row13, layout=box_layout) box14 = Box(children=row14, layout=box_layout) self.tab = VBox([ box1, box2, box3, box4, box5, box6, box7, box8, box9, box10, box11, box12, box13, box14, ])
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} widget2_layout = {'width': '10%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} menv_var1 = Button(description='electrical_potential (volt)', disabled=True, layout=name_button_layout) menv_var1.style.button_color = 'tan' param_name1 = Button(description='diffusion_coefficient', disabled=True, layout=name_button_layout) self.electrical_potential_diffusion_coefficient = FloatText( value=0, step=0.01, style=style, layout=widget_layout) param_name2 = Button(description='decay_rate', disabled=True, layout=name_button_layout) self.electrical_potential_decay_rate = FloatText(value=0, step=0.01, style=style, layout=widget_layout) param_name3 = Button(description='initial_condition', disabled=True, layout=name_button_layout) self.electrical_potential_initial_condition = FloatText( value=0, style=style, layout=widget_layout) param_name4 = Button(description='Dirichlet_boundary_condition', disabled=True, layout=name_button_layout) self.electrical_potential_Dirichlet_boundary_condition = FloatText( value=0, style=style, layout=widget_layout) self.electrical_potential_Dirichlet_boundary_condition_toggle = Checkbox( description='on/off', disabled=False, style=style, layout=widget_layout) menv_var2 = Button(description='quorum_factor_1', disabled=True, layout=name_button_layout) menv_var2.style.button_color = 'lightgreen' param_name5 = Button(description='diffusion_coefficient', disabled=True, layout=name_button_layout) self.quorum_factor_1_diffusion_coefficient = FloatText( value=50000, step=1000, style=style, layout=widget_layout) param_name6 = Button(description='decay_rate', disabled=True, layout=name_button_layout) self.quorum_factor_1_decay_rate = FloatText(value=0.1, step=0.01, style=style, layout=widget_layout) param_name7 = Button(description='initial_condition', disabled=True, layout=name_button_layout) self.quorum_factor_1_initial_condition = FloatText( value=0.0, style=style, layout=widget_layout) param_name8 = Button(description='Dirichlet_boundary_condition', disabled=True, layout=name_button_layout) self.quorum_factor_1_Dirichlet_boundary_condition = FloatText( value=0, style=style, layout=widget_layout) self.quorum_factor_1_Dirichlet_boundary_condition_toggle = Checkbox( description='on/off', disabled=False, style=style, layout=widget_layout) menv_var3 = Button(description='quorum_factor_2', disabled=True, layout=name_button_layout) menv_var3.style.button_color = 'tan' param_name9 = Button(description='diffusion_coefficient', disabled=True, layout=name_button_layout) self.quorum_factor_2_diffusion_coefficient = FloatText( value=50000, step=1000, style=style, layout=widget_layout) param_name10 = Button(description='decay_rate', disabled=True, layout=name_button_layout) self.quorum_factor_2_decay_rate = FloatText(value=0.1, step=0.01, style=style, layout=widget_layout) param_name11 = Button(description='initial_condition', disabled=True, layout=name_button_layout) self.quorum_factor_2_initial_condition = FloatText( value=0.0, style=style, layout=widget_layout) param_name12 = Button(description='Dirichlet_boundary_condition', disabled=True, layout=name_button_layout) self.quorum_factor_2_Dirichlet_boundary_condition = FloatText( value=0, style=style, layout=widget_layout) self.quorum_factor_2_Dirichlet_boundary_condition_toggle = Checkbox( description='on/off', disabled=False, style=style, layout=widget_layout) self.calculate_gradient = Checkbox(description='calculate_gradients', disabled=False, layout=desc_button_layout) self.track_internal = Checkbox(description='track_in_agents', disabled=False, layout=desc_button_layout) # ------- micronenv info menv_units_button1 = Button(description='micron^2/min', disabled=True, layout=units_button_layout) menv_units_button2 = Button(description='1/min', disabled=True, layout=units_button_layout) menv_units_button3 = Button(description='mmHg', disabled=True, layout=units_button_layout) menv_units_button4 = Button(description='mmHg', disabled=True, layout=units_button_layout) menv_units_button5 = Button(description='micron^2/min', disabled=True, layout=units_button_layout) menv_units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) menv_units_button7 = Button(description='mmHg', disabled=True, layout=units_button_layout) menv_units_button8 = Button(description='mmHg', disabled=True, layout=units_button_layout) menv_units_button9 = Button(description='micron^2/min', disabled=True, layout=units_button_layout) menv_units_button10 = Button(description='1/min', disabled=True, layout=units_button_layout) menv_units_button11 = Button(description='mmHg', disabled=True, layout=units_button_layout) menv_units_button12 = Button(description='mmHg', disabled=True, layout=units_button_layout) row_electrical_potential = [ menv_var1, ] row1 = [ param_name1, self.electrical_potential_diffusion_coefficient, menv_units_button1 ] row2 = [ param_name2, self.electrical_potential_decay_rate, menv_units_button2 ] row3 = [ param_name3, self.electrical_potential_initial_condition, menv_units_button3 ] row4 = [ param_name4, self.electrical_potential_Dirichlet_boundary_condition, menv_units_button4, self.electrical_potential_Dirichlet_boundary_condition_toggle ] row_quorum_factor_1 = [ menv_var2, ] row5 = [ param_name5, self.quorum_factor_1_diffusion_coefficient, menv_units_button5 ] row6 = [ param_name6, self.quorum_factor_1_decay_rate, menv_units_button6 ] row7 = [ param_name7, self.quorum_factor_1_initial_condition, menv_units_button7 ] row8 = [ param_name8, self.quorum_factor_1_Dirichlet_boundary_condition, menv_units_button8, self.quorum_factor_1_Dirichlet_boundary_condition_toggle ] row_quorum_factor_2 = [ menv_var3, ] row9 = [ param_name9, self.quorum_factor_2_diffusion_coefficient, menv_units_button9 ] row10 = [ param_name10, self.quorum_factor_2_decay_rate, menv_units_button10 ] row11 = [ param_name11, self.quorum_factor_2_initial_condition, menv_units_button11 ] row12 = [ param_name12, self.quorum_factor_2_Dirichlet_boundary_condition, menv_units_button12, self.quorum_factor_2_Dirichlet_boundary_condition_toggle ] row13 = [ self.calculate_gradient, ] row14 = [ self.track_internal, ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box_electrical_potential = Box(children=row_electrical_potential, layout=box_layout) box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box_quorum_factor_1 = Box(children=row_quorum_factor_1, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box8 = Box(children=row8, layout=box_layout) box_quorum_factor_2 = Box(children=row_quorum_factor_2, layout=box_layout) box9 = Box(children=row9, layout=box_layout) box10 = Box(children=row10, layout=box_layout) box11 = Box(children=row11, layout=box_layout) box12 = Box(children=row12, layout=box_layout) box13 = Box(children=row13, layout=box_layout) box14 = Box(children=row14, layout=box_layout) self.tab = VBox([ box_electrical_potential, box1, box2, box3, box4, box_quorum_factor_1, box5, box6, box7, box8, box_quorum_factor_2, box9, box10, box11, box12, box13, box14, ])
def __init__(self): self.output_dir = '.' # self.output_dir = 'tmpdir' # self.fig = plt.figure(figsize=(7.2,6)) # this strange figsize results in a ~square contour plot # initial value self.field_index = 4 # self.field_index = self.mcds_field.value + 4 tab_height = '500px' constWidth = '180px' constWidth2 = '150px' tab_layout = Layout( width='900px', # border='2px solid black', height=tab_height, ) #overflow_y='scroll') max_frames = 1 self.mcds_plot = interactive(self.plot_substrate, frame=(0, max_frames), continuous_update=False) svg_plot_size = '700px' self.mcds_plot.layout.width = svg_plot_size self.mcds_plot.layout.height = svg_plot_size self.max_frames = BoundedIntText( min=0, max=99999, value=max_frames, description='Max', layout=Layout(width='160px'), ) self.max_frames.observe(self.update_max_frames) self.field_min_max = {'dummy': [0., 1.]} # hacky I know, but make a dict that's got (key,value) reversed from the dict in the Dropdown below self.field_dict = {0: 'dummy'} self.mcds_field = Dropdown( options={'dummy': 0}, value=0, # description='Field', layout=Layout(width=constWidth)) # print("substrate __init__: self.mcds_field.value=",self.mcds_field.value) # self.mcds_field.observe(self.mcds_field_cb) self.mcds_field.observe(self.mcds_field_changed_cb) # self.field_cmap = Text( # value='viridis', # description='Colormap', # disabled=True, # layout=Layout(width=constWidth), # ) self.field_cmap = Dropdown( options=['viridis', 'jet', 'YlOrRd'], value='viridis', # description='Field', layout=Layout(width=constWidth)) #self.field_cmap.observe(self.plot_substrate) # self.field_cmap.observe(self.plot_substrate) self.field_cmap.observe(self.mcds_field_cb) self.cmap_fixed = Checkbox( description='Fix', disabled=False, # layout=Layout(width=constWidth2), ) self.save_min_max = Button( description='Save', #style={'description_width': 'initial'}, button_style= 'success', # 'success', 'info', 'warning', 'danger' or '' tooltip='Save min/max for this substrate', disabled=True, layout=Layout(width='90px')) def save_min_max_cb(b): # field_name = self.mcds_field.options[] # field_name = next(key for key, value in self.mcds_field.options.items() if value == self.mcds_field.value) field_name = self.field_dict[self.mcds_field.value] # print(field_name) # self.field_min_max = {'oxygen': [0., 30.], 'glucose': [0., 1.], 'H+ ions': [0., 1.], 'ECM': [0., 1.], 'NP1': [0., 1.], 'NP2': [0., 1.]} self.field_min_max[field_name][0] = self.cmap_min.value self.field_min_max[field_name][1] = self.cmap_max.value # print(self.field_min_max) self.save_min_max.on_click(save_min_max_cb) self.cmap_min = FloatText( description='Min', value=0, step=0.1, disabled=True, layout=Layout(width=constWidth2), ) self.cmap_min.observe(self.mcds_field_cb) self.cmap_max = FloatText( description='Max', value=38, step=0.1, disabled=True, layout=Layout(width=constWidth2), ) self.cmap_max.observe(self.mcds_field_cb) def cmap_fixed_cb(b): if (self.cmap_fixed.value): self.cmap_min.disabled = False self.cmap_max.disabled = False self.save_min_max.disabled = False else: self.cmap_min.disabled = True self.cmap_max.disabled = True self.save_min_max.disabled = True # self.mcds_field_cb() self.cmap_fixed.observe(cmap_fixed_cb) field_cmap_row2 = HBox([self.field_cmap, self.cmap_fixed]) # field_cmap_row3 = HBox([self.save_min_max, self.cmap_min, self.cmap_max]) items_auto = [ self.save_min_max, #layout=Layout(flex='3 1 auto', width='auto'), self.cmap_min, self.cmap_max, ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='80%') field_cmap_row3 = Box(children=items_auto, layout=box_layout) # field_cmap_row3 = Box([self.save_min_max, self.cmap_min, self.cmap_max]) # mcds_tab = widgets.VBox([mcds_dir, mcds_plot, mcds_play], layout=tab_layout) mcds_params = VBox([ self.mcds_field, field_cmap_row2, field_cmap_row3, self.max_frames ]) # mcds_dir # mcds_params = VBox([self.mcds_field, field_cmap_row2, field_cmap_row3,]) # mcds_dir # self.tab = HBox([mcds_params, self.mcds_plot], layout=tab_layout) # self.tab = HBox([mcds_params, self.mcds_plot]) help_label = Label('select slider: drag or left/right arrows') row1 = Box([ help_label, Box([self.max_frames, self.mcds_field, self.field_cmap], layout=Layout(border='0px solid black', width='50%', height='', align_items='stretch', flex_direction='row', display='flex')) ]) row2 = Box([self.cmap_fixed, self.cmap_min, self.cmap_max], layout=Layout(border='0px solid black', width='50%', height='', align_items='stretch', flex_direction='row', display='flex')) self.tab = VBox([row1, row2, self.mcds_plot])
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} param_name1 = Button(description='Volume', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'lightgreen' self.Volume = Text(value='"Parameters"', style=style, layout=widget_layout) param_name2 = Button(description='Volume_target_solid_cytoplasmic', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'tan' self.Volume_target_solid_cytoplasmic = FloatText(value=488.5, step=10, style=style, layout=widget_layout) param_name3 = Button(description='Volume_target_solid_nuclear', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'lightgreen' self.Volume_target_solid_nuclear = FloatText(value=135.0, step=10, style=style, layout=widget_layout) param_name4 = Button(description='Volume_target_fluid_fraction', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.Volume_target_fluid_fraction = FloatText(value=0.75, step=0.1, style=style, layout=widget_layout) param_name5 = Button( description='Volume_cytoplasmic_biomass_change_rate', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'lightgreen' self.Volume_cytoplasmic_biomass_change_rate = FloatText( value=0.0045, step=0.001, style=style, layout=widget_layout) param_name6 = Button(description='Volume_nuclear_biomass_change_rate', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.Volume_nuclear_biomass_change_rate = FloatText( value=0.0055, step=0.001, style=style, layout=widget_layout) param_name7 = Button(description='Volume_fluid_change_rate', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'lightgreen' self.Volume_fluid_change_rate = FloatText(value=0.05, step=0.01, style=style, layout=widget_layout) param_name8 = Button(description='Volume_calcification_rate', disabled=True, layout=name_button_layout) param_name8.style.button_color = 'tan' self.Volume_calcification_rate = FloatText(value=0.0, step=0.01, style=style, layout=widget_layout) param_name9 = Button(description='Volume_Total', disabled=True, layout=name_button_layout) param_name9.style.button_color = 'lightgreen' self.Volume_Total = FloatText(value=2494, step=100, style=style, layout=widget_layout) param_name10 = Button(description='Volume_solid', disabled=True, layout=name_button_layout) param_name10.style.button_color = 'tan' self.Volume_solid = FloatText(value=623.5, step=10, style=style, layout=widget_layout) param_name11 = Button(description='Volume_fluid', disabled=True, layout=name_button_layout) param_name11.style.button_color = 'lightgreen' self.Volume_fluid = FloatText(value=1870.5, step=100, style=style, layout=widget_layout) param_name12 = Button(description='Volume_fluid_fraction', disabled=True, layout=name_button_layout) param_name12.style.button_color = 'tan' self.Volume_fluid_fraction = FloatText(value=0.75, step=0.1, style=style, layout=widget_layout) param_name13 = Button(description='Volume_nuclear', disabled=True, layout=name_button_layout) param_name13.style.button_color = 'lightgreen' self.Volume_nuclear = FloatText(value=540.0, step=10, style=style, layout=widget_layout) param_name14 = Button(description='Volume_nuclear_solid', disabled=True, layout=name_button_layout) param_name14.style.button_color = 'tan' self.Volume_nuclear_solid = FloatText(value=135.0, step=10, style=style, layout=widget_layout) param_name15 = Button(description='Volume_nuclear_fluid', disabled=True, layout=name_button_layout) param_name15.style.button_color = 'lightgreen' self.Volume_nuclear_fluid = FloatText(value=405.0, step=10, style=style, layout=widget_layout) param_name16 = Button(description='Volume_cytoplasmic', disabled=True, layout=name_button_layout) param_name16.style.button_color = 'tan' self.Volume_cytoplasmic = FloatText(value=1954.0, step=100, style=style, layout=widget_layout) param_name17 = Button(description='Volume_cytoplasmic_solid', disabled=True, layout=name_button_layout) param_name17.style.button_color = 'lightgreen' self.Volume_cytoplasmic_solid = FloatText(value=488.5, step=10, style=style, layout=widget_layout) param_name18 = Button(description='Volume_cytoplasmic_fluid', disabled=True, layout=name_button_layout) param_name18.style.button_color = 'tan' self.Volume_cytoplasmic_fluid = FloatText(value=1465.5, step=100, style=style, layout=widget_layout) param_name19 = Button(description='Volume_clacification_fraction', disabled=True, layout=name_button_layout) param_name19.style.button_color = 'lightgreen' self.Volume_clacification_fraction = FloatText(value=0.0, step=0.01, style=style, layout=widget_layout) param_name20 = Button( description='Volume_cytoplasmic_to_nuclear_ratio', disabled=True, layout=name_button_layout) param_name20.style.button_color = 'tan' self.Volume_cytoplasmic_to_nuclear_ratio = FloatText( value=3.6, step=0.1, style=style, layout=widget_layout) param_name21 = Button(description='use_function_multiply_by_ratio', disabled=True, layout=name_button_layout) param_name21.style.button_color = 'lightgreen' self.use_function_multiply_by_ratio = Checkbox(value=False, style=style, layout=widget_layout) param_name22 = Button(description='multiplication_ratio_value', disabled=True, layout=name_button_layout) param_name22.style.button_color = 'tan' self.multiplication_ratio_value = FloatText(value=2.0, step=0.1, style=style, layout=widget_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'lightgreen' units_button4 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'tan' units_button5 = Button(description='cubic_micron/min', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'lightgreen' units_button6 = Button(description='cubic_micron/min', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'tan' units_button7 = Button(description='cubic_micron/min', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'lightgreen' units_button8 = Button(description='cubic_micron/min', disabled=True, layout=units_button_layout) units_button8.style.button_color = 'tan' units_button9 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button9.style.button_color = 'lightgreen' units_button10 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button10.style.button_color = 'tan' units_button11 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button11.style.button_color = 'lightgreen' units_button12 = Button(description='', disabled=True, layout=units_button_layout) units_button12.style.button_color = 'tan' units_button13 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button13.style.button_color = 'lightgreen' units_button14 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button14.style.button_color = 'tan' units_button15 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button15.style.button_color = 'lightgreen' units_button16 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button16.style.button_color = 'tan' units_button17 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button17.style.button_color = 'lightgreen' units_button18 = Button(description='cubic_micron', disabled=True, layout=units_button_layout) units_button18.style.button_color = 'tan' units_button19 = Button(description='', disabled=True, layout=units_button_layout) units_button19.style.button_color = 'lightgreen' units_button20 = Button(description='', disabled=True, layout=units_button_layout) units_button20.style.button_color = 'tan' units_button21 = Button(description='', disabled=True, layout=units_button_layout) units_button21.style.button_color = 'lightgreen' units_button22 = Button(description='', disabled=True, layout=units_button_layout) units_button22.style.button_color = 'tan' desc_button1 = Button(description='', disabled=True, layout=desc_button_layout) desc_button1.style.button_color = 'lightgreen' desc_button2 = Button(description='', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button(description='', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button4 = Button(description='', disabled=True, layout=desc_button_layout) desc_button4.style.button_color = 'tan' desc_button5 = Button(description='', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button(description='', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' desc_button7 = Button(description='', disabled=True, layout=desc_button_layout) desc_button7.style.button_color = 'lightgreen' desc_button8 = Button(description='', disabled=True, layout=desc_button_layout) desc_button8.style.button_color = 'tan' desc_button9 = Button(description='', disabled=True, layout=desc_button_layout) desc_button9.style.button_color = 'lightgreen' desc_button10 = Button(description='', disabled=True, layout=desc_button_layout) desc_button10.style.button_color = 'tan' desc_button11 = Button(description='', disabled=True, layout=desc_button_layout) desc_button11.style.button_color = 'lightgreen' desc_button12 = Button(description='', disabled=True, layout=desc_button_layout) desc_button12.style.button_color = 'tan' desc_button13 = Button(description='', disabled=True, layout=desc_button_layout) desc_button13.style.button_color = 'lightgreen' desc_button14 = Button(description='', disabled=True, layout=desc_button_layout) desc_button14.style.button_color = 'tan' desc_button15 = Button(description='', disabled=True, layout=desc_button_layout) desc_button15.style.button_color = 'lightgreen' desc_button16 = Button(description='', disabled=True, layout=desc_button_layout) desc_button16.style.button_color = 'tan' desc_button17 = Button(description='', disabled=True, layout=desc_button_layout) desc_button17.style.button_color = 'lightgreen' desc_button18 = Button(description='', disabled=True, layout=desc_button_layout) desc_button18.style.button_color = 'tan' desc_button19 = Button(description='', disabled=True, layout=desc_button_layout) desc_button19.style.button_color = 'lightgreen' desc_button20 = Button(description='', disabled=True, layout=desc_button_layout) desc_button20.style.button_color = 'tan' desc_button21 = Button(description='', disabled=True, layout=desc_button_layout) desc_button21.style.button_color = 'lightgreen' desc_button22 = Button(description='', disabled=True, layout=desc_button_layout) desc_button22.style.button_color = 'tan' row1 = [param_name1, self.Volume, units_button1, desc_button1] row2 = [ param_name2, self.Volume_target_solid_cytoplasmic, units_button2, desc_button2 ] row3 = [ param_name3, self.Volume_target_solid_nuclear, units_button3, desc_button3 ] row4 = [ param_name4, self.Volume_target_fluid_fraction, units_button4, desc_button4 ] row5 = [ param_name5, self.Volume_cytoplasmic_biomass_change_rate, units_button5, desc_button5 ] row6 = [ param_name6, self.Volume_nuclear_biomass_change_rate, units_button6, desc_button6 ] row7 = [ param_name7, self.Volume_fluid_change_rate, units_button7, desc_button7 ] row8 = [ param_name8, self.Volume_calcification_rate, units_button8, desc_button8 ] row9 = [param_name9, self.Volume_Total, units_button9, desc_button9] row10 = [ param_name10, self.Volume_solid, units_button10, desc_button10 ] row11 = [ param_name11, self.Volume_fluid, units_button11, desc_button11 ] row12 = [ param_name12, self.Volume_fluid_fraction, units_button12, desc_button12 ] row13 = [ param_name13, self.Volume_nuclear, units_button13, desc_button13 ] row14 = [ param_name14, self.Volume_nuclear_solid, units_button14, desc_button14 ] row15 = [ param_name15, self.Volume_nuclear_fluid, units_button15, desc_button15 ] row16 = [ param_name16, self.Volume_cytoplasmic, units_button16, desc_button16 ] row17 = [ param_name17, self.Volume_cytoplasmic_solid, units_button17, desc_button17 ] row18 = [ param_name18, self.Volume_cytoplasmic_fluid, units_button18, desc_button18 ] row19 = [ param_name19, self.Volume_clacification_fraction, units_button19, desc_button19 ] row20 = [ param_name20, self.Volume_cytoplasmic_to_nuclear_ratio, units_button20, desc_button20 ] row21 = [ param_name21, self.use_function_multiply_by_ratio, units_button21, desc_button21 ] row22 = [ param_name22, self.multiplication_ratio_value, units_button22, desc_button22 ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box8 = Box(children=row8, layout=box_layout) box9 = Box(children=row9, layout=box_layout) box10 = Box(children=row10, layout=box_layout) box11 = Box(children=row11, layout=box_layout) box12 = Box(children=row12, layout=box_layout) box13 = Box(children=row13, layout=box_layout) box14 = Box(children=row14, layout=box_layout) box15 = Box(children=row15, layout=box_layout) box16 = Box(children=row16, layout=box_layout) box17 = Box(children=row17, layout=box_layout) box18 = Box(children=row18, layout=box_layout) box19 = Box(children=row19, layout=box_layout) box20 = Box(children=row20, layout=box_layout) box21 = Box(children=row21, layout=box_layout) box22 = Box(children=row22, layout=box_layout) self.tab = VBox([ box1, box2, box3, box4, box5, box6, box7, box8, box9, box10, box11, box12, box13, box14, box15, box16, box17, box18, box19, box20, box21, box22, ])
def create_tables(): """Create essential cbm tables """ data_path = config.get_value(['paths', 'temp']) l_tb = Label("""Add a short name as prefix for the tables, max 15 characters e.g.:escat2020.""") try: with open(normpath(join(data_path, 'tb_prefix')), 'r') as f: prefix = f.read() except Exception: prefix = '' tb_prefix = Text(value=prefix, placeholder='xx2010', description='Table prefix:', disabled=False) checkboxes = {} tbs = db_tables.tables_dict() for key in tbs: checkboxes[key] = Checkbox(value=True, description=tbs[key]['name'], disabled=False, indent=False, layout=Layout(width='150px')) checkboxes["aois"].value = False check_box = HBox([checkboxes[t] for t in checkboxes]) bt_create_tb = Button(description='Create tables', value=False, disabled=False, button_style='info', tooltip='Creat tables', icon='fa-table') progress = Output() def outlog(*text): with progress: print(*text) def on_tb_prefix(change): with open(normpath(join(data_path, 'tb_prefix')), 'w+') as f: f.write(tb_prefix.value.replace(' ', '').lower()[:15]) tb_prefix.observe(on_tb_prefix, 'value') @bt_create_tb.on_click def bt_create_tb_on_click(b): progress.clear_output() tb_prefix_clean = tb_prefix.value.replace(' ', '').lower()[:15] if tb_prefix.value != '': for key in tbs: if checkboxes[key].value is True: if db.tb_exist( f"{tb_prefix_clean}_{tbs[key]['table']}") is False: sql = tbs[key]['sql'].replace('\n', '').replace(' ', '') db.execute_sql(sql.format(tb_prefix_clean)) outlog( f"The table {tb_prefix_clean}_{tbs[key]['table']} is created.." ) else: outlog( f"The table {tb_prefix_clean}_{tbs[key]['table']} already exist." ) else: outlog("Please add tables prefix.") wbox = VBox([l_tb, tb_prefix, check_box, bt_create_tb, progress]) return wbox
def annotate( examples, task_type='classification', options=None, shuffle=False, include_next=True, include_back=True, stop_at_last_example=True, use_dropdown=False, buttons_in_a_row=4, reset_buttons_after_click=True, example_process_fn=None, final_process_fn=None, display_fn=display, example_column='example', value_column='label', id_column='id', return_type='dataframe', ): """ Build an interactive widget for annotating a list or DataFrame of input examples. Parameters ---------- examples : list or pandas.DataFrame This can be a list of any type or a Pandas dataframe. If using a DataFrame, make sure that at least the example_column is set to the column holding the examples. When a DataFrame of a previous annotation is provided, it can be relabeled and shows previous selected labels. task_type : str Possible options are: - classification - multilabel-classification - regression - captioning options : list, tuple, or None Depending on the task this can be: - list of str for (multilabel) classification. - tuple with a range for regression tasks - None (actually ignored) for captioning shuffle : bool, shuffle the examples before annotating include_skip : bool, include option to skip example while annotating include_back : bool, include option to navigate to previous example use_dropdown : bool, use a dropdown or buttons during classification buttons_in_a_row : int, number of buttons in a row during classification reset_buttons_after_click : bool, reset multi-label buttons after each click example_process_fn : function, hooked function to call after each example fn(ix, labels) final_process_fn : function, hooked function to call after annotation is done fn(annotations) display_fn : function, function for displaying an example to the user Default, it uses the IPython display function example_column : str, column name which holds all examples. Required when using DataFrame value_column : str column to store the result for classification (not for multilabel), regression, captioning. For multilabel, each option will be a column in the dataframe. id_column : str, optional Column name which holds the id of the example. If available, will be shown in the progress row. return_type : str, 'dataframe' or 'dict' By default, annotate will return a DataFrame with the annotations. For compatability, when return_type is 'dict' it can also return a dictionary with changed annotations. Returns ------- annotations : pandas.DataFrame or dict Depending on return_type it will return a DataFrame (preferred) or a dict with the annotations. The dict will have the form: {example: label} and only return the labeled examples that are changed (using the submit button). The DataFrame will have a column with the examples and if it is multilabel, a column for each label. For regular classification, the labeled values are in the value_column. When a DataFrame is used as input, all other columns such as id, are kept intact. """ # Parameter checkes task_type = task_type.lower() if task_type not in [ 'classification', 'multilabel-classification', 'regression', 'captioning', ]: raise ValueError( "task_type should be 'classification', 'multilabel-classification', 'regression', or 'captioning'" ) if not isinstance(examples, (list, pd.DataFrame)): raise TypeError('examples should be of type list or pandas.DataFrame') if task_type == 'regression': if not isinstance(options, tuple): raise TypeError( 'options should be of type tuple for regression tasks') if len(options) != 2 and len(options) != 3: raise ValueError( 'options should be a tuple (min, max) or (min, max, step)') if task_type in ['multilabel-classification', 'classification']: if not isinstance(options, list): raise TypeError( 'options should be of type list for classification tasks') return_type = return_type.lower() if return_type not in ['dataframe', 'dict']: raise TypeError("return_type should be 'dataframe' or 'dict'") # create annotations object as DataFrame if isinstance(examples, pd.DataFrame): # Examples is a dataframe annotations = examples.copy() annotations['changed'] = False else: # Examples is a list annotations = pd.DataFrame({ example_column: examples, 'changed': False, }) # add options as columns if isinstance(options, list): # list of labels if task_type == 'classification': annotations[value_column] = '' else: for label in options: if label not in annotations.columns: annotations[label] = False elif isinstance(options, tuple): # regression if value_column not in annotations.columns: annotations[value_column] = 0 else: # captioning if value_column not in annotations.columns: annotations[value_column] = '' # shuffle if needed if shuffle: annotations = annotations.sample(frac=1).copy() current_index = -1 annotations_dict = {} def set_label_text(index): """ Create info string with annotation progress """ nonlocal count_label labeled = len(annotations.loc[annotations['changed']]) str_output = f'{labeled} of {len(annotations)} Examples annotated, Current Position: {index + 1} ' if id_column in annotations.columns and index >= 0 and index < len( annotations): ix = annotations.iloc[index].name str_output += f"(id: {annotations.at[ix, id_column]}) " count_label.value = str_output def render(index): """ Render current index of the annotation """ set_label_text(index) if index >= len(annotations): if stop_at_last_example: print('Annotation done.') if final_process_fn is not None: final_process_fn(annotations) for button in buttons: button.disabled = True set_label_text(index - 1) else: prev_example() return # render buttons ix = annotations.iloc[index].name for button in buttons: if button.description == 'prev': # disable previous button when at first example button.disabled = index <= 0 elif button.description == 'next': # disable skip button when at last example button.disabled = index >= len(annotations) - 1 elif button.description != 'submit': if task_type == 'classification': if annotations.at[ix, value_column] == button.description: button.icon = 'check' else: button.icon = '' elif task_type == 'multilabel-classification': button.value = bool(annotations.at[ix, button.description]) # render dropdown if use_dropdown: current_value = annotations.at[ix, value_column] if current_value in dd.options: dd.value = current_value # slider while regression if task_type == 'regression': slider.value = annotations.at[ix, value_column] # captioning if task_type == 'captioning': ta.value = annotations.at[ix, value_column] # display new example with out: clear_output(wait=True) display_fn(annotations.at[ix, example_column]) def add_annotation(annotation): """ Toggle annotation """ if return_type == 'dict': annotations_dict[annotations.at[current_index, example_column]] = annotation ix = annotations.iloc[current_index].name if task_type == 'multilabel-classification': for label in options: annotations.at[ix, label] = label in annotation else: # multi-class, regression, captioning annotations.at[ix, value_column] = annotation annotations.at[ix, 'changed'] = True if example_process_fn is not None: example_process_fn(annotations.at[ix, example_column], annotation) next_example() def next_example(button=None): """ Increase current index """ nonlocal current_index if current_index < len(annotations): current_index += 1 render(current_index) def prev_example(button=None): """ Decrease current index """ nonlocal current_index if current_index > 0: current_index -= 1 render(current_index) count_label = HTML() set_label_text(current_index) display(count_label) buttons = [] if task_type == 'classification': if use_dropdown: dd = Dropdown(options=options) display(dd) btn = Button(description='submit') def on_click(button): add_annotation(dd.value) btn.on_click(on_click) buttons.append(btn) else: for label in options: btn = Button(description=label) def on_click(lbl, button): add_annotation(lbl) btn.on_click(functools.partial(on_click, label)) buttons.append(btn) elif task_type == 'multilabel-classification': for label in options: tgl = ToggleButton(description=label) buttons.append(tgl) btn = Button(description='submit', button_style='info') def on_click(button): labels_on = [] for tgl_btn in buttons: if isinstance(tgl_btn, ToggleButton): if tgl_btn.value: labels_on.append(tgl_btn.description) if reset_buttons_after_click: tgl_btn.value = False add_annotation(labels_on) btn.on_click(on_click) buttons.append(btn) elif task_type == 'regression': # check if tuple is int or float target_type = type(options[0]) if target_type == int: cls = IntSlider else: cls = FloatSlider # create slider if len(options) == 2: min_val, max_val = options slider = cls(min=min_val, max=max_val) else: min_val, max_val, step_val = options slider = cls(min=min_val, max=max_val, step=step_val) display(slider) # submit button btn = Button(description='submit', value='submit') def on_click(button): add_annotation(slider.value) btn.on_click(on_click) buttons.append(btn) elif task_type == 'captioning': ta = Textarea() display(ta) btn = Button(description='submit') def on_click(button): add_annotation(ta.value) btn.on_click(on_click) buttons.append(btn) else: raise ValueError('invalid task type') if include_back: btn = Button(description='prev', button_style='info') btn.on_click(prev_example) buttons.append(btn) if include_next: btn = Button(description='next', button_style='info') btn.on_click(next_example) buttons.append(btn) if len(buttons) > buttons_in_a_row: box = VBox([ HBox(buttons[x:x + buttons_in_a_row]) for x in range(0, len(buttons), buttons_in_a_row) ]) else: box = HBox(buttons) display(box) out = Output() display(out) next_example() # return object if return_type == 'dataframe': return annotations else: return annotations_dict
def __init__(self): micron_units = Label('micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout={'width':'25%'} widget_layout = {'width': '15%'} widget2_layout = {'width': '10%'} units_button_layout ={'width':'15%'} desc_button_layout={'width':'45%'} divider_button_layout={'width':'40%'} div_row1 = Button(description='---Initial Parameters---', disabled=True, layout=divider_button_layout) param_name1 = Button(description='seeding_method', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'tan' self.seeding_method = IntText( value=1, step=0.1, style=style, layout=widget_layout) div_row2 = Button(description='---Transition Rates---', disabled=True, layout=divider_button_layout) param_name2 = Button(description='r01', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'lightgreen' self.r01 = FloatText( value=0.01666, step=0.001, style=style, layout=widget_layout) param_name3 = Button(description='r01_fixed_duration', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'tan' self.r01_fixed_duration = Checkbox( value=False, style=style, layout=widget_layout) param_name4 = Button(description='r12', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'lightgreen' self.r12 = FloatText( value=0.01666, step=0.001, style=style, layout=widget_layout) param_name5 = Button(description='r12_fixed_duration', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'tan' self.r12_fixed_duration = Checkbox( value=False, style=style, layout=widget_layout) param_name6 = Button(description='r23', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'lightgreen' self.r23 = FloatText( value=0.01666, step=0.001, style=style, layout=widget_layout) param_name7 = Button(description='r23_fixed_duration', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'tan' self.r23_fixed_duration = Checkbox( value=False, style=style, layout=widget_layout) param_name8 = Button(description='r30', disabled=True, layout=name_button_layout) param_name8.style.button_color = 'lightgreen' self.r30 = FloatText( value=0.01666, step=0.001, style=style, layout=widget_layout) param_name9 = Button(description='r30_fixed_duration', disabled=True, layout=name_button_layout) param_name9.style.button_color = 'tan' self.r30_fixed_duration = Checkbox( value=False, style=style, layout=widget_layout) div_row3 = Button(description='---Arresting phase link between G0/G1 and S---', disabled=True, layout=divider_button_layout) param_name10 = Button(description='r01_arrest', disabled=True, layout=name_button_layout) param_name10.style.button_color = 'lightgreen' self.r01_arrest = Checkbox( value=False, style=style, layout=widget_layout) param_name11 = Button(description='oxygen_threshold', disabled=True, layout=name_button_layout) param_name11.style.button_color = 'tan' self.oxygen_threshold = FloatText( value=24, step=1, style=style, layout=widget_layout) param_name12 = Button(description='oxygen_gradient', disabled=True, layout=name_button_layout) param_name12.style.button_color = 'lightgreen' self.oxygen_gradient = Checkbox( value=False, style=style, layout=widget_layout) div_row4 = Button(description='---Arresting phase link between S and G2---', disabled=True, layout=divider_button_layout) param_name13 = Button(description='r12_arrest', disabled=True, layout=name_button_layout) param_name13.style.button_color = 'tan' self.r12_arrest = Checkbox( value=False, style=style, layout=widget_layout) param_name14 = Button(description='chemokine_threshold', disabled=True, layout=name_button_layout) param_name14.style.button_color = 'lightgreen' self.chemokine_threshold = FloatText( value=10.0, step=1, style=style, layout=widget_layout) div_row5 = Button(description='---Arresting phase link between G2 an M---', disabled=True, layout=divider_button_layout) param_name15 = Button(description='r23_arrest', disabled=True, layout=name_button_layout) param_name15.style.button_color = 'tan' self.r23_arrest = Checkbox( value=False, style=style, layout=widget_layout) param_name16 = Button(description='pressure_threshold', disabled=True, layout=name_button_layout) param_name16.style.button_color = 'lightgreen' self.pressure_threshold = FloatText( value=1.0, step=0.1, style=style, layout=widget_layout) div_row6 = Button(description='---Arresting phase link between M an G0/G1 (division)---', disabled=True, layout=divider_button_layout) param_name17 = Button(description='r30_arrest', disabled=True, layout=name_button_layout) param_name17.style.button_color = 'tan' self.r30_arrest = Checkbox( value=False, style=style, layout=widget_layout) param_name18 = Button(description='volume_threshold', disabled=True, layout=name_button_layout) param_name18.style.button_color = 'lightgreen' self.volume_threshold = FloatText( value=2490.0, step=100, style=style, layout=widget_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'tan' units_button4 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'lightgreen' units_button5 = Button(description='', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'tan' units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'lightgreen' units_button7 = Button(description='', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'tan' units_button8 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button8.style.button_color = 'lightgreen' units_button9 = Button(description='', disabled=True, layout=units_button_layout) units_button9.style.button_color = 'tan' units_button10 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button10.style.button_color = 'lightgreen' units_button11 = Button(description='', disabled=True, layout=units_button_layout) units_button11.style.button_color = 'tan' units_button12 = Button(description='', disabled=True, layout=units_button_layout) units_button12.style.button_color = 'tan' units_button13 = Button(description='', disabled=True, layout=units_button_layout) units_button13.style.button_color = 'lightgreen' units_button14 = Button(description='mmHg', disabled=True, layout=units_button_layout) units_button14.style.button_color = 'tan' units_button15 = Button(description='', disabled=True, layout=units_button_layout) units_button15.style.button_color = 'lightgreen' units_button16 = Button(description='', disabled=True, layout=units_button_layout) units_button16.style.button_color = 'lightgreen' units_button17 = Button(description='', disabled=True, layout=units_button_layout) units_button17.style.button_color = 'tan' units_button18 = Button(description='mM', disabled=True, layout=units_button_layout) units_button18.style.button_color = 'lightgreen' units_button19 = Button(description='', disabled=True, layout=units_button_layout) units_button19.style.button_color = 'lightgreen' units_button20 = Button(description='', disabled=True, layout=units_button_layout) units_button20.style.button_color = 'tan' units_button21 = Button(description='', disabled=True, layout=units_button_layout) units_button21.style.button_color = 'lightgreen' units_button22 = Button(description='', disabled=True, layout=units_button_layout) units_button22.style.button_color = 'lightgreen' units_button23 = Button(description='', disabled=True, layout=units_button_layout) units_button23.style.button_color = 'tan' units_button24 = Button(description='micron^3', disabled=True, layout=units_button_layout) units_button24.style.button_color = 'lightgreen' desc_button2 = Button(description='For seeding one cell => 1, For tissue seeding => 2' , tooltip='For seeding one cell => 1, For tissue seeding => 2', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button(description='transition rate between G0/G1 and S' , tooltip='transition rate between G0/G1 and S', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button4 = Button(description='True if transition rate (r01) are fixed duration.' , tooltip='True if transition rate (r01) are fixed duration.', disabled=True, layout=desc_button_layout) desc_button4.style.button_color = 'tan' desc_button5 = Button(description='transition rate between S and G2' , tooltip='transition rate between S and G2', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button(description='True if transition rate (r12) are fixed duration.' , tooltip='True if transition rate (r12) are fixed duration.', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' desc_button7 = Button(description='transition rate between G2 and M' , tooltip='transition rate between G2 and M', disabled=True, layout=desc_button_layout) desc_button7.style.button_color = 'lightgreen' desc_button8 = Button(description='True if transition rate (r23) are fixed duration.' , tooltip='True if transition rate (r23) are fixed duration.', disabled=True, layout=desc_button_layout) desc_button8.style.button_color = 'tan' desc_button9 = Button(description='transition rate between M and G0/G1' , tooltip='transition rate between M and G0/G1', disabled=True, layout=desc_button_layout) desc_button9.style.button_color = 'lightgreen' desc_button10 = Button(description='True if transition rate (r30) are fixed duration.' , tooltip='True if transition rate (r30) are fixed duration.', disabled=True, layout=desc_button_layout) desc_button10.style.button_color = 'tan' desc_button11 = Button(description='if true and conditions were matched, it arrests phase link.' , tooltip='if true and conditions were matched, it arrests phase link.', disabled=True, layout=desc_button_layout) desc_button11.style.button_color = 'lightgreen' desc_button12 = Button(description='environmental oxygen threshold for phase transition. If less than threshold, it stops' , tooltip='environmental oxygen threshold for phase transition. If less than threshold, it stops', disabled=True, layout=desc_button_layout) desc_button12.style.button_color = 'tan' desc_button13 = Button(description='True, if environment has oxygen gradient' , tooltip='True, if environment has oxygen gradient', disabled=True, layout=desc_button_layout) desc_button13.style.button_color = 'lightgreen' desc_button14 = Button(description='arrest function according to chemokine level' , tooltip='arrest function according to chemokine level', disabled=True, layout=desc_button_layout) desc_button14.style.button_color = 'tan' desc_button15 = Button(description='environmental chemokine threshold for phase transition. If more, it stops' , tooltip='environmental chemokine threshold for phase transition. If more, it stops', disabled=True, layout=desc_button_layout) desc_button15.style.button_color = 'lightgreen' desc_button16 = Button(description='arrest function according to pressure level' , tooltip='arrest function according to pressure level', disabled=True, layout=desc_button_layout) desc_button16.style.button_color = 'tan' desc_button17 = Button(description='cell pressure threshold to stall this phase transition. If more, it stops' , tooltip='cell pressure threshold to stall this phase transition. If more, it stops', disabled=True, layout=desc_button_layout) desc_button17.style.button_color = 'lightgreen' desc_button18 = Button(description='arrest function according to cell volume' , tooltip='arrest function according to cell volume', disabled=True, layout=desc_button_layout) desc_button18.style.button_color = 'tan' desc_button19 = Button(description='target cell volume threshold. If less, it does not cycle.' , tooltip='target cell volume threshold. If less, it does not cycle.', disabled=True, layout=desc_button_layout) desc_button19.style.button_color = 'lightgreen' row2 = [param_name1, self.seeding_method, units_button2, desc_button2] row3 = [param_name2, self.r01, units_button4, desc_button3] row4 = [param_name3, self.r01_fixed_duration, units_button5, desc_button4] row5 = [param_name4, self.r12, units_button6, desc_button5] row6 = [param_name5, self.r12_fixed_duration, units_button7, desc_button6] row7 = [param_name6, self.r23, units_button8, desc_button7] row8 = [param_name7, self.r23_fixed_duration, units_button9, desc_button8] row9 = [param_name8, self.r30, units_button10, desc_button9] row10 = [param_name9, self.r30_fixed_duration, units_button11, desc_button10] row11 = [param_name10, self.r01_arrest, units_button13, desc_button11] row12 = [param_name11, self.oxygen_threshold, units_button14, desc_button12] row13 = [param_name12, self.oxygen_gradient, units_button15, desc_button13] row14 = [param_name13, self.r12_arrest, units_button17, desc_button14] row15 = [param_name14, self.chemokine_threshold, units_button18, desc_button15] row16 = [param_name15, self.r23_arrest, units_button20, desc_button16] row17 = [param_name16, self.pressure_threshold, units_button21, desc_button17] row18 = [param_name17, self.r30_arrest, units_button23, desc_button18] row19 = [param_name18, self.volume_threshold, units_button24, desc_button19] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box8 = Box(children=row8, layout=box_layout) box9 = Box(children=row9, layout=box_layout) box10 = Box(children=row10, layout=box_layout) box11 = Box(children=row11, layout=box_layout) box12 = Box(children=row12, layout=box_layout) box13 = Box(children=row13, layout=box_layout) box14 = Box(children=row14, layout=box_layout) box15 = Box(children=row15, layout=box_layout) box16 = Box(children=row16, layout=box_layout) box17 = Box(children=row17, layout=box_layout) box18 = Box(children=row18, layout=box_layout) box19 = Box(children=row19, layout=box_layout) self.tab = VBox([ div_row1, box2, div_row2, box3, box4, box5, box6, box7, box8, box9, box10, div_row3, box11, box12, box13, div_row4, box14, box15, div_row5, box16, box17, div_row6, box18, box19, ])
def _widget(self): """ Create IPython widget for display within a notebook """ try: return self._cached_widget except AttributeError: pass from ipywidgets import Layout, VBox, HBox, IntText, Button, HTML, Accordion layout = Layout(width='150px') if 'bokeh' in self.scheduler.services: template = config.get('diagnostics-link', 'http://{host}:{port}/status') host = self.scheduler.address.split('://')[1].split(':')[0] port = self.scheduler.services['bokeh'].port link = template.format(host=host, port=port, **os.environ) link = '<p><b>Dashboard: </b><a href="%s" target="_blank">%s</a></p>\n' % ( link, link) else: link = '' title = '<h2>%s</h2>' % type(self).__name__ title = HTML(title) dashboard = HTML(link) status = HTML(self._widget_status(), layout=Layout(min_width='150px')) request = IntText(0, description='Workers', layout=layout) scale = Button(description='Scale', layout=layout) minimum = IntText(0, description='Minimum', layout=layout) maximum = IntText(0, description='Maximum', layout=layout) adapt = Button(description='Adapt', layout=layout) accordion = Accordion( [HBox([request, scale]), HBox([minimum, maximum, adapt])], layout=Layout(min_width='500px')) accordion.selected_index = None accordion.set_title(0, 'Manual Scaling') accordion.set_title(1, 'Adaptive Scaling') box = VBox([title, HBox([status, accordion]), dashboard]) self._cached_widget = box def adapt_cb(b): self.adapt(minimum=minimum.value, maximum=maximum.value) adapt.on_click(adapt_cb) def scale_cb(b): print('Hello!') with log_errors(): n = request.value with ignoring(AttributeError): self._adaptive.stop() self.scale(n) scale.on_click(scale_cb) scheduler_ref = ref(self.scheduler) def update(): status.value = self._widget_status() pc = PeriodicCallback(update, 500, io_loop=self.scheduler.loop) self.scheduler.periodic_callbacks['cluster-repr'] = pc pc.start() return box
def __init__(self, show=True, style=True, Debug=p.DEBUG): super(MS2Dscene, self).__init__() # header # filechooser self.base = p.BASE self.filechooser = FI.FileChooser(self.base, dotd=False, accept=('2D-MS', )) self.datap = None self.MAX_DISP_PEAKS = p.NbMaxDisplayPeaks self.debug = Debug # buttons # load self.bload = Button( description='Load', #layout=Layout(width='15%'), tooltip='load and display experiment') self.bload.on_click(self.load2D) # info self.binfo = Button( description='Info', #layout=Layout(width='15%'), tooltip='Info on selected experiment, without loading') self.binfo.on_click(self.info2D) # GUI set-up and scene # tools self.header = Output() with self.header: self.waitarea = Output() self.buttonbar = HBox([self.bload, self.binfo, self.waitarea]) display(Markdown('---\n# Select an experiment, and load')) display(self.filechooser) display(self.buttonbar) NODATA = HTML("<br><br><h3><i><center>No Data</center></i></h3>") # 2D spectrum self.out2D = Output() # the area where 2D is shown with self.out2D: display(NODATA) display(Markdown("use the `Load` button above")) # 1D spectrum self.out1D = Output() # the area where 1D is shown with self.out1D: display(NODATA) display(Markdown("After loading, this window will be activated")) # peaklist self.peaklist = Output() # the area where peak list is shown with self.peaklist: display( HTML( "<br><br><h3><i><center>Not implemented yet</center></i></h3>" )) # # form # self.outform = Output() # the area where processing parameters are displayed # with self.outform: # self.paramform() # display(self.form) # Info self.outinfo = Output() # the area where info is shown with self.outinfo: display(NODATA) self.out2D.clear_output(wait=True) self.out1D.clear_output(wait=True) self.outinfo.clear_output(wait=True) self.peaklist.clear_output(wait=True) # tabs self.tabs = widgets.Tab() self.tabs.children = [ self.out1D, self.out2D, self.peaklist, self.outinfo ] self.tabs.set_title(0, '1D Extraction') self.tabs.set_title(1, '2D Display') self.tabs.set_title(2, 'Peak List') # self.tabs.set_title(3, 'Processing Parameters') self.tabs.set_title(3, 'Info') # self.tabs = VBox([ self.out2D, self.outpp2D, self.out1D, self.outinfo ]) self.box = VBox([self.header, self.tabs]) # self.box = VBox([self.title, # self.FC, # HBox([self.bdisp2D, self.bpp2D, self.bdisp1D]) # ]) if style: FI.injectcss() if show: display(self.box)
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} param_name1 = Button(description='random_seed', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'tan' self.random_seed = IntText(value=0, step=1, style=style, layout=widget_layout) param_name2 = Button(description='motile_cell_persistence_time', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'tan' self.motile_cell_persistence_time = FloatText(value=15, step=1, style=style, layout=widget_layout) param_name3 = Button(description='motile_cell_migration_speed', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'tan' self.motile_cell_migration_speed = FloatText(value=0.5, step=0.1, style=style, layout=widget_layout) param_name4 = Button(description='motile_cell_relative_adhesion', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.motile_cell_relative_adhesion = FloatText(value=0.05, step=0.01, style=style, layout=widget_layout) param_name5 = Button(description='motile_cell_apoptosis_rate', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'tan' self.motile_cell_apoptosis_rate = FloatText(value=0.0, step=0.01, style=style, layout=widget_layout) param_name6 = Button( description='motile_cell_relative_cycle_entry_rate', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.motile_cell_relative_cycle_entry_rate = FloatText( value=0.1, step=0.01, style=style, layout=widget_layout) param_name7 = Button(description='birth_interval', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'tan' self.birth_interval = FloatText(value=60, step=1, style=style, layout=widget_layout) param_name8 = Button(description='volume_total', disabled=True, layout=name_button_layout) param_name8.style.button_color = 'tan' self.volume_total = FloatText(value=1, step=0.1, style=style, layout=widget_layout) param_name9 = Button(description='target_fluid_frac', disabled=True, layout=name_button_layout) param_name9.style.button_color = 'tan' self.target_fluid_frac = FloatText(value=0.75, step=0.1, style=style, layout=widget_layout) param_name10 = Button(description='fluid_change_rate', disabled=True, layout=name_button_layout) param_name10.style.button_color = 'tan' self.fluid_change_rate = FloatText(value=0.15, step=0.01, style=style, layout=widget_layout) param_name11 = Button(description='cytoplasmic_biomass_change_rate', disabled=True, layout=name_button_layout) param_name11.style.button_color = 'tan' self.cytoplasmic_biomass_change_rate = FloatText(value=0.15, step=0.01, style=style, layout=widget_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'tan' units_button2 = Button(description='min', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='micron/min', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'tan' units_button4 = Button(description='', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'tan' units_button5 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'tan' units_button6 = Button(description='', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'tan' units_button7 = Button(description='min', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'tan' units_button8 = Button(description='micron^3', disabled=True, layout=units_button_layout) units_button8.style.button_color = 'tan' units_button9 = Button(description='', disabled=True, layout=units_button_layout) units_button9.style.button_color = 'tan' units_button10 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button10.style.button_color = 'tan' units_button11 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button11.style.button_color = 'tan' row0 = [ param_name1, self.random_seed, units_button1, ] row0 = [ param_name2, self.motile_cell_persistence_time, units_button2, ] row0 = [ param_name3, self.motile_cell_migration_speed, units_button3, ] row0 = [ param_name4, self.motile_cell_relative_adhesion, units_button4, ] row0 = [ param_name5, self.motile_cell_apoptosis_rate, units_button5, ] row0 = [ param_name6, self.motile_cell_relative_cycle_entry_rate, units_button6, ] row0 = [ param_name7, self.birth_interval, units_button7, ] row0 = [ param_name8, self.volume_total, units_button8, ] row0 = [ param_name9, self.target_fluid_frac, units_button9, ] row0 = [ param_name10, self.fluid_change_rate, units_button10, ] row0 = [ param_name11, self.cytoplasmic_biomass_change_rate, units_button11, ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) box0 = Box(children=row0, layout=box_layout) self.tab = VBox([ box0, box0, box0, box0, box0, box0, box0, box0, box0, box0, box0, ])
def df_input(dfUniprot=DataFrame([])): num_phylum = len(dfUniprot.PHYLUM.drop_duplicates()) from matplotlib import cm set3 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Set3(np.arange(12) / 12.) ] set2 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Set2(np.arange(8) / 8.) ] set1 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Set1(np.arange(9) / 9.) ] pastel2 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Pastel2(np.arange(8) / 8.) ] pastel1 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Pastel1(np.arange(9) / 9.) ] dark2 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Dark2(np.arange(8) / 8.) ] paired = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Paired(np.arange(12) / 12.) ] accent = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Accent(np.arange(8) / 8.) ] spectral = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.Spectral(np.arange(11) / 11.) ] tab20 = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.tab20(np.arange(20) / 20.) ] tab20b = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.tab20b(np.arange(20) / 20.) ] tab20c = [ matplotlib.colors.rgb2hex(tuple(i)) for i in cm.tab20c(np.arange(20) / 20.) ] Colors1 = set2 + set1 + dark2 + paired + accent + spectral + tab20 + tab20b + tab20c Colors2 = accent + spectral + tab20 + tab20b + tab20c + set1 + set2 + dark2 + paired Colors3 = dark2 + paired + accent + spectral + tab20 + tab20b + tab20c + set1 + set2 Colors4 = tab20b + tab20c + set1 + set2 + dark2 + paired + accent + spectral + tab20 Colors5 = spectral + tab20 + tab20b + tab20c + set1 + set2 + dark2 + paired + accent pie_colors = { 'Set3': cm.Set3(np.arange(12) / 12.), 'Set2': cm.Set2(np.arange(8) / 8.), 'Set1': cm.Set1(np.arange(9) / 9.), 'Pastel2': cm.Pastel2(np.arange(8) / 8.), 'Pastel1': cm.Pastel1(np.arange(9) / 9.), 'Dark2': cm.Dark2(np.arange(8) / 8.), 'Paired': cm.Paired(np.arange(12) / 12.), 'Accent': cm.Accent(np.arange(8) / 8.), 'Spectral': cm.Spectral(np.arange(11) / 11.), 'tab20': cm.tab20(np.arange(20) / 20.), 'tab20b': cm.tab20b(np.arange(20) / 20.), 'tab20c': cm.tab20c(np.arange(20) / 20.) } circle_colors = { 'Colors1': Colors1[0:num_phylum], 'Colors2': Colors2[0:num_phylum], 'Colors3': Colors3[0:num_phylum], 'Colors4': Colors4[0:num_phylum], 'Colors5': Colors5[0:num_phylum] } def tax_colors(color_list=circle_colors['Colors1'], taxx=dfUniprot): tax_cols = [ 'Entry', 'Tax_ID', 'KINGDOM', 'PHYLUM', 'CLASS', 'ORDER', 'FAMILY', 'GENUS', 'SPECIES', 'Organism' ] new2 = taxx[tax_cols].drop_duplicates() #>>>>>>>>>>>>>>>>>>>>>>>>>>> phylum0 = new2.groupby(['PHYLUM' ]).Entry.count().reset_index().sort_values( by='Entry', ascending=False).reset_index(drop=True) asign_color = {} for i, j in zip(phylum0.PHYLUM, color_list): if i == 'NA': asign_color[i] = 'black' else: asign_color[i] = j phylum0['phy_col'] = list(asign_color.values()) # distribución de Class phylum1 = new2.groupby(['PHYLUM', 'CLASS']).Entry.count().reset_index() class0 = [] class0_colors = [] for i in phylum0.PHYLUM: for j in phylum1.PHYLUM: if i == j: class0_colors.append(asign_color[j]) class0.append(phylum1[phylum1.PHYLUM == i].sort_values( by='Entry', ascending=False).reset_index(drop=True)) else: pass class1 = pd.concat(class0).drop_duplicates() class1['class_col'] = class0_colors class0_colors_corregido = [] for index, row in class1.iterrows(): if row.PHYLUM == 'NA': if row.CLASS == 'NA': class0_colors_corregido.append(row.class_col) else: class0_colors_corregido.append('grey') else: if row.CLASS == 'NA': class0_colors_corregido.append('black') else: class0_colors_corregido.append(row.class_col) class1['class_col'] = class0_colors_corregido class11 = class1.groupby(['CLASS' ]).Entry.sum().reset_index().sort_values( by='Entry', ascending=False).reset_index(drop=True) class11 = class11.merge(class1[['CLASS', 'class_col']].drop_duplicates(), on='CLASS', how='left') # distribución de Order phylum2 = new2.groupby(['PHYLUM', 'CLASS', 'ORDER']).Entry.count().reset_index() order0 = [] order0_colors = [] for i in phylum0.PHYLUM: for j in phylum2.PHYLUM: if i == j: order0_colors.append(asign_color[j]) order0.append(phylum2[phylum2.PHYLUM == i].sort_values( by='Entry', ascending=False).reset_index(drop=True)) else: pass order1 = pd.concat(order0).drop_duplicates() order1['order_col'] = order0_colors order0_colors_corregido = [] for index, row in order1.iterrows(): if row.PHYLUM == 'NA': if row.ORDER == 'NA': order0_colors_corregido.append(row.order_col) else: order0_colors_corregido.append('grey') else: if row.ORDER == 'NA': order0_colors_corregido.append('black') else: order0_colors_corregido.append(row.order_col) order1['order_col'] = order0_colors_corregido order11 = order1.groupby(['ORDER' ]).Entry.sum().reset_index().sort_values( by='Entry', ascending=False).reset_index(drop=True) order11 = order11.merge(order1[['ORDER', 'order_col']].drop_duplicates(), on='ORDER', how='left') # distribución de Genus phylum3 = new2.groupby(['PHYLUM', 'CLASS', 'ORDER', 'GENUS']).Entry.count().reset_index() genus0 = [] genus0_colors = [] for i in phylum0.PHYLUM: for j in phylum3.PHYLUM: if i == j: genus0_colors.append(asign_color[j]) genus0.append(phylum3[phylum3.PHYLUM == i].sort_values( by='Entry', ascending=False).reset_index(drop=True)) else: pass genus1 = pd.concat(genus0).drop_duplicates() genus1['genus_col'] = genus0_colors genus0_colors_corregido = [] for index, row in genus1.iterrows(): if row.PHYLUM == 'NA': if row.GENUS == 'NA': genus0_colors_corregido.append(row.genus_col) else: genus0_colors_corregido.append('grey') else: if row.GENUS == 'NA': genus0_colors_corregido.append('black') else: genus0_colors_corregido.append(row.genus_col) genus1['genus_col'] = genus0_colors_corregido genus11 = genus1.groupby(['GENUS' ]).Entry.sum().reset_index().sort_values( by='Entry', ascending=False).reset_index(drop=True) genus11 = genus11.merge(genus1[['GENUS', 'genus_col']].drop_duplicates(), on='GENUS', how='left') # distribución de Organism phylum4 = new2.groupby( ['PHYLUM', 'CLASS', 'ORDER', 'GENUS', 'Organism']).Entry.count().reset_index() org0 = [] org0_colors = [] for i in phylum0.PHYLUM: for j in phylum4.PHYLUM: if i == j: org0_colors.append(asign_color[j]) org0.append(phylum4[phylum4.PHYLUM == i].sort_values( by='Entry', ascending=False).reset_index(drop=True)) else: pass org1 = pd.concat(org0).drop_duplicates() org1['org_col'] = org0_colors org0_colors_corregido = [] for index, row in org1.iterrows(): if row.PHYLUM == 'NA': if row.Organism == 'NA': org0_colors_corregido.append(row.org_col) else: org0_colors_corregido.append('grey') else: if row.Organism == 'NA': org0_colors_corregido.append('black') else: org0_colors_corregido.append(row.org_col) org1['org_col'] = org0_colors_corregido org11 = org1.groupby(['Organism' ]).Entry.sum().reset_index().sort_values( by='Entry', ascending=False).reset_index(drop=True) org11 = org11.merge(org1[['Organism', 'org_col']].drop_duplicates(), on='Organism', how='left') os.makedirs('tax', exist_ok=True) return phylum0.to_csv('tax/phylum0.tsv', sep = '\t', index = None),\ class1.to_csv('tax/class1.tsv', sep = '\t', index = None),\ class11.to_csv('tax/class11.tsv', sep = '\t', index = None),\ order1.to_csv('tax/order1.tsv', sep = '\t', index = None),\ order11.to_csv('tax/order11.tsv', sep = '\t', index = None),\ genus1.to_csv('tax/genus1.tsv', sep = '\t', index = None),\ genus11.to_csv('tax/genus11.tsv', sep = '\t', index = None),\ org1.to_csv('tax/org1.tsv', sep = '\t', index = None),\ org11.to_csv('tax/org11.tsv', sep = '\t', index = None) alfas = { 'Lineage*': [1, 1, 1, 1, 1], 'Phylum': [1, 0.3, 0.3, 0.3, 0.3], 'Class': [0.3, 1, 0.3, 0.3, 0.3], 'Order': [0.3, 0.3, 1, 0.3, 0.3], 'Genus': [0.3, 0.3, 0.3, 1, 0.3], 'Species': [0.3, 0.3, 0.3, 0.3, 1], 'Gradient1*': [1, 0.85, 0.7, 0.55, 0.4], 'Gradient2*': [0.4, 0.55, 0.7, 0.85, 1], 'Attenuate*': [0.3, 0.3, 0.3, 0.3, 0.3], 'None*': [0, 0, 0, 0, 0] } def circle_lineage(alphas=alfas['Phylum']): #fig, ax = plt.subplots(111, facecolor= 'white') #fig, ax = plt.subplot(111) phylum0 = pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA') class1 = pd.read_csv('tax/class1.tsv', sep='\t').fillna('NA') order1 = pd.read_csv('tax/order1.tsv', sep='\t').fillna('NA') genus1 = pd.read_csv('tax/genus1.tsv', sep='\t').fillna('NA') org1 = pd.read_csv('tax/org1.tsv', sep='\t').fillna('NA') radio = 0.5 linaje = [phylum0, class1, order1, genus1, org1] #colores = [list(asign_color.values()), class0_colors, order0_colors, genus0_colors, org0_colors] colores = ['phy_col', 'class_col', 'order_col', 'genus_col', 'org_col'] pat = [] size = -.205 for i, j, k in zip(linaje, colores, alphas): size += .205 patches, texts = plt.pie( i.Entry, radius=radio + size, labels=None, labeldistance=0.8, rotatelabels=True, colors= i[j], # new_colors(valor = len(i.Entry), col = 'nipy_spectral'), wedgeprops=dict(width=0.2, edgecolor='white', alpha=k), textprops=dict(size=10)) pat.append(patches) #plt.legend(pat[0], df_phylum.PHYLUM, loc=2,fontsize=13,labelspacing = 0.4, # bbox_to_anchor=(1.05, 1),frameon=False) plt.gca().set(aspect='equal') plt.title('Root', fontsize=10, x=0.5, y=0.465) plt.text(-1.8, 1.35, 'Lineage', fontsize=15, ha='left', va='center', color='black') #plt.title('Lineage',fontsize=20, fontweight='bold', x = -0.17, y = 1) #plt.text(1.1, 1.35, linaje_seleccionado, fontsize = 15, ha='left', va='center', # color='black') #>>>>>>>>>>>>>>>>>>>>>>> #### insetplot #ax2 = plt.axes([0.1, 0.66, 0.13, 0.14]) ax2 = plt.axes([-0.07, 1.71, 0.17, 0.18]) logo = [20, 20, 20, 20, 20, 20, 20, 20] logo_col = [ 'white', 'white', 'black', 'white', 'white', 'white', 'white', 'white' ] logo_col1 = [ 'white', 'white', 'black', 'black', 'black', 'black', 'black', 'black' ] radio = 0.5 linaje = [logo, logo, logo, logo, logo] colores = [logo_col1, logo_col, logo_col, logo_col, logo_col] name_linaje = ['Phylum', 'Class', 'Order', 'Genus', 'Species'] pat = [] size = -.44 pos = -.18 for i, j, k, l in zip(linaje, colores, name_linaje, alphas): pos += .47 size += .44 ax2.pie(i, radius=radio + size, labels=None, colors=j, wedgeprops=dict(width=0.35, edgecolor='white', alpha=l), textprops=dict(size=10)) ax2.text(0.1, pos, k, fontsize=9, ha='left', va='center', fontweight='bold', alpha=l) #color='black' def barras_tax(df=DataFrame([]), column=0, dim=111, title='', row_num=10, color=['#ff7f0e'], size_x=8, size_y=10, ylabel_text='', xlabel=10, ylabel=10, size_title=15, size_bartxt=10, sep=1.2): if len(df) == 0: print('Data frame sin datos') else: #plt.subplot(dim, facecolor= 'white') barWidth = 0.9 if row_num == len(df): ejey = list(df.iloc[0:len(df), 1]) val = max(ejey) ejex = list(df.iloc[0:len(df), column]) colores = list(df.iloc[0:len(df), 2]) borde = list( np.repeat('white', len(df.iloc[0:row_num, column]))) linea = list(np.repeat(0, len(df.iloc[0:row_num, column]))) if row_num < len(df): ejey = list(df.iloc[0:row_num, 1]) + [df.iloc[row_num:len(df), 1].sum()] val = max(ejey) ejex = list(df.iloc[0:row_num, column]) + ['Others'] borde = list( np.repeat('white', len(df.iloc[0:row_num, column]))) + ['black'] colores = list(df.iloc[0:row_num, 2]) + ['linen'] linea = list(np.repeat(0, len(df.iloc[0:row_num, column]))) + [1] if row_num > len(df): ejey = list(df.iloc[0:len(df), 1]) val = max(ejey) ejex = list(df.iloc[0:len(df), column]) borde = list( np.repeat('white', len(df.iloc[0:row_num, column]))) colores = list(df.iloc[0:len(df), 2]) linea = list(np.repeat(0, len(df.iloc[0:row_num, column]))) for i, j, k, l, m in zip(ejex, ejey, borde, colores, linea): plt.barh(i, j, color=l, align='center', height=0.7, linewidth=m, alpha=1, edgecolor=k) plt.gca().spines['right'].set_visible(False) plt.gca().spines['top'].set_visible(False) plt.gca().spines['bottom'].set_position(('data', -0.6)) plt.gca().spines['left'].set_visible(False) plt.title(title, size=size_title, loc='left') plt.tick_params(axis="y", color="gray") plt.yticks(size=size_y) v1 = -50 v2 = 0 v3 = 0 for i in range(10000): v1 += 50 v2 += 50 v3 += 10 if v1 <= max(list(ejey)) < v2: #print(v3, v1, val, v2) escala = v3 plt.xticks(range(0, val, escala), size=size_x) #fontweight='bold' plt.ylabel(ylabel_text, size=ylabel) plt.xlabel("Number of Proteins", size=xlabel) #plt.tick_params(top = 'on', bottom = 'on', right = 'on', left = 'on') #plt.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False) for j, k in zip(ejey, range(0, len(ejey))): plt.text(j + sep, k - 0.2, j, size=size_bartxt, ha='left', color='black') import ipywidgets as widgets from ipywidgets import interact, interactive, fixed, interact_manual, Button, HBox, VBox, IntSlider, Label, IntRangeSlider from ipywidgets import Checkbox, RadioButtons from ipywidgets import Button, Layout alfas = { 'Lineage*': [1, 1, 1, 1, 1], 'Phylum': [1, 0.3, 0.3, 0.3, 0.3], 'Class': [0.3, 1, 0.3, 0.3, 0.3], 'Order': [0.3, 0.3, 1, 0.3, 0.3], 'Genus': [0.3, 0.3, 0.3, 1, 0.3], 'Species': [0.3, 0.3, 0.3, 0.3, 1], 'Gradient1*': [1, 0.85, 0.7, 0.55, 0.4], 'Gradient2*': [0.4, 0.55, 0.7, 0.85, 1], 'Attenuate*': [0.3, 0.3, 0.3, 0.3, 0.3], 'None*': [0, 0, 0, 0, 0] } plotss = ['Phylum', 'Class', 'Order', 'Genus', 'Species'] posicion_subplots = [] n = 0.9 while n < 2: n += 0.1 posicion_subplots.append(np.around(n, 1)) color_a6 = widgets.Dropdown(options=list(circle_colors.keys()), value='Colors1', description='Colors:', disabled=False, button_style='', layout=Layout(width='20%', height='25px')) a6 = widgets.Dropdown(options=list(alfas.keys()), description='Chart 1:', value='Phylum', disabled=False, button_style='', layout=Layout(width='20%', height='25px')) a61 = widgets.Dropdown(options=plotss, description='Chart 2:', disabled=False, button_style='', layout=Layout(width='20%', height='25px')) pos_sub1 = widgets.Dropdown(options=posicion_subplots, value=1.3, description='xloc1:', disabled=False, layout=Layout(width='15%', height='25px')) pos_sub2 = widgets.Dropdown(options=posicion_subplots, value=1.3, description='xloc2:', disabled=False, layout=Layout(width='15%', height='25px')) b6 = widgets.Dropdown(options=list(range(0, 101)), value=10, description='rows1:', disabled=False, layout=Layout(width='15%', height='25px')) c6 = widgets.Dropdown(options=list(range(0, 101)), value=10, description='rows2:', disabled=False, layout=Layout(width='15%', height='25px')) z6 = widgets.ToggleButton(value=False, description='Save Chart', disabled=False, button_style='', tooltip='Description') o6 = widgets.Dropdown(options=[0, 0.25, 0.5, 0.75] + list(range(0, 201)), value=3, description='sep1:', disabled=False, layout=Layout(width='15%', height='25px')) o61 = widgets.Dropdown(options=[0, 0.25, 0.5, 0.75] + list(range(0, 201)), value=3, description='sep2:', disabled=False, layout=Layout(width='15%', height='25px')) d6 = widgets.Dropdown(options=list(range(0, 51)), value=8, description='size_y1:', disabled=False, layout=Layout(width='15%', height='25px')) d61 = widgets.Dropdown(options=list(range(0, 51)), value=8, description='size_y2:', disabled=False, layout=Layout(width='15%', height='25px')) g6 = widgets.Dropdown(options=list(range(0, 51)), value=8, description='bartxt1:', disabled=False, layout=Layout(width='15%', height='25px')) g61 = widgets.Dropdown(options=list(range(0, 51)), value=8, description='bartxt2:', disabled=False, layout=Layout(width='15%', height='25px')) xxx = Button(layout=Layout(width='5%', height='25px'), disabled=True) xxx.style.button_color = 'white' yyy = Button(layout=Layout(width='94%', height='5px'), disabled=True) yyy.style.button_color = 'red' ww = widgets.HBox([color_a6, xxx, z6]) w6 = widgets.HBox([ a6, b6, o6, d6, g6, pos_sub1, ]) w7 = widgets.HBox([ a61, c6, o61, d61, g61, pos_sub2, ]) w8 = widgets.VBox([w6, w7, yyy]) ###### def col(color_a6): tax_colors(color_list=circle_colors[color_a6], taxx=dfUniprot) out7 = widgets.interactive_output(col, {'color_a6': color_a6}) def box1(a6, a61, pos_sub1, pos_sub2, b6, c6, z6, o6, o61, d6, d61, g6, g61): yetiquetas_plot1 = { 'Lineage*': 'Phylum', 'Phylum': 'Phylum', 'Class': 'Class', 'Order': 'Order', 'Genus': 'Genus', 'Species': 'Species', 'Gradient1*': 'Phylum', 'Gradient2*': 'Phylum', 'Attenuate*': 'Phylum', 'None*': 'Phylum' } plots1 = { 'Lineage*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'), 'Phylum': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'), 'Class': pd.read_csv('tax/class11.tsv', sep='\t').fillna('NA'), 'Order': pd.read_csv('tax/order11.tsv', sep='\t').fillna('NA'), 'Genus': pd.read_csv('tax/genus11.tsv', sep='\t').fillna('NA'), 'Species': pd.read_csv('tax/org11.tsv', sep='\t').fillna('NA'), 'Gradient1*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'), 'Gradient2*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'), 'Attenuate*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'), 'None*': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA') } plots2 = { 'Phylum': pd.read_csv('tax/phylum0.tsv', sep='\t').fillna('NA'), 'Class': pd.read_csv('tax/class11.tsv', sep='\t').fillna('NA'), 'Order': pd.read_csv('tax/order11.tsv', sep='\t').fillna('NA'), 'Genus': pd.read_csv('tax/genus11.tsv', sep='\t').fillna('NA'), 'Species': pd.read_csv('tax/org11.tsv', sep='\t').fillna('NA') } ax3 = plt.axes([pos_sub2, .97, .3, 0.55]) ##>>>>>>>>>>> grafico circular ax = plt.axes([0, 1, 0.9, 1]) circle_lineage(alphas=alfas[a6]) ##>>>>>>>>>>> grafico 1 #ax2 = plt.axes([pos_sub1, 1.51, .3, 0.55]) ax2 = plt.axes([pos_sub1, 1.63, .3, 0.4]) #>>>>>>>>>> barras_tax( plots1[a6], #barras_tax(tax_colors(color_list = circle_colors['Spectral'])[0], row_num=b6, color=plots1[a6].iloc[0:b6, 2], sep=o6, size_y=d6, size_bartxt=g6, ylabel_text=yetiquetas_plot1[a6], ylabel=10) ##>>>>>>>>>>> grafico 2 ax3 = plt.axes([pos_sub2, .97, .3, 0.55]) barras_tax( plots2[a61], #barras_tax(tax_colors(color_list = circle_colors['Spectral'])[0], row_num=c6, color=plots2[a61].iloc[0:b6, 2], sep=o61, size_y=d61, size_bartxt=g61, ylabel_text=yetiquetas_plot1[a61], ylabel=10) ##>>>>>>>>>>>> save if z6 == True: import datetime plt.savefig('img/Lineage' + datetime.datetime.now().strftime('%d.%B.%Y_%I-%M%p') + '.png', dpi=900, bbox_inches='tight') else: pass out6 = widgets.interactive_output( box1, { 'a6': a6, 'a61': a61, 'pos_sub1': pos_sub1, 'pos_sub2': pos_sub2, 'b6': b6, 'c6': c6, 'z6': z6, 'o6': o6, 'o61': o61, 'd6': d6, 'd61': d61, 'g6': g6, 'g61': g61 }) import warnings warnings.filterwarnings("ignore") return display(VBox([yyy, ww, w8, out6]))
def upload_shp(path_data, config_path=False): # Upload l_up = Label("a. Upload .shp to the server.") accept_files = ".shp, .cpg, .dbf, .prj, .shx, .sbn, .sbx, .xml" data_path = config.get_value(['paths', 'temp']) shp_dist_folder = Text(value=normpath(join(path_data, 'vector')), placeholder='tmp/', description='Folder:', disabled=config_path) shp_select = FileUpload( description='Select files:', icon='plus', accept=accept_files, multiple=True # True to accept multiple files upload else False ) shp_clear = Button(value=False, disabled=False, button_style='info', tooltip='Clear selections.', icon='broom', layout=Layout(width='40px')) shp_upload = Button(value=False, disabled=False, button_style='info', tooltip='Upload foi reference data (.shp).', icon='fa-upload', layout=Layout(width='40px')) progress = Output() def outlog(*text): with progress: print(*text) @shp_clear.on_click def shp_clear_on_click(b): shp_select.value.clear() shp_select._counter = 0 @shp_upload.on_click def shp_upload_on_click(b): progress.clear_output() os.makedirs(shp_dist_folder.value, exist_ok=True) for key in shp_select.value: content = shp_select.value[key]['content'] with open(normpath(join(shp_dist_folder.value, key)), 'wb') as f: f.write(content) outlog("All files are uploaded.") shp_select.value.clear() shp_select._counter = 0 shp_box = HBox([shp_dist_folder, shp_select, shp_clear, shp_upload]) # Import the .shp to the database l_imp = Label("""b. Import uploaded .shp to the database. Add a short name, max 15 characters for the parcels table e.g.:escat2020.""") imp_select = Dropdown(options=[ s for s in glob.glob(normpath(join(shp_dist_folder.value, '*'))) if '.shp' in s ], description='Select .shp:', disabled=False) imp_refresh = Button(layout=Layout(width='35px'), icon='fa-refresh') imp_proc = Button( description='Import .shp file', value=False, disabled=False, button_style='info', tooltip='Run', icon='fa-database', ) imp_truncate = Checkbox(value=False, description='Remove old entries', disabled=False) try: with open(normpath(join(data_path, 'tb_prefix')), 'r') as f: name_from_prfix = f.read() except Exception: name_from_prfix = None imp_tb_name = Text(value=name_from_prfix, placeholder='ms2010', description='Table name:', tooltip='A short name max 10 char.', disabled=False) def on_imp_tb_name(change): with open(normpath(join(data_path, 'tb_prefix')), 'w+') as f: f.write(imp_tb_name.value) imp_tb_name.observe(on_imp_tb_name, 'value') @imp_proc.on_click def imp_proc_on_click(b): if imp_tb_name is not None: import subprocess progress.clear_output() # tb_name = imp_select.value.split('/')[-1].split('.')[0] tb_name = imp_tb_name.value.replace(' ', '').lower()[:15] outlog("Importing .shp to database...") command = [ 'ogr2ogr', '-f', 'PostgreSQL', 'PG:' + db.conn_str(), '-nln', tb_name, '-nlt', 'PROMOTE_TO_MULTI', '-nlt', 'GEOMETRY', imp_select.value ] if imp_truncate.value is True: command.extend(['--config', 'OGR_TRUNCATE', 'YES']) if subprocess.call(command) == 0: progress.clear_output() outlog( f"Completed. Total number of rows in table '{tb_name}':", db.exact_count(tb_name)) else: outlog("Could not import shp file.") else: outlog( "Please add a name for the parcels table (MAX 15 char e.g.: escat2020)." ) @imp_refresh.on_click def imp_refresh_on_click(b): imp_select.options = [ s for s in glob.glob(f'{shp_dist_folder.value}/*') if '.shp' in s ] imp_box = HBox( [imp_tb_name, imp_select, imp_refresh, imp_proc, imp_truncate]) return VBox([l_up, shp_box, l_imp, imp_box, progress])
def button_factory(description, color='lightgray'): return Button(description=description, button_style='', layout=BUTTON_LAYOUT, style={'button_color': color})
def extraction(): start = DatePicker(description='Start date:', disabled=False) end = DatePicker(description='End date:', disabled=False) dates = HBox([start, end]) bt_sig_s2 = Button(description='Sentinel 2', value=False, disabled=False, button_style='info', tooltip='Run Sentinel 2 extraction', icon='fa-play') bt_sig_bs = Button(description='S1 Backscattering', value=False, disabled=True, button_style='info', tooltip='Run S1 Backscattering extraction', icon='fa-play') bt_sig_c6 = Button(description='S1 6-day coherence', value=False, disabled=True, button_style='info', tooltip='Run S1 6-day coherence extraction', icon='fa-play') progress = Output() def outlog(*text): with progress: print(*text) bt_sg_box = VBox([bt_sig_s2, bt_sig_bs, bt_sig_c6]) tab_box = Tab(children=[bt_sg_box, Text()]) tab_box.set_title(0, 'Procedures') tab_box.set_title(1, 'VM Workers config') @bt_sig_s2.on_click def bt_sig_s2_on_click(b): progress.clear_output() with progress: try: delta = end.value - start.value for d in range(delta.days): pgS2Extract.main(start.value, end.value) except Exception as err: outlog(err) @bt_sig_bs.on_click def bt_sig_bs_on_click(b): progress.clear_output() with progress: try: delta = end.value - start.value for d in range(delta.days): pgS1bsExtract.extractS1bs(start.value, end.value) except Exception as err: outlog(err) @bt_sig_c6.on_click def bt_sig_c6_on_click(b): progress.clear_output() with progress: outlog( "6-day coherence extraction not yet available please check for updates." ) return VBox([dates, bt_sg_box, progress])
def __init__(self, **kwargs): super(TaskManager, self).__init__(**kwargs) # Header self.checkbox = Checkbox(indent=False, layout=Layout(flex='1 1 20', width='auto')) self.cancel_selected = Button(description='Cancel Selected', tooltip='Cancel all selected tasks') self.cancel_all = Button(description='Cancell All', tooltip='Cancel all tasks') self.refresh = Button(description='Refresh', tooltip='Refresh Tasks List') self.autorefresh = ToggleButton( description='auto-refresh', tooltip='click to enable/disable autorefresh') self.slider = IntSlider(min=1, max=10, step=1, value=5) self.hbox = HBox([ self.checkbox, self.refresh, self.cancel_selected, self.cancel_all, self.autorefresh, self.slider ]) # Tabs for COMPLETED, FAILED, etc self.tabs = Tab() # Tabs index self.tab_index = { 0: 'RUNNING', 1: 'COMPLETED', 2: 'FAILED', 3: 'CANCELED', 4: 'UNKNOWN' } self.taskVBox = VBox() self.runningVBox = VBox() self.completedVBox = VBox() self.failedVBox = VBox() self.canceledVBox = VBox() self.unknownVBox = VBox() self.tab_widgets_rel = { 'RUNNING': self.runningVBox, 'COMPLETED': self.completedVBox, 'FAILED': self.failedVBox, 'CANCELED': self.canceledVBox, 'UNKNOWN': self.unknownVBox } # Create Tabs self.tab_widgets = [] for key, val in self.tab_index.items(): widget = self.tab_widgets_rel[val] self.tab_widgets.append(widget) self.tabs.children = self.tab_widgets self.tabs.set_title(key, val) ''' autorefresh def update_task_list(widget): # widget is a VBox tasklist = ee.data.getTaskList() widlist = [] for task in tasklist: accordion = create_accordion(task) if task.has_key('description'): name = '{} ({})'.format(task['description'], task['state']) else: name = '{} ({})'.format(task['output_url'][0].split('/')[-1], task['state']) mainacc = Accordion(children=(accordion, )) mainacc.set_title(0, name) mainacc.selected_index = None wid = CheckRow(mainacc) #wid = CheckRow(accordion) widlist.append(wid) widget.children = tuple(widlist) ''' def loop(widget): while True: self.update_task_list()(self.refresh) time.sleep(self.slider.value) # First widget self.update_task_list(vbox=self.runningVBox)(self.refresh) # self.children = (self.hbox, self.taskVBox) self.children = (self.hbox, self.tabs) # Set on_click for refresh button self.refresh.on_click(self.update_task_list(vbox=self.selected_tab())) ''' autorefresh thread = threading.Thread(target=loop, args=(self.taskVBox,)) thread.start() ''' # Set on_clicks self.cancel_all.on_click(self.cancel_all_click) self.cancel_selected.on_click(self.cancel_selected_click)
def _dock_add_button(self, name, callback, layout=None): widget = Button(description=name) widget.on_click(lambda x: callback()) self._layout_add_widget(layout, widget) return _IpyWidget(widget)
def create_expanded_button(description, button_style): return Button(description=description, button_style=button_style, layout=Layout(height='auto', width='auto'))
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} param_name1 = Button(description='tumor_radius', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'lightgreen' self.tumor_radius = FloatText(value=250.0, step=10, style=style, layout=widget_layout) param_name2 = Button(description='oncoprotein_mean', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'tan' self.oncoprotein_mean = FloatText(value=1.0, step=0.1, style=style, layout=widget_layout) param_name3 = Button(description='oncoprotein_sd', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'lightgreen' self.oncoprotein_sd = FloatText(value=0.25, step=0.01, style=style, layout=widget_layout) param_name4 = Button(description='oncoprotein_min', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.oncoprotein_min = FloatText(value=0.0, step=0.01, style=style, layout=widget_layout) param_name5 = Button(description='oncoprotein_max', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'lightgreen' self.oncoprotein_max = FloatText(value=2, step=0.1, style=style, layout=widget_layout) param_name6 = Button(description='random_seed', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.random_seed = IntText(value=0, step=1, style=style, layout=widget_layout) units_button1 = Button(description='micron', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'lightgreen' units_button4 = Button(description='', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'tan' units_button5 = Button(description='', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'lightgreen' units_button6 = Button(description='', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'tan' desc_button1 = Button(description='', disabled=True, layout=desc_button_layout) desc_button1.style.button_color = 'lightgreen' desc_button2 = Button(description='', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button(description='', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button4 = Button(description='', disabled=True, layout=desc_button_layout) desc_button4.style.button_color = 'tan' desc_button5 = Button(description='', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button(description='', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' row1 = [param_name1, self.tumor_radius, units_button1, desc_button1] row2 = [ param_name2, self.oncoprotein_mean, units_button2, desc_button2 ] row3 = [param_name3, self.oncoprotein_sd, units_button3, desc_button3] row4 = [param_name4, self.oncoprotein_min, units_button4, desc_button4] row5 = [param_name5, self.oncoprotein_max, units_button5, desc_button5] row6 = [param_name6, self.random_seed, units_button6, desc_button6] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) self.tab = VBox([ box1, box2, box3, box4, box5, box6, ])
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} param_name1 = Button(description='random_seed', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'lightgreen' self.random_seed = IntText(value=0, step=1, style=style, layout=widget_layout) param_name2 = Button(description='scale_factor', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'tan' self.scale_factor = FloatText(value=300., step=10, style=style, layout=widget_layout) param_name3 = Button(description='persistence_time', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'lightgreen' self.persistence_time = FloatText(value=4.0, step=0.1, style=style, layout=widget_layout) param_name4 = Button(description='migration_speed', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.migration_speed = FloatText(value=0.25, step=0.01, style=style, layout=widget_layout) param_name5 = Button(description='adhesion_strength', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'lightgreen' self.adhesion_strength = FloatText(value=0.5, step=0.1, style=style, layout=widget_layout) param_name6 = Button(description='repulsion_strength', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.repulsion_strength = FloatText(value=0.5, step=0.1, style=style, layout=widget_layout) param_name7 = Button(description='rel_max_adhesion_dist', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'lightgreen' self.rel_max_adhesion_dist = FloatText(value=1.25, step=0.1, style=style, layout=widget_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'tan' units_button3 = Button(description='', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'lightgreen' units_button4 = Button(description='', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'tan' units_button5 = Button(description='', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'lightgreen' units_button6 = Button(description='', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'tan' units_button7 = Button(description='', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'lightgreen' desc_button1 = Button(description='', disabled=True, layout=desc_button_layout) desc_button1.style.button_color = 'lightgreen' desc_button2 = Button(description='', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button(description='', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button4 = Button(description='', disabled=True, layout=desc_button_layout) desc_button4.style.button_color = 'tan' desc_button5 = Button(description='', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button(description='', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' desc_button7 = Button(description='', disabled=True, layout=desc_button_layout) desc_button7.style.button_color = 'lightgreen' row1 = [param_name1, self.random_seed, units_button1, desc_button1] row2 = [param_name2, self.scale_factor, units_button2, desc_button2] row3 = [ param_name3, self.persistence_time, units_button3, desc_button3 ] row4 = [param_name4, self.migration_speed, units_button4, desc_button4] row5 = [ param_name5, self.adhesion_strength, units_button5, desc_button5 ] row6 = [ param_name6, self.repulsion_strength, units_button6, desc_button6 ] row7 = [ param_name7, self.rel_max_adhesion_dist, units_button7, desc_button7 ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) self.tab = VBox([ box1, box2, box3, box4, box5, box6, box7, ])
def annotate(self): self.count_label = HTML() self.set_label_text() display(self.count_label) self.buttons = [] text_id = self.current_index + 1 if self.task_type == 'classification': use_dropdown = len(self.options) > self.max_options_dropdown if use_dropdown: dd = Dropdown(options=self.options) display(dd) else: for label in self.options: btn = Button(description=label) def on_click(label, btn): self.add_annotation(label) btn.on_click(functools.partial(on_click, label)) self.buttons.append(btn) elif self.task_type == 'regression': target_type = type(options[0]) if target_type == int: cls = IntSlider else: cls = FloatSlider if len(options) == 2: min_val, max_val = options slider = cls(min=min_val, max=max_val) else: min_val, max_val, step_val = options slider = cls(min=min_val, max=max_val, step=step_val) display(slider) btn = Button(description='submit') def on_click(btn): add_annotation(slider.value) btn.on_click(on_click) buttons.append(btn) ta = Textarea() display(ta) btn = Button(description='submit', button_style="success") def on_click(btn): self.add_annotation(dd.value, ta.value) btn.on_click(on_click) self.buttons.append(btn) self.box = HBox(self.buttons) display(self.box) self.out = Output() display(self.out) self.show_next()
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} menv_var1 = Button(description='thanos', disabled=True, layout=name_button_layout) menv_var1.style.button_color = 'tan' param_name1 = Button(description='diffusion_coefficient', disabled=True, layout=name_button_layout) self.thanos_diffusion_coefficient = FloatText(value=100000.0, step=10000, style=style, layout=widget_layout) param_name2 = Button(description='decay_rate', disabled=True, layout=name_button_layout) self.thanos_decay_rate = FloatText(value=1, step=0.1, style=style, layout=widget_layout) param_name3 = Button(description='initial_condition', disabled=True, layout=name_button_layout) self.thanos_initial_condition = FloatText(value=0.0, style=style, layout=widget_layout) param_name4 = Button(description='Dirichlet_boundary_condition', disabled=True, layout=name_button_layout) self.thanos_Dirichlet_boundary_condition = FloatText( value=1.0, style=style, layout=widget_layout) self.thanos_Dirichlet_boundary_condition_toggle = Checkbox( description='on/off', disabled=False, style=style, layout=widget_layout) menv_var2 = Button(description='avenger', disabled=True, layout=name_button_layout) menv_var2.style.button_color = 'lightgreen' param_name5 = Button(description='diffusion_coefficient', disabled=True, layout=name_button_layout) self.avenger_diffusion_coefficient = FloatText(value=100000.0, step=10000, style=style, layout=widget_layout) param_name6 = Button(description='decay_rate', disabled=True, layout=name_button_layout) self.avenger_decay_rate = FloatText(value=1, step=0.1, style=style, layout=widget_layout) param_name7 = Button(description='initial_condition', disabled=True, layout=name_button_layout) self.avenger_initial_condition = FloatText(value=0.0, style=style, layout=widget_layout) param_name8 = Button(description='Dirichlet_boundary_condition', disabled=True, layout=name_button_layout) self.avenger_Dirichlet_boundary_condition = FloatText( value=1.0, style=style, layout=widget_layout) self.avenger_Dirichlet_boundary_condition_toggle = Checkbox( description='on/off', disabled=False, style=style, layout=widget_layout) self.calculate_gradient = Checkbox(description='calculate_gradients', disabled=False, layout=desc_button_layout) self.track_internal = Checkbox(description='track_in_agents', disabled=False, layout=desc_button_layout) # ------- micronenv info menv_units_button1 = Button(description='micron^2/min', disabled=True, layout=units_button_layout) menv_units_button2 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button2 = Button(description='', disabled=True, layout=units_button_layout) menv_units_button5 = Button(description='micron^2/min', disabled=True, layout=units_button_layout) menv_units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button3 = Button(description='', disabled=True, layout=units_button_layout) units_button4 = Button(description='', disabled=True, layout=units_button_layout) row_thanos = [ menv_var1, ] row1 = [ param_name1, self.thanos_diffusion_coefficient, menv_units_button1 ] row2 = [param_name2, self.thanos_decay_rate, menv_units_button2] row3 = [param_name3, self.thanos_initial_condition, units_button1] row4 = [ param_name4, self.thanos_Dirichlet_boundary_condition, units_button2, self.thanos_Dirichlet_boundary_condition_toggle ] row_avenger = [ menv_var2, ] row5 = [ param_name5, self.avenger_diffusion_coefficient, menv_units_button5 ] row6 = [param_name6, self.avenger_decay_rate, menv_units_button6] row7 = [param_name7, self.avenger_initial_condition, units_button3] row8 = [ param_name8, self.avenger_Dirichlet_boundary_condition, units_button4, self.avenger_Dirichlet_boundary_condition_toggle ] row9 = [ self.calculate_gradient, ] row10 = [ self.track_internal, ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box_thanos = Box(children=row_thanos, layout=box_layout) box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box_avenger = Box(children=row_avenger, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box8 = Box(children=row8, layout=box_layout) box9 = Box(children=row9, layout=box_layout) box10 = Box(children=row10, layout=box_layout) self.tab = VBox([ box_thanos, box1, box2, box3, box4, box_avenger, box5, box6, box7, box8, box9, box10, ])
def __init__( self, path=os.getcwd(), filename='', title='', select_desc='Select', change_desc='Change', show_hidden=False, select_default=False, use_dir_icons=False, **kwargs ): """Initialize FileChooser object.""" self._default_path = path.rstrip(os.path.sep) self._default_filename = filename self._selected_path = None self._selected_filename = None self._show_hidden = show_hidden self._select_desc = select_desc self._change_desc = change_desc self._callback = None self._use_dir_icons = use_dir_icons # Widgets self._pathlist = Dropdown( description="", layout=Layout( width='auto', grid_area='pathlist' ) ) self._filename = Text( placeholder='output filename', layout=Layout( width='auto', grid_area='filename' ) ) self._dircontent = Select( rows=8, layout=Layout( width='auto', grid_area='dircontent' ) ) self._cancel = Button( description='Cancel', layout=Layout( width='auto', display='none' ), ) self._cancel.button_style='danger' self._select = Button( description=self._select_desc, layout=Layout(width='auto') ) self._select.button_style='info' self._title = HTML( value=title ) if title == '': self._title.layout.display = 'none' # Widget observe handlers self._pathlist.observe( self._on_pathlist_select, names='value' ) self._dircontent.observe( self._on_dircontent_select, names='value' ) self._filename.observe( self._on_filename_change, names='value' ) self._select.on_click(self._on_select_click) self._cancel.on_click(self._on_cancel_click) # Selected file label self._label = HTML( value=self._LBL_TEMPLATE.format( self._LBL_NOFILE, 'black' ), placeholder='', description='' ) # Layout self._gb = GridBox( children=[ self._pathlist, self._filename, self._dircontent ], layout=Layout( display='none', width='500px', grid_gap='0px 0px', grid_template_rows='auto auto', grid_template_columns='60% 40%', grid_template_areas=''' 'pathlist filename' 'dircontent dircontent' ''' ) ) buttonbar = HBox( children=[ self._select, self._cancel, self._label ], layout=Layout(width='auto') ) # Call setter to set initial form values self._set_form_values( self._default_path, self._default_filename ) # Use the defaults as the selected values if select_default: self._apply_selection() # Call VBox super class __init__ super().__init__( children=[ self._title, self._gb, buttonbar, ], layout=Layout(width='auto'), **kwargs )
def annotate(examples, example_labels=None, options=None, shuffle=False, include_skip=True, display_fn=display): """ Build an interactive widget for annotating a list of input examples. Parameters ---------- examples: list(any), list of items to annotate example_labels: list(string), if examples are one large numpy array options: list(any) or tuple(start, end, [step]) or None if list: list of labels for binary classification task (Dropdown or Buttons) if tuple: range for regression task (IntSlider or FloatSlider) if None: arbitrary text input (TextArea) shuffle: bool, shuffle the examples before annotating include_skip: bool, include option to skip example while annotating display_fn: func, function for displaying an example to the user Returns ------- annotations : list of tuples, list of annotated examples (example, label) """ examples = list(examples) use_example_labels = True if example_labels is None: use_example_labels = False example_labels = examples if shuffle: ind_shuff = np.arange(len(examples)) random.shuffle(ind_shuff) examples = examples[ind_shuff] example_labels = example_labels[ind_shuff] annotations = [] current_index = -1 def set_label_text(): nonlocal count_label count_label.value = '{} examples annotated, {} examples left'.format( len(annotations), len(examples) - current_index) def show_next(): nonlocal current_index current_index += 1 set_label_text() if current_index >= len(examples): for btn in buttons: btn.disabled = True print('Annotation done.') return with out: clear_output(wait=True) display_fn(examples[current_index]) def add_annotation(annotation): annotations.append((example_labels[current_index], annotation)) show_next() def skip(btn): show_next() count_label = HTML() set_label_text() display(count_label) if type(options) == list: task_type = 'classification' elif type(options) == tuple and len(options) in [2, 3]: task_type = 'regression' elif options is None: task_type = 'captioning' else: raise Exception('Invalid options') buttons = [] if task_type == 'classification': use_dropdown = len(options) > 5 if use_dropdown: dd = Dropdown(options=options) display(dd) btn = Button(description='submit') def on_click(btn): add_annotation(dd.value) btn.on_click(on_click) buttons.append(btn) else: for label in options: btn = Button(description=label) def on_click(label, btn): add_annotation(label) btn.on_click(functools.partial(on_click, label)) buttons.append(btn) elif task_type == 'regression': target_type = type(options[0]) if target_type == int: cls = IntSlider else: cls = FloatSlider if len(options) == 2: min_val, max_val = options slider = cls(min=min_val, max=max_val) else: min_val, max_val, step_val = options slider = cls(min=min_val, max=max_val, step=step_val) display(slider) btn = Button(description='submit') def on_click(btn): add_annotation(slider.value) btn.on_click(on_click) buttons.append(btn) else: ta = Textarea() display(ta) btn = Button(description='submit') def on_click(btn): add_annotation(ta.value) btn.on_click(on_click) buttons.append(btn) if include_skip: btn = Button(description='skip') btn.on_click(skip) buttons.append(btn) box = HBox(buttons) display(box) out = Output() display(out) show_next() return annotations
'g61': g61 }) import warnings warnings.filterwarnings("ignore") return display(VBox([yyy, ww, w8, out6])) def inputs(): taxonomia_cargada = pd.read_csv('tax_file.tsv', sep='\t').fillna('NA') return taxonomia_cargada import tkinter as tk from tkinter import filedialog yyy = Button(layout=Layout(width='94%', height='5px'), disabled=True) yyy.style.button_color = 'red' xxx = Button(layout=Layout(width='94%', height='5px'), disabled=True) xxx.style.button_color = 'white' upload_tax = widgets.Checkbox(description='Upload file', value=False, disabled=False) def file_tax(upload_tax): if upload_tax == True: root = tk.Tk() root.withdraw() root.attributes("-topmost", True) file_path = filedialog.askopenfilename() root.destroy()
def __init__(self, description, task_name): self.description = description self.task_name = task_name self.button = Button(description=description)
def __init__(self): micron_units = Label( 'micron') # use "option m" (Mac, for micro symbol) constWidth = '180px' tab_height = '500px' stepsize = 10 #style = {'description_width': '250px'} style = {'description_width': '25%'} layout = {'width': '400px'} name_button_layout = {'width': '25%'} widget_layout = {'width': '15%'} units_button_layout = {'width': '15%'} desc_button_layout = {'width': '45%'} divider_button_layout = {'width': '40%'} param_name1 = Button(description='random_seed', disabled=True, layout=name_button_layout) param_name1.style.button_color = 'lightgreen' self.random_seed = IntText(value=0, step=1, style=style, layout=widget_layout) div_row1 = Button(description='---Virus Replication---', disabled=True, layout=divider_button_layout) param_name2 = Button(description='virion_uncoating_rate', disabled=True, layout=name_button_layout) param_name2.style.button_color = 'tan' self.virion_uncoating_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) param_name3 = Button(description='uncoated_to_RNA_rate', disabled=True, layout=name_button_layout) param_name3.style.button_color = 'lightgreen' self.uncoated_to_RNA_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) param_name4 = Button(description='protein_synthesis_rate', disabled=True, layout=name_button_layout) param_name4.style.button_color = 'tan' self.protein_synthesis_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) param_name5 = Button(description='virion_assembly_rate', disabled=True, layout=name_button_layout) param_name5.style.button_color = 'lightgreen' self.virion_assembly_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) div_row2 = Button(description='---Virus Adsorption and Export---', disabled=True, layout=divider_button_layout) param_name6 = Button(description='virion_export_rate', disabled=True, layout=name_button_layout) param_name6.style.button_color = 'tan' self.virion_export_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) div_row3 = Button( description='---ACE2 receptor dynamics with virus binding---', disabled=True, layout=divider_button_layout) param_name7 = Button(description='ACE2_receptors_per_cell', disabled=True, layout=name_button_layout) param_name7.style.button_color = 'lightgreen' self.ACE2_receptors_per_cell = FloatText(value=1000, step=100, style=style, layout=widget_layout) param_name8 = Button(description='ACE2_binding_rate', disabled=True, layout=name_button_layout) param_name8.style.button_color = 'tan' self.ACE2_binding_rate = FloatText(value=0.001, step=0.0001, style=style, layout=widget_layout) param_name9 = Button(description='ACE2_endocytosis_rate', disabled=True, layout=name_button_layout) param_name9.style.button_color = 'lightgreen' self.ACE2_endocytosis_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) param_name10 = Button(description='ACE2_cargo_release_rate', disabled=True, layout=name_button_layout) param_name10.style.button_color = 'tan' self.ACE2_cargo_release_rate = FloatText(value=0.001, step=0.0001, style=style, layout=widget_layout) param_name11 = Button(description='ACE2_recycling_rate', disabled=True, layout=name_button_layout) param_name11.style.button_color = 'lightgreen' self.ACE2_recycling_rate = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) div_row4 = Button(description='---Apoptotic Response---', disabled=True, layout=divider_button_layout) param_name12 = Button(description='max_infected_apoptosis_rate', disabled=True, layout=name_button_layout) param_name12.style.button_color = 'tan' self.max_infected_apoptosis_rate = FloatText(value=0.001, step=0.0001, style=style, layout=widget_layout) param_name13 = Button(description='max_apoptosis_half_max', disabled=True, layout=name_button_layout) param_name13.style.button_color = 'lightgreen' self.max_apoptosis_half_max = FloatText(value=500, step=10, style=style, layout=widget_layout) param_name14 = Button(description='apoptosis_hill_power', disabled=True, layout=name_button_layout) param_name14.style.button_color = 'tan' self.apoptosis_hill_power = FloatText(value=1, step=0.1, style=style, layout=widget_layout) param_name15 = Button(description='virus_fraction_released_at_death', disabled=True, layout=name_button_layout) param_name15.style.button_color = 'lightgreen' self.virus_fraction_released_at_death = FloatText(value=0, step=0.01, style=style, layout=widget_layout) div_row5 = Button(description='---Initialization Options--', disabled=True, layout=divider_button_layout) param_name16 = Button(description='multiplicity_of_infection', disabled=True, layout=name_button_layout) param_name16.style.button_color = 'tan' self.multiplicity_of_infection = FloatText(value=0.01, step=0.001, style=style, layout=widget_layout) param_name17 = Button(description='use_single_infected_cell', disabled=True, layout=name_button_layout) param_name17.style.button_color = 'lightgreen' self.use_single_infected_cell = Checkbox(value=False, style=style, layout=widget_layout) div_row6 = Button(description='---Visualization Options---', disabled=True, layout=divider_button_layout) param_name18 = Button(description='color_variable', disabled=True, layout=name_button_layout) param_name18.style.button_color = 'tan' self.color_variable = Text(value='assembled virion', style=style, layout=widget_layout) units_button1 = Button(description='', disabled=True, layout=units_button_layout) units_button1.style.button_color = 'lightgreen' units_button2 = Button(description='', disabled=True, layout=units_button_layout) units_button2.style.button_color = 'lightgreen' units_button3 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button3.style.button_color = 'tan' units_button4 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button4.style.button_color = 'lightgreen' units_button5 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button5.style.button_color = 'tan' units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button6.style.button_color = 'lightgreen' units_button7 = Button(description='', disabled=True, layout=units_button_layout) units_button7.style.button_color = 'lightgreen' units_button8 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button8.style.button_color = 'tan' units_button9 = Button(description='', disabled=True, layout=units_button_layout) units_button9.style.button_color = 'tan' units_button10 = Button(description='', disabled=True, layout=units_button_layout) units_button10.style.button_color = 'lightgreen' units_button11 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button11.style.button_color = 'tan' units_button12 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button12.style.button_color = 'lightgreen' units_button13 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button13.style.button_color = 'tan' units_button14 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button14.style.button_color = 'lightgreen' units_button15 = Button(description='', disabled=True, layout=units_button_layout) units_button15.style.button_color = 'lightgreen' units_button16 = Button(description='1/min', disabled=True, layout=units_button_layout) units_button16.style.button_color = 'tan' units_button17 = Button(description='virion', disabled=True, layout=units_button_layout) units_button17.style.button_color = 'lightgreen' units_button18 = Button(description='', disabled=True, layout=units_button_layout) units_button18.style.button_color = 'tan' units_button19 = Button(description='', disabled=True, layout=units_button_layout) units_button19.style.button_color = 'lightgreen' units_button20 = Button(description='', disabled=True, layout=units_button_layout) units_button20.style.button_color = 'lightgreen' units_button21 = Button(description='', disabled=True, layout=units_button_layout) units_button21.style.button_color = 'tan' units_button22 = Button(description='', disabled=True, layout=units_button_layout) units_button22.style.button_color = 'lightgreen' units_button23 = Button(description='', disabled=True, layout=units_button_layout) units_button23.style.button_color = 'lightgreen' units_button24 = Button(description='', disabled=True, layout=units_button_layout) units_button24.style.button_color = 'tan' desc_button1 = Button(description='', tooltip='', disabled=True, layout=desc_button_layout) desc_button1.style.button_color = 'lightgreen' desc_button2 = Button( description='rate at which an internalized virion is uncoated', tooltip='rate at which an internalized virion is uncoated', disabled=True, layout=desc_button_layout) desc_button2.style.button_color = 'tan' desc_button3 = Button( description= 'rate at which uncoated virion makes its mRNA available', tooltip='rate at which uncoated virion makes its mRNA available', disabled=True, layout=desc_button_layout) desc_button3.style.button_color = 'lightgreen' desc_button4 = Button( description='rate at mRNA creates complete set of proteins', tooltip='rate at mRNA creates complete set of proteins', disabled=True, layout=desc_button_layout) desc_button4.style.button_color = 'tan' desc_button5 = Button( description= 'rate at which viral proteins are assembled into complete virion', tooltip= 'rate at which viral proteins are assembled into complete virion', disabled=True, layout=desc_button_layout) desc_button5.style.button_color = 'lightgreen' desc_button6 = Button( description='rate at which a virion is exported from a live cell', tooltip='rate at which a virion is exported from a live cell', disabled=True, layout=desc_button_layout) desc_button6.style.button_color = 'tan' desc_button7 = Button(description='number of ACE2 receptors per cell', tooltip='number of ACE2 receptors per cell', disabled=True, layout=desc_button_layout) desc_button7.style.button_color = 'lightgreen' desc_button8 = Button(description='ACE2 receptor-virus binding rate', tooltip='ACE2 receptor-virus binding rate', disabled=True, layout=desc_button_layout) desc_button8.style.button_color = 'tan' desc_button9 = Button( description='ACE2 receptor-virus endocytosis rate', tooltip='ACE2 receptor-virus endocytosis rate', disabled=True, layout=desc_button_layout) desc_button9.style.button_color = 'lightgreen' desc_button10 = Button( description='ACE2 receptor-virus cargo release rate', tooltip='ACE2 receptor-virus cargo release rate', disabled=True, layout=desc_button_layout) desc_button10.style.button_color = 'tan' desc_button11 = Button(description='ACE2 receptor recycling rate', tooltip='ACE2 receptor recycling rate', disabled=True, layout=desc_button_layout) desc_button11.style.button_color = 'lightgreen' desc_button12 = Button( description='maximum rate of cell apoptosis due to viral infection', tooltip='maximum rate of cell apoptosis due to viral infection', disabled=True, layout=desc_button_layout) desc_button12.style.button_color = 'tan' desc_button13 = Button( description= 'viral load at which cells reach half max apoptosis rate', tooltip='viral load at which cells reach half max apoptosis rate', disabled=True, layout=desc_button_layout) desc_button13.style.button_color = 'lightgreen' desc_button14 = Button( description='Hill power for viral load apoptosis response', tooltip='Hill power for viral load apoptosis response', disabled=True, layout=desc_button_layout) desc_button14.style.button_color = 'tan' desc_button15 = Button( description='fraction of internal virus released at cell death', tooltip='fraction of internal virus released at cell death', disabled=True, layout=desc_button_layout) desc_button15.style.button_color = 'lightgreen' desc_button16 = Button( description='multiplicity of infection: virions/cells at t=0', tooltip='multiplicity of infection: virions/cells at t=0', disabled=True, layout=desc_button_layout) desc_button16.style.button_color = 'tan' desc_button17 = Button( description='Infect center cell with one virion (overrides MOI)', tooltip='Infect center cell with one virion (overrides MOI)', disabled=True, layout=desc_button_layout) desc_button17.style.button_color = 'lightgreen' desc_button18 = Button( description='color cells based on this variable', tooltip='color cells based on this variable', disabled=True, layout=desc_button_layout) desc_button18.style.button_color = 'tan' row1 = [param_name1, self.random_seed, units_button1, desc_button1] row2 = [ param_name2, self.virion_uncoating_rate, units_button3, desc_button2 ] row3 = [ param_name3, self.uncoated_to_RNA_rate, units_button4, desc_button3 ] row4 = [ param_name4, self.protein_synthesis_rate, units_button5, desc_button4 ] row5 = [ param_name5, self.virion_assembly_rate, units_button6, desc_button5 ] row6 = [ param_name6, self.virion_export_rate, units_button8, desc_button6 ] row7 = [ param_name7, self.ACE2_receptors_per_cell, units_button10, desc_button7 ] row8 = [ param_name8, self.ACE2_binding_rate, units_button11, desc_button8 ] row9 = [ param_name9, self.ACE2_endocytosis_rate, units_button12, desc_button9 ] row10 = [ param_name10, self.ACE2_cargo_release_rate, units_button13, desc_button10 ] row11 = [ param_name11, self.ACE2_recycling_rate, units_button14, desc_button11 ] row12 = [ param_name12, self.max_infected_apoptosis_rate, units_button16, desc_button12 ] row13 = [ param_name13, self.max_apoptosis_half_max, units_button17, desc_button13 ] row14 = [ param_name14, self.apoptosis_hill_power, units_button18, desc_button14 ] row15 = [ param_name15, self.virus_fraction_released_at_death, units_button19, desc_button15 ] row16 = [ param_name16, self.multiplicity_of_infection, units_button21, desc_button16 ] row17 = [ param_name17, self.use_single_infected_cell, units_button22, desc_button17 ] row18 = [ param_name18, self.color_variable, units_button24, desc_button18 ] box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%') box1 = Box(children=row1, layout=box_layout) box2 = Box(children=row2, layout=box_layout) box3 = Box(children=row3, layout=box_layout) box4 = Box(children=row4, layout=box_layout) box5 = Box(children=row5, layout=box_layout) box6 = Box(children=row6, layout=box_layout) box7 = Box(children=row7, layout=box_layout) box8 = Box(children=row8, layout=box_layout) box9 = Box(children=row9, layout=box_layout) box10 = Box(children=row10, layout=box_layout) box11 = Box(children=row11, layout=box_layout) box12 = Box(children=row12, layout=box_layout) box13 = Box(children=row13, layout=box_layout) box14 = Box(children=row14, layout=box_layout) box15 = Box(children=row15, layout=box_layout) box16 = Box(children=row16, layout=box_layout) box17 = Box(children=row17, layout=box_layout) box18 = Box(children=row18, layout=box_layout) self.tab = VBox([ box1, div_row1, box2, box3, box4, box5, div_row2, box6, div_row3, box7, box8, box9, box10, box11, div_row4, box12, box13, box14, box15, div_row5, box16, box17, div_row6, box18, ])