Skip to content

Commit

Permalink
Shift VariantQC to only render one section of plots at a time. Mostly…
Browse files Browse the repository at this point in the history
… written by @yanm (#16)
  • Loading branch information
bbimber authored Jan 25, 2018
1 parent 96422e1 commit 3694fea
Show file tree
Hide file tree
Showing 7 changed files with 2,256 additions and 3,039 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class HtmlGenerator {
};

public static final String[] JS_SCRIPTS2 = new String[]{
"templates/assets/js/multiqc.js",
"templates/assets/js/multiqc_tables.js",
"templates/assets/js/multiqc_toolbox.js",
"templates/assets/js/multiqc.js",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,102 @@ var brewer_scales = ['YlOrRd', 'YlOrBr', 'YlGnBu', 'YlGn', 'Reds', 'RdPu',
'Paired', 'Dark2', 'Accent', 'Spectral', 'RdYlGn', 'RdYlBu', 'RdGy', 'RdBu',
'PuOr', 'PRGn', 'PiYG', 'BrBG'];


// TOOLBOX LISTENERS

// Update tablesorter if samples renamed
$(document).on('mqc_renamesamples', function(e, f_texts, t_texts, regex_mode){
$('.mqc_table').trigger('update');
});

// highlight samples
$(document).on('mqc_highlights', function(e, f_texts, f_cols, regex_mode){
$('.mqc_table_sortHighlight').hide();
$('.mqc_table tbody th').removeClass('highlighted').removeData('highlight');
$('.mqc_table tbody th').each(function(i){
var th = $(this);
var thtext = $(this).text();
var thiscol = '#333';
$.each(f_texts, function(idx, f_text){
if((regex_mode && thtext.match(f_text)) || (!regex_mode && thtext.indexOf(f_text) > -1)){
thiscol = f_cols[idx];
th.addClass('highlighted').data('highlight', idx);
$('.mqc_table_sortHighlight').show();
}
});
$(this).css('color', thiscol);
});
});

// Rename samples
$(document).on('mqc_renamesamples', function(e, f_texts, t_texts, regex_mode){
$(".mqc_table tbody th").each(function(){
var s_name = $(this).data('original-sn');
$.each(f_texts, function(idx, f_text){
if(regex_mode){
var re = new RegExp(f_text,"g");
s_name = s_name.replace(re, t_texts[idx]);
} else {
s_name = s_name.replace(f_text, t_texts[idx]);
}
});
$(this).text(s_name);
});
});

// Hide samples
$(document).on('mqc_hidesamples', function(e, f_texts, regex_mode){
// Hide rows in MultiQC tables
$(".mqc_table tbody th").each(function(){
var match = false;
var hfilter = $(this).text();
$.each(f_texts, function(idx, f_text){
if((regex_mode && hfilter.match(f_text)) || (!regex_mode && hfilter.indexOf(f_text) > -1)){
match = true;
}
});
if(window.mqc_hide_mode == 'show'){
match = !match;
}
if(match){
$(this).parent().hide().addClass('hidden');
} else {
$(this).parent().show().removeClass('hidden');
}
});
$('.mqc_table_numrows').each(function(){
var tid = $(this).attr('id').replace('_numrows','');
$(this).text( $('#'+tid+' tbody tr:visible').length );
});

// Hide empty columns
$('.mqc_table').each(function(){
var table = $(this);
var gsthidx = 0;
table.find("thead th, tbody tr td").show();
table.find("thead th").each(function(){
if(gsthidx == 0){ gsthidx += 1; return true; }
var count = 0;
var empties = 0;
table.find("tbody tr td:nth-child("+(gsthidx+2)+")").filter(":visible").each(function(){
count += 1;
if($(this).text() == ''){ empties += 1; }
});
if(count > 0 && count == empties){
$(this).hide();
table.find("tbody tr td:nth-child("+(gsthidx+2)+")").hide();
}
gsthidx += 1;
});
});
$('.mqc_table_numcols').each(function(){
var tid = $(this).attr('id').replace('_numcols','');
$(this).text( $('#'+tid+' thead th:visible').length - 1 );
});
});

// Execute when page load has finished loading
$(function () {
function render_tables() {

if($('.mqc_table').length > 0){

Expand All @@ -22,11 +116,6 @@ $(function () {
}
});

// Update tablesorter if samples renamed
$(document).on('mqc_renamesamples', function(e, f_texts, t_texts, regex_mode){
$('.mqc_table').trigger('update');
});

// Copy table contents to clipboard
var clipboard = new Clipboard('.mqc_table_copy_btn');
clipboard.on('success', function(e) { e.clearSelection(); });
Expand Down Expand Up @@ -162,27 +251,6 @@ $(function () {
change_mqc_table_col_order( $(this) );
});

// TOOLBOX LISTENERS

// highlight samples
$(document).on('mqc_highlights', function(e, f_texts, f_cols, regex_mode){
$('.mqc_table_sortHighlight').hide();
$('.mqc_table tbody th').removeClass('highlighted').removeData('highlight');
$('.mqc_table tbody th').each(function(i){
var th = $(this);
var thtext = $(this).text();
var thiscol = '#333';
$.each(f_texts, function(idx, f_text){
if((regex_mode && thtext.match(f_text)) || (!regex_mode && thtext.indexOf(f_text) > -1)){
thiscol = f_cols[idx];
th.addClass('highlighted').data('highlight', idx);
$('.mqc_table_sortHighlight').show();
}
});
$(this).css('color', thiscol);
});
});

// Sort MultiQC tables by highlight
$('.mqc_table_sortHighlight').click(function(e){
e.preventDefault();
Expand All @@ -202,74 +270,6 @@ $(function () {
}
});

// Rename samples
$(document).on('mqc_renamesamples', function(e, f_texts, t_texts, regex_mode){
$(".mqc_table tbody th").each(function(){
var s_name = $(this).data('original-sn');
$.each(f_texts, function(idx, f_text){
if(regex_mode){
var re = new RegExp(f_text,"g");
s_name = s_name.replace(re, t_texts[idx]);
} else {
s_name = s_name.replace(f_text, t_texts[idx]);
}
});
$(this).text(s_name);
});
});

// Hide samples
$(document).on('mqc_hidesamples', function(e, f_texts, regex_mode){

// Hide rows in MultiQC tables
$(".mqc_table tbody th").each(function(){
var match = false;
var hfilter = $(this).text();
$.each(f_texts, function(idx, f_text){
if((regex_mode && hfilter.match(f_text)) || (!regex_mode && hfilter.indexOf(f_text) > -1)){
match = true;
}
});
if(window.mqc_hide_mode == 'show'){
match = !match;
}
if(match){
$(this).parent().hide().addClass('hidden');
} else {
$(this).parent().show().removeClass('hidden');
}
});
$('.mqc_table_numrows').each(function(){
var tid = $(this).attr('id').replace('_numrows','');
$(this).text( $('#'+tid+' tbody tr:visible').length );
});

// Hide empty columns
$('.mqc_table').each(function(){
var table = $(this);
var gsthidx = 0;
table.find("thead th, tbody tr td").show();
table.find("thead th").each(function(){
if(gsthidx == 0){ gsthidx += 1; return true; }
var count = 0;
var empties = 0;
table.find("tbody tr td:nth-child("+(gsthidx+2)+")").filter(":visible").each(function(){
count += 1;
if($(this).text() == ''){ empties += 1; }
});
if(count > 0 && count == empties){
$(this).hide();
table.find("tbody tr td:nth-child("+(gsthidx+2)+")").hide();
}
gsthidx += 1;
});
});
$('.mqc_table_numcols').each(function(){
var tid = $(this).attr('id').replace('_numcols','');
$(this).text( $('#'+tid+' thead th:visible').length - 1 );
});
});

} // End of check for table

// Table Scatter Modal
Expand Down Expand Up @@ -421,7 +421,7 @@ $(function () {
}
});

});
};

// Reorder columns in MultiQC tables.
// Note: Don't have to worry about floating headers, as 'Configure Columns'
Expand Down
Loading

0 comments on commit 3694fea

Please sign in to comment.