8e7458b6824acecaeae94cf3969e152c0cf9ee3d kate Sun May 13 21:16:14 2012 -0700 Generalize experiment matrix to handle mouse diff --git src/hg/js/encodeDataMatrix.js src/hg/js/encodeDataMatrix.js index c18ca6f..5129795 100644 --- src/hg/js/encodeDataMatrix.js +++ src/hg/js/encodeDataMatrix.js @@ -28,39 +28,39 @@ dataTypes = responses[1], cellTypes = responses[2]; var dataGroups, cellTiers; var dataType, cellType; var matrix, dataTypeExps = {}; // hide spinner and show table encodeMatrix.show($matrixTable); // set up structures for data types and their groups // data type labels tucked into their tiers dataGroups = encodeProject.getDataGroups(dataTypes); // set up structures for cell types and their tiers - cellTiers = encodeProject.getCellTiers(cellTypes); + cellTiers = encodeProject.getCellTiers(cellTypes, encodeMatrix_organism); // gather experiments into matrix // NOTE: dataTypeExps is populated here matrix = makeExperimentMatrix(experiments, dataTypeExps); // fill in table using matrix - encodeMatrix.tableOut($matrixTable, matrix, cellTiers, - dataGroups, dataTypeExps, tableHeaderOut, rowAddCells); + encodeMatrix.tableOut($matrixTable, matrix, cellTiers, dataGroups, dataTypeExps, + encodeProject.pruneDataGroupsToExps, tableHeaderOut, rowAddCells); } function makeExperimentMatrix(experiments, dataTypeExps) { // Populate dataType vs. cellType array with counts of experiments var dataType, cellType; var matrix = {}; $.each(experiments, function (i, exp) { // exclude ref genome annotations if (exp.cellType === 'None') { return true; } // count experiments per dataType so we can prune those having none @@ -72,108 +72,102 @@ } dataTypeExps[dataType]++; cellType = exp.cellType; if (!matrix[cellType]) { matrix[cellType] = {}; } if (!matrix[cellType][dataType]) { matrix[cellType][dataType] = 0; } matrix[cellType][dataType]++; }); return matrix; } - function tableHeaderOut($table, dataGroups, dataTypeExps) { + function tableHeaderOut($table, dataGroups) { // Generate table header and add to document // NOTE: relies on hard-coded classes and ids var $tableHeaders, $thead, $th; var maxLen, dataType; // fill in column headers from dataTypes returned by server $tableHeaders = $('#columnHeaders'); $thead = $('thead'); // 1st column is row headers // colgroups are needed to support cross-hair hover effect $thead.before('<colgroup></colgroup>'); $.each(dataGroups, function (i, group) { $tableHeaders.append('<th class="groupType"><div class="verticalText">' + group.label + '</div></th>'); maxLen = Math.max(maxLen, group.label.length); $thead.before('<colgroup></colgroup>'); $.each(group.dataTypes, function (i, label) { dataType = encodeProject.getDataTypeByLabel(label); - - // prune out datatypes with no experiments - if (dataTypeExps[dataType.term] !== undefined) { $th = $('<th class="elementType"><div class="verticalText">' + dataType.label + // add button to launch ChIP-seq (but suppress on IE) (dataType.term === 'ChipSeq' && !$.browser.msie ? ' <span title="Click to view ChIP-seq experiment matrix by antibody target" id="chipButton">view matrix</span>': '') + '</div></th>'); if (!encodeProject.isIE8()) { // Suppress mouseOver under IE8 as QA noted flashing effect $th.attr('title', dataType.description); } $tableHeaders.append($th); - // add colgroup element to support cross-hair hover effect $thead.before('<colgroup class="experimentCol"></colgroup>'); maxLen = Math.max(maxLen, dataType.label.length); - } }); }); // add click handler to navigate to Chip-seq matrix $('#chipButton').click(function() { - window.open('encodeChipMatrixHuman.html', 'matrixWindow'); + window.open(encodeMatrix.pageForChipMatrix(encodeMatrix_organism), 'matrixWindow'); }); // adjust size of headers based on longest label length // empirically len/2 em's is right $('#columnHeaders th').css('height', (String((maxLen/2 + 2)).concat('em'))); $('#columnHeaders th').css('width', '1em'); //also need to set additional width for non-IE if (!$.browser.msie) { $('.verticalText').css('width', '1em'); } } - function rowAddCells($row, dataGroups, dataTypeExps, matrix, cellType) { + function rowAddCells($row, dataGroups, matrix, cellType) { // populate a row in the matrix with cells for data groups and data types // null cellType indicates this is a row for a cell group (tier) var $td; $.each(dataGroups, function (i, group) { // skip group header $td = $('<td></td>'); $td.addClass('matrixCell'); $row.append($td); - - $.each(group.dataTypes, function (i, dataTypeLabel) { - dataType = encodeProject.getDataTypeByLabel(dataTypeLabel).term; - // prune out datatypes with no experiments - if (dataTypeExps[dataType] === undefined) { + if (!group.dataTypes.length) { + // no data types in this organism for this group return true; } + $.each(group.dataTypes, function (i, dataTypeLabel) { + dataType = encodeProject.getDataTypeByLabel(dataTypeLabel).term; $td = $('<td></td>'); $td.addClass('matrixCell'); $row.append($td); if (cellType === null) { return true; } if (!matrix[cellType][dataType]) { $td.addClass('todoExperiment'); return true; } // this cell represents experiments that // fill in count, mouseover and selection by click $td.addClass('experiment'); $td.text(matrix[cellType][dataType]); $td.data({