def _checkbox_group(source, subgroup_col): checkbox_title = Div(text=str(subgroup_col).title() + ": ") checkbox_labels = sorted(set(source.data[subgroup_col])) actives = list(range(len(checkbox_labels))) checkboxes = CheckboxGroup( labels=checkbox_labels, active=actives, inline=True, name="subgroup_checkbox", ) checkboxes.js_on_change( "active", CustomJS(code="source.change.emit();", args={"source": source})) return Row(checkbox_title, checkboxes, name="subgroup_widget")
for(var i=0;i<pc1.length; i++){ if(tissue[i]==f){ x.push(pc1[i]); y.push(pc2[i]); } } data1['comp 0']=x; data1['comp 1']=y; source.change.emit(); """) p = makePlot(source) selection = CheckboxGroup(labels=dataCats, active=[0, 1]) selection.js_on_change('active', callback) controls = WidgetBox(selection) layout = row(controls, p) tab = Panel(child=layout, title='test') tabs = Tabs(tabs=[tab]) #curdoc().add_root(tabs) show(tabs) #cancer_selection = CheckboxGroup(labels=list(___), active = [0,1]) # #show(p) #show(widgetbox(cancer_selection)) # # #def makePlot(data):
Sytsq+=yt[i]*yt[i]; Sexpsq+=exp[i]*exp[i]; } TSR=(95*Sytexp-Sexp*Syt)/Math.sqrt(95*Sytsq-Syt*Syt)/Math.sqrt(95*Sexpsq-Sexp*Sexp) TSR=Math.round(TSR*100)/100 corlabTS.text='TS R='.concat(TSR.toString()) source.trigger('change'); """) cbox.js_on_change('active', cb) slider.js_on_change('value', cb_slider) rb_group.js_on_change('active', cb_ff) rb_group2.js_on_change('active', cb_struct) div = Div(text="""<b>Figure: Comparison of H-SASA profiles calculated with different parameters with experimental cleavage frequencies. Top strand (TS) of <i>S. cerevisiae</i> centromeric nucleosome with 601TA DNA sequence.</b> <br><br> This interactive plot allows to explore dependence of H-SASA profiles on different paramters. Correlation coefficient is interactively displayed in the bottom left corner. Use contols above to choose between following paramters:<br><br> <b>Structure used for calculations</b>: X-H nuclear - orginal X-ray derived structure, hydrogen atoms added via REDUCE program with nuclear distances for X-H bond length; X-H electron - original X-ray derived structure, hydrogen atoms added via REDUCE program with electron cloud distances for X-H bond length; MD average - average profile for 50 frames spaced 1 ns apart from molecular dynamics simulations with CHARMM36 force field with NAMD. <br><br> <b>Radii of atoms used for SASA calculations</b>: FreeSASA Default - default radii in FreeSASA program; CHARMM36-rmin - van der Waals radii (Rmin paramter) of atoms as defined by CHARMM36 force field; AMBER10-rmin - van der Waals radii (Rmin paramter) of atoms as defined by AMBER10 force field. <br><br> <b>Contributions of deoxyribose hydrogen atoms</b>: SASA of deoxyribose hydrogen atoms selected will be included in calculation of H-SASA profile.
title='Depth Cutoff') slider_af = Slider(start=0, end=100, step=1, value=1, title='Allele Frequency Cutoff') slider_af.js_on_change( 'value', sliderCallback(source_sample, depth_sample, slider, slider_af, syngroup, unique_longitudinal_muts)) slider.js_on_change( 'value', sliderCallback(source_sample, depth_sample, slider, slider_af, syngroup, unique_longitudinal_muts)) syngroup.js_on_change( 'active', sliderCallback(source_sample, depth_sample, slider, slider_af, syngroup, unique_longitudinal_muts)) ose.js_on_change( 'value', sliderCallback2(source_sample, depth_sample, slider, slider_af, syngroup, ose, unique_longitudinal_muts)) # When mousing over Bokeh plot, allele frequency updated to user input. if (user_af != -123): slider_af.value = user_af ## g.js_on_event(events.PlotEvent, sliderCallback(source_sample, depth_sample, slider, slider_af, syngroup)) genome_plot.js_on_event( events.MouseEnter, sliderCallback(source_sample, depth_sample, slider, slider_af, syngroup, unique_longitudinal_muts))
def show_projection(alg, selected_ids, dim_red, directionality): filename = "static/data/anchs_" title = "2D Projection - Key Features" samples = 7468 if (not alg): samples = 3114 filename = "static/data/changes_" title = "2D Projection - Changes" filename += dim_red if (not directionality): filename += "_dir_False" filename += ".csv" fp = open(filename, 'r', encoding='utf-8') X = np.zeros((samples, 2)) ids = [] category = [] ft_selected_ids = [] for i in range(samples): roww = fp.readline().split(',') # print(roww) ids.append(int(roww[0])) X[i][0] = float(roww[3]) X[i][1] = float(roww[4]) if int(roww[0]) in selected_ids: ft_selected_ids.append(1) else: ft_selected_ids.append(0) if roww[2] == "TP": category.append(0) elif roww[2] == "TN": category.append(1) elif roww[2] == "FP": category.append(2) elif roww[2] == "FN": category.append(3) # percentage.append(float(roww[4])) fp.close() for p in range(1, 2): x = [] y = [] for i in range(samples): x.append(X[i][0]) y.append(X[i][1]) ################# ################# ##### bokeh ##### ################# ################# color_opt = [ "rgb(27, 158, 119)", "rgb(217, 95, 2)", "rgb(27, 158, 119)", "rgb(217, 95, 2)", "gray" ] alpha_opt = [0.6, 0.05] line_opt = [ "rgb(27, 158, 119)", "rgb(217, 95, 2)", "black", "black", "gray" ] if (len(ft_selected_ids) > 0): alpha_opt = [0.7, 0.02] colors = [] line_color = [] fill_alpha = [] line_alpha = [] for k in range(samples): if ft_selected_ids[k]: colors.append(color_opt[category[k]]) line_color.append(line_opt[category[k]]) fill_alpha.append(alpha_opt[0]) line_alpha.append(alpha_opt[0]) else: colors.append(color_opt[-1]) line_color.append(line_opt[-1]) fill_alpha.append(alpha_opt[-1]) line_alpha.append(alpha_opt[-1]) output_file('2d_changes_map.html') s1 = ColumnDataSource(data=dict(x=x, y=y, ids=ids, category=category, colors=colors, fill_alpha=fill_alpha, line_alpha=line_alpha, line_color=line_color, ft_selected_ids=ft_selected_ids)) hover = HoverTool(tooltips=""" """) # help_b = HelpTool(help_tooltip = """ """) wheel_zoom = WheelZoomTool() lasso_select = LassoSelectTool() p1 = figure( tools=[hover, lasso_select, "reset", "tap", wheel_zoom, "pan"], toolbar_location="right", toolbar_sticky=False, title=title, width=390, height=390) # p1.circle('x', 'y', source=s1, size=7.3, fill_alpha = 'fill_alpha', line_alpha = 'line_alpha', fill_color = 'colors', line_color = 'line_color', # nonselection_fill_alpha=alpha_opt[-1], # nonselection_fill_color=color_opt[-1], # nonselection_line_color=color_opt[-1], # nonselection_line_alpha=alpha_opt[-1] # ) p1.title.text_font_size = '10pt' p1.title.align = 'center' p1.toolbar.active_scroll = wheel_zoom p1.toolbar.active_drag = lasso_select p1.axis.visible = False lasso_select.select_every_mousemove = False # CheckboxGroup to select categories category_selection = CheckboxGroup(labels=["TP", "TN", "FP", "FN"], active=[0, 1, 2, 3]) selection_callback = CustomJS(args=dict(source=s1), code=""" source.change.emit(); """) category_selection.js_on_change('active', selection_callback) # Define the custom filter to return the indices, compare against values in source.data js_filter = CustomJSFilter(args=dict( category_selection=category_selection, source=s1), code=""" var indices = []; for (var i = 0; i <= source.data['category'].length; i++){ if (category_selection.active.includes(source.data['category'][i])) { indices.push(i) } } return indices; """) s1.callback = CustomJS(code=""" var lasso_ids = cb_obj.selected['1d'].indices; //console.log(lasso_ids); var ft_selected_ids = cb_obj.data['ft_selected_ids']; var ids = cb_obj.data['ids']; //console.log(ft_selected_ids); var aggregation_ids = []; for (i=0; i<ft_selected_ids.length; i++){ if (ft_selected_ids[i] == 1 && lasso_ids.includes(i)){ //console.log(ids[i]); aggregation_ids.push(ids[i]); } } if (!(aggregation_ids && aggregation_ids.length)) { aggregation_ids = [-1]; } console.log(aggregation_ids); //parent.makeBokehRequest(aggregation_ids); parent.makeBokehRequest2(aggregation_ids); """) # Use the filter in a view view = CDSView(source=s1, filters=[js_filter]) p1.circle('x', 'y', source=s1, view=view, size=7.3, fill_alpha='fill_alpha', line_alpha='line_alpha', fill_color='colors', line_color='line_color', nonselection_fill_alpha=alpha_opt[-1], nonselection_fill_color=color_opt[-1], nonselection_line_color=color_opt[-1], nonselection_line_alpha=alpha_opt[-1]) layout = column(p1, category_selection) # show(layout) # grid = gridplot([[p1, None]], merge_tools=False) # # show(grid) html = file_html(layout, CDN, "my_plot") html = html.replace("auto;", "0px;") fp = open("static/html/projection_file_raw.html", 'w') fp.write(html) fp.close() # show_projection(False, list(range(7468)), "pca", True )