Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 50945: Show counts per metric for outliers in QC Summary view of all replicates #953

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions resources/views/peptideSummary.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
margin-top: 1em;
}

.outlier-count {
text-align: right
}

</style>

<label for="date-range">Date Range:</label>
Expand Down Expand Up @@ -161,7 +165,7 @@
function generateTable(data) {
$('#fom-loading').hide();
const tableContainer = document.getElementById('table-container');
let tableHTML = '<table id="heatmap-table" class="heatmap-table">';
let tableHTML = '<table id="heatmap-table" class="table-condensed labkey-data-region-legacy labkey-show-borders">';
tableHTML += '<thead><tr><th></th>';

for (let i = 0; i < data.metrics.length; i++) {
Expand Down Expand Up @@ -191,7 +195,7 @@
for (let j = 0; j < data.metrics.length; j++) {
let metric = data.metrics[j];
if (data.peptideOutliers[i].outlierCountsPerMetric[metric]) {
tableHTML += '<td>' + data.peptideOutliers[i].outlierCountsPerMetric[metric] + '</td>';
tableHTML += '<td class="outlier-count">' + data.peptideOutliers[i].outlierCountsPerMetric[metric] + '</td>';
if (!totalOutliersByMetric[metric]) {
totalOutliersByMetric[metric] = 0;
}
Expand All @@ -200,11 +204,11 @@

}
else {
tableHTML += '<td>0</td>';
tableHTML += '<td class="outlier-count">0</td>';
}

if (j === data.metrics.length - 1) {
tableHTML += '<td><b>' + LABKEY.Utils.encodeHtml(data.peptideOutliers[i].totalOutliers) + '</b></td>';
tableHTML += '<td class="outlier-count"><b>' + LABKEY.Utils.encodeHtml(data.peptideOutliers[i].totalOutliers) + '</b></td>';
}
}
tableHTML += '</tr>';
Expand All @@ -215,13 +219,13 @@
for (let i = 0; i < data.metrics.length; i++) {
if (totalOutliersByMetric[data.metrics[i]]) {
sumOfOutliers += totalOutliersByMetric[data.metrics[i]];
tableHTML += '<td><b>' + LABKEY.Utils.encodeHtml(totalOutliersByMetric[data.metrics[i]]) + '</b></td>';
tableHTML += '<td class="outlier-count"><b>' + LABKEY.Utils.encodeHtml(totalOutliersByMetric[data.metrics[i]]) + '</b></td>';
}
else {
tableHTML += '<td><b>0</b></td>';
tableHTML += '<td class="outlier-count"><b>0</b></td>';
}
}
tableHTML += '<td><b>' + sumOfOutliers + '</b></td>';
tableHTML += '<td class="outlier-count"><b>' + sumOfOutliers + '</b></td>';
tableHTML += '</tbody></table>';
tableContainer.innerHTML = tableHTML;

Expand Down
105 changes: 66 additions & 39 deletions webapp/TargetedMS/js/QCSummaryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Ext4.define('LABKEY.targetedms.QCSummary', {
getContainerSummaryView: function (container, hasChildren, width) {
container.viewCmpId = Ext4.id();
container.autoQcCalloutId = Ext4.id();
container.width = width;

var config = {
id: container.viewCmpId,
Expand Down Expand Up @@ -296,49 +297,75 @@ Ext4.define('LABKEY.targetedms.QCSummary', {
},

renderContainerSampleFileStats: function (params) {
var container = params.container;
var html = '<table class="table-condensed labkey-data-region-legacy labkey-show-borders">';
html += '<thead><tr><td></td></td><td class="labkey-column-header">Replicate Name</td><td class="labkey-column-header">Acquired</td><td class="labkey-column-header">Outliers</td></tr></thead>';
var sampleFiles = params.sampleFiles;
Ext4.iterate(sampleFiles, function (sampleFile) {
// create a new div id for each sampleFile to use for the hover details callout
sampleFile.calloutId = Ext4.id();

var totalOutliers = sampleFile.Value;

var iconCls;
if (sampleFile.IgnoreForAllMetric)
iconCls = 'fa-ban qc-none';
else if (totalOutliers > 0)
iconCls = 'fa-times-rectangle qc-error';
else
iconCls = 'fa-check qc-correct';
html += '<tr id="' + sampleFile.calloutId + '"><td>'
+ '<span class="fa ' + iconCls + '" style="width: 1em; text-align: center"></span></td><td><div class="sample-file-item">' + Ext4.util.Format.htmlEncode(sampleFile.ReplicateName) + '</div></td><td><div class="sample-file-item-acquired">' + Ext4.util.Format.date(sampleFile.AcquiredTime ? new Date(sampleFile.AcquiredTime) : null, LABKEY.extDefaultDateTimeFormat || 'Y-m-d H:i:s') + '</div></td>';

if (sampleFile.IgnoreForAllMetric) {
html += '<td><div class="sample-file-item-total-outliers" style="text-align: center">excluded</div></td>';
}
else {
html += '<td style="text-align: right"><div class="sample-file-item-total-outliers">' + totalOutliers + "</div></td>"
}
html += '</tr>';
let container = params.container;
let sampleFiles = params.sampleFiles;
let metrics = sampleFiles[0].Metrics;
let showMetrics = container.fileCount <= sampleFiles.length && metrics && metrics.length > 0;
let tableWidth = container.width - 100;
let html = '';
let thead = '';
if (showMetrics) {
html = '<table class="table-condensed labkey-data-region-legacy labkey-show-borders" style="width: ' + tableWidth + 'px">';
thead = '<thead><tr><td></td></td><td class="labkey-column-header">Replicate Name</td><td class="labkey-column-header">Acquired</td>';
Ext4.each(metrics, function (item) {
thead += '<td class="labkey-column-header">' + Ext4.util.Format.htmlEncode(item.MetricLabel) + '</td>';
});
html += '</table>';
if (container.fileCount > sampleFiles.length) {
html += '<div class="qc-summary-text"><a href="' + LABKEY.ActionURL.buildURL('targetedms', 'qcSummaryHistory.view', container.path) + '">View all ' + container.fileCount + ' replicates and utilization calendar <span class="fa fa-calendar"></span></a></div>';
thead += '<td class="labkey-column-header"><b>Total</b></td>';
}
else {
html = '<table class="table-condensed labkey-data-region-legacy labkey-show-borders">';
thead = '<thead><tr><td></td></td><td class="labkey-column-header">Replicate Name</td><td class="labkey-column-header">Acquired</td><td class="labkey-column-header">Outliers</td>';
}

thead += '</tr></thead>';
html += thead;

Ext4.iterate(sampleFiles, function (sampleFile) {
// create a new div id for each sampleFile to use for the hover details callout
sampleFile.calloutId = Ext4.id();

var totalOutliers = sampleFile.Value;

var iconCls;
if (sampleFile.IgnoreForAllMetric)
iconCls = 'fa-ban qc-none';
else if (totalOutliers > 0)
iconCls = 'fa-times-rectangle qc-error';
else
iconCls = 'fa-check qc-correct';
html += '<tr id="' + sampleFile.calloutId + '"><td>'
+ '<span class="fa ' + iconCls + '" style="width: 1em; text-align: center"></span></td><td><div class="sample-file-item">' + Ext4.util.Format.htmlEncode(sampleFile.ReplicateName) + '</div></td><td><div class="sample-file-item-acquired" style="text-wrap: nowrap">' + Ext4.util.Format.date(sampleFile.AcquiredTime ? new Date(sampleFile.AcquiredTime) : null, LABKEY.extDefaultDateTimeFormat || 'Y-m-d H:i:s') + '</div></td>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should HTML encode the formatted time just to be safe.




if (showMetrics) {
Ext4.each(sampleFile.Metrics, function (metric) {
html += '<td><div class="sample-file-item" style="text-align: right">' + Ext4.util.Format.htmlEncode(metric.Value) + '</div></td>';
});
}
var sampleFilesDiv = Ext4.get('qc-summary-samplefiles-' + container.id);
sampleFilesDiv.update(html);
sampleFilesDiv.removeCls('sample-file-details-loading');
if (sampleFile.IgnoreForAllMetric) {
html += '<td><div class="sample-file-item-total-outliers" style="text-align: center"><b>excluded</b></div></td>';
}
else {
html += '<td><div class="sample-file-item-total-outliers" style="text-align: right"><b>' + totalOutliers + "</b></div></td>"
}
html += '</tr>';
});
html += '</table>';
if (container.fileCount > sampleFiles.length) {
html += '<div class="qc-summary-text"><a href="' + LABKEY.ActionURL.buildURL('targetedms', 'qcSummaryHistory.view', container.path) + '">View all ' + container.fileCount + ' replicates and utilization calendar <span class="fa fa-calendar"></span></a></div>';
}
var sampleFilesDiv = Ext4.get('qc-summary-samplefiles-' + container.id);
sampleFilesDiv.update(html);
sampleFilesDiv.removeCls('sample-file-details-loading');

// since the height of the panel will change from adding up to three lines of text, need to reset the size of the view
this.doLayout();
// since the height of the panel will change from adding up to three lines of text, need to reset the size of the view
this.doLayout();

// add a hover listener for each of the sample file divs
Ext4.iterate(sampleFiles, function (sampleFile) {
this.showSampleFileStatsDetails(sampleFile.calloutId, sampleFile);
}, this);
// add a hover listener for each of the sample file divs
Ext4.iterate(sampleFiles, function (sampleFile) {
this.showSampleFileStatsDetails(sampleFile.calloutId, sampleFile);
}, this);
},

showSampleFileStatsDetails : function(divId, sampleFile) {
Expand Down