8e7458b6824acecaeae94cf3969e152c0cf9ee3d kate Sun May 13 21:16:14 2012 -0700 Generalize experiment matrix to handle mouse diff --git src/hg/js/encodeMatrix.js src/hg/js/encodeMatrix.js index fb7359c..6a51b80 100644 --- src/hg/js/encodeMatrix.js +++ src/hg/js/encodeMatrix.js @@ -25,30 +25,42 @@ $div.append('<span id="searchPanelInstructions">search for: </span>' + '<input type="radio" name="searchType" id="searchTracks" value=' + COOKIE_SEARCH_TRACKS + ' onclick="encodeMatrix.setFileSearch(false);">tracks' + '<input type="radio" name="searchType" id="searchFiles" value=' + COOKIE_SEARCH_FILES + ' onclick="encodeMatrix.setFileSearch(true);" >files'); if (isFile) { $('#searchFiles').attr('checked', true); } else { $('#searchTracks').attr('checked', true); } encodeMatrix.setFileSearch(isFile); } return { + // Page names for other pages in this application + + pageForChipMatrix: function(organism) { + // URL for Chip-seq matrix + return 'encodeChipMatrix' + organism.charAt(0).toUpperCase() + organism.substring(1) + '.html'; + }, + + pageForDataMatrix: function(organism) { + // URL for Chip-seq matrix + return 'encodeDataMatrix' + organism.charAt(0).toUpperCase() + organism.substring(1) + '.html'; + }, + // UI panel for search: select tracks or files setFileSearch: function (isFile) { // Set search type cookie to retain user choice $.cookie(COOKIE_SEARCH, (isFile ? COOKIE_SEARCH_FILES : COOKIE_SEARCH_TRACKS), {expires: 7}); }, isFileSearch: function () { // Check search type cookie to retain user choice // Defaults to track search if no cookie set return ($.cookie(COOKIE_SEARCH) === COOKIE_SEARCH_FILES); }, getSearchUrl: function () { @@ -111,31 +123,30 @@ // General purpose functions start: function ($el) { // Initialize application. Caller passes in jQuery selector object to hide/show // get server from calling web page (e.g. can sub in genome-preview) if ('encodeMatrix_server' in window) { server = encodeMatrix_server; } else { server = document.location.hostname; // or document.domain ? } // variables from calling page - organism = encodeMatrix_organism; assembly = encodeMatrix_assembly; $('#assemblyLabel').text(assembly); header = encodeMatrix_pageHeader; $('#pageHeader').text(header); document.title = 'ENCODE ' + header; encodeProject.setup({ server: server, assembly: assembly }); // show only spinner and (optionally help) until data is retrieved $el.hide(); encodeMatrix.disableHelp(!encodeMatrix.isHelpWanted()); spinner = showLoadingImage(spinnerLoc, true); @@ -242,81 +253,87 @@ } else { $(this).parent().removeClass('crossHair'); $('colGroup').eq($(this).index()).removeClass('crossHair'); } }); }, rotateTableCells: function ($table) { // plugin from David Votrubec, handles IE rotate if ($.browser.msie) { $table.rotateTableCellContent({className: 'verticalText'}); $(this).attr('disabled', 'disabled'); } }, - tableMatrixOut: function ($table, matrix, cellTiers, groups, expCounts, rowAddCells) { + tableMatrixOut: function ($table, matrix, cellTiers, groups, rowAddCells) { // Fill in matrix -- // add rows with cell type labels (column 1) and cells for experiments // add sections for each Tier of cell type var maxLen, karyotype, cellType; var $row; // add sections for each Tier of cells $.each(cellTiers, function (i, tier) { //skip bogus 4th tier (not my property ?) if (tier === undefined) { return true; } + if (cellTiers.length > 1) { + // add row for tier label if there are more than one tier + // (i.e. suppress for mouse) $row = $('<tr class="matrix"><th class="groupType">' + "Tier " + tier.term + '</th></td></tr>'); - rowAddCells($row, groups, expCounts, matrix, null); + rowAddCells($row, groups, matrix, null); $table.append($row); + } maxLen = 0; $.each(tier.cellTypes, function (i, term) { if (!term) { return true; } if (!matrix[term]) { return true; } cellType = encodeProject.getCellType(term); karyotype = cellType.karyotype; if (karyotype !== 'cancer' && karyotype !== 'normal') { karyotype = 'unknown'; } // note karyotype bullet layout requires non-intuitive placement // in code before the span that shows to it's left $row = $('<tr>' + '<th class="elementType">' + '<span style="float:right; text-align: right;" title="karyotype: ' + karyotype + '" class="karyotype ' + karyotype + '">•</span>' + '<span title="' + cellType.description + '"><a target="cvWindow" href="/cgi-bin/hgEncodeVocab?ra=encode/cv.ra&deprecated=true&term=' + encodeURIComponent(cellType.term) + '">' + cellType.term + '</a>' + '</th>' ); maxLen = Math.max(maxLen, cellType.term.length); - rowAddCells($row, groups, expCounts, matrix, cellType.term); + rowAddCells($row, groups, matrix, cellType.term); $table.append($row); }); // adjust size of row headers based on longest label length $('tbody th').css('height', '1em'); $('tbody th').css('width', (String((maxLen/2 + 2)).concat('em'))); }); $('body').append($table); }, - tableOut: function ($table, matrix, cellTiers, groups, expCounts, tableHeaderOut, rowAddCells) { + tableOut: function ($table, matrix, cellTiers, groups, dataTypeExps, + pruneToExps, tableHeaderOut, rowAddCells) { // Create table with rows for each cell type and columns for each antibody target - tableHeaderOut($table, groups, expCounts); - encodeMatrix.tableMatrixOut($table, matrix, cellTiers, groups, expCounts, rowAddCells); + var dataGroups = pruneToExps(groups, dataTypeExps); + tableHeaderOut($table, dataGroups); + encodeMatrix.tableMatrixOut($table, matrix, cellTiers, dataGroups, rowAddCells); encodeMatrix.addTableFloatingHeader($table); encodeMatrix.rotateTableCells($table); encodeMatrix.hoverTableCrossHair($table); } }; }());