Skip to content

Commit

Permalink
Add calculated field and code to catch HTO libraries with single HTO
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Jan 31, 2024
1 parent 45d7f14 commit 8119303
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion singlecell/resources/web/singlecell/panel/LibraryExportPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ Ext4.define('SingleCell.panel.LibraryExportPanel', {
',readsetId,readsetId/name,readsetId/application,readsetId/librarytype,readsetId/barcode5,readsetId/barcode5/sequence,readsetId/barcode3,readsetId/barcode3/sequence,readsetId/totalFiles,readsetId/concentration' +
',tcrReadsetId,tcrReadsetId/name,tcrReadsetId/application,tcrReadsetId/librarytype,tcrReadsetId/barcode5,tcrReadsetId/barcode5/sequence,tcrReadsetId/barcode3,tcrReadsetId/barcode3/sequence,tcrReadsetId/totalFiles,tcrReadsetId/concentration' +
',hashingReadsetId,hashingReadsetId/name,hashingReadsetId/application,hashingReadsetId/librarytype,hashingReadsetId/barcode5,hashingReadsetId/barcode5/sequence,hashingReadsetId/barcode3,hashingReadsetId/barcode3/sequence,hashingReadsetId/totalFiles,hashingReadsetId/concentration' +
',citeseqReadsetId,citeseqReadsetId/name,citeseqReadsetId/application,citeseqReadsetId/librarytype,citeseqReadsetId/barcode5,citeseqReadsetId/barcode5/sequence,citeseqReadsetId/barcode3,citeseqReadsetId/barcode3/sequence,citeseqReadsetId/totalFiles,citeseqReadsetId/concentration',
',citeseqReadsetId,citeseqReadsetId/name,citeseqReadsetId/application,citeseqReadsetId/librarytype,citeseqReadsetId/barcode5,citeseqReadsetId/barcode5/sequence,citeseqReadsetId/barcode3,citeseqReadsetId/barcode3/sequence,citeseqReadsetId/totalFiles,citeseqReadsetId/concentration,uniqueHtos',
scope: this,
filterArray: [LABKEY.Filter.create('plateId', plateIds.join(';'), LABKEY.Filter.Types.IN)],
failure: LDK.Utils.getErrorCallback(),
Expand All @@ -661,6 +661,7 @@ Ext4.define('SingleCell.panel.LibraryExportPanel', {
if (expectedPairs) {
sortedRows = [];
var missingRows = [];
var errorMsgs = [];
Ext4.Array.forEach(expectedPairs, function(p){
var found = false;
Ext4.Array.forEach(results.rows, function(row){
Expand All @@ -679,6 +680,11 @@ Ext4.define('SingleCell.panel.LibraryExportPanel', {
if (row['hashingReadsetId'] && row['hashingReadsetId/application'] && row['hashingReadsetId/application'] === 'Cell Hashing') {
sortedRows.push(Ext4.apply({targetApplication: '10x HTO', laneAssignment: (p.length > 2 ? p[2] : null), plateAlias: (p.length > 3 ? p[3] : null)}, row));
found = true;

if (row.uniqueHtos <=1) {
errorMsgs.push(row['hashingReadsetId/name'] + ': only ' + row.uniqueHtos + ' present')
}

return false;
}
}
Expand Down Expand Up @@ -713,6 +719,11 @@ Ext4.define('SingleCell.panel.LibraryExportPanel', {
Ext4.Msg.alert('Error', 'The following plates were not found:<br>' + missingRows.join('<br>'));
return;
}

if (errorMsgs.length){
Ext4.Msg.alert('Error', 'The following lanes had HTO libraries, without multiple HTOs:<br>' + errorMsgs.join('<br>'));
return;
}
}

var barcodes = 'Illumina';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ private void customizeCdnas(AbstractTableInfo ti)
}

LDKService.get().applyNaturalSort(ti, "plateId");

String uniqueHTOs = "uniqueHtos";
if (ti.getColumn(uniqueHTOs) == null)
{
SQLFragment sql = new SQLFragment("(SELECT count(DISTINCT s.hto) as expr FROM " + SingleCellSchema.NAME + "." + SingleCellSchema.TABLE_SORTS + " s WHERE s.rowid IN (SELECT DISTINCT sortId FROM " + SingleCellSchema.NAME + "." + SingleCellSchema.TABLE_CDNAS + " c WHERE c.plateid = " + ExprColumn.STR_TABLE_ALIAS + ".plateid AND c.container = " + ExprColumn.STR_TABLE_ALIAS + ".container))");
ExprColumn newCol = new ExprColumn(ti, uniqueHTOs, sql, JdbcType.INTEGER, ti.getColumn("plateId"), ti.getColumn("container"));
newCol.setLabel("Distinct HTOs In Lane");
DetailsURL details = DetailsURL.fromString("/query/executeQuery.view?schemaName=singlecell&query.queryName=cdna_libraries&query.plateId~eq=${plateId}", ti.getUserSchema().getContainer());
newCol.setURL(details);

ti.addColumn(newCol);
}
}

private void customizeSorts(AbstractTableInfo ti)
Expand Down

0 comments on commit 8119303

Please sign in to comment.