UNPKG

clustergrammer

Version:

This is a clustergram implemented in D3.js. I started from the example http://bost.ocks.org/mike/miserables/ and added the following features

94 lines (67 loc) 2.2 kB
/* Example files */ var hzome = ini_hzome(); make_clust('mult_view.json'); var about_string = 'Zoom, scroll, and click buttons to interact with the clustergram. <a href="http://amp.pharm.mssm.edu/clustergrammer/help"> <i class="fa fa-question-circle" aria-hidden="true"></i> </a>'; function make_clust(inst_network){ d3.json('json/'+inst_network, function(network_data){ // define arguments object var args = { root: '#container-id-1', 'network_data': network_data, 'about':about_string, 'row_tip_callback':hzome.gene_info, 'col_tip_callback':test_col_callback, 'tile_tip_callback':test_tile_callback, 'dendro_callback':dendro_callback, 'matrix_update_callback':matrix_update_callback, 'cat_update_callback': cat_update_callback, 'sidebar_width':150, // 'ini_view':{'N_row_var':20} // 'ini_expand':true }; resize_container(args); d3.select(window).on('resize',function(){ resize_container(args); cgm.resize_viz(); }); cgm = Clustergrammer(args); check_setup_enrichr(cgm); d3.select(cgm.params.root + ' .wait_message').remove(); }); } function matrix_update_callback(){ if (genes_were_found[this.root]){ enr_obj[this.root].clear_enrichr_results(false); } } function cat_update_callback(){ console.log('callback to run after cats are updated'); } function test_tile_callback(tile_data){ var row_name = tile_data.row_name; var col_name = tile_data.col_name; } function test_col_callback(col_data){ var col_name = col_data.name; } function dendro_callback(inst_selection){ var inst_rc; var inst_data = inst_selection.__data__; // toggle enrichr export section if (inst_data.inst_rc === 'row'){ d3.select('.enrichr_export_section') .style('display', 'block'); } else { d3.select('.enrichr_export_section') .style('display', 'none'); } } function resize_container(args){ var screen_width = window.innerWidth; var screen_height = window.innerHeight - 20; d3.select(args.root) .style('width', screen_width+'px') .style('height', screen_height+'px'); }