Skip to content

Commit

Permalink
Add feature to auto-split cell/lane for 10x import
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Jan 31, 2024
1 parent 04a31f4 commit db93852
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion singlecell/resources/web/singlecell/panel/PoolImportPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,12 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
fieldLabel: 'Use 10x V2/HT (Dual Index)',
itemId: 'useDualIndex',
checked: true
},{
xtype: 'checkbox',
fieldLabel: '# Cells Indicates Totla Per Lane',
helpPopup: '',
itemId: 'cellsReportedAsTotalPerLane',
checked: true
},{
xtype: 'checkbox',
fieldLabel: 'Use MS (Dual Index)',
Expand Down Expand Up @@ -822,6 +828,7 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {

data[col.name] = cell;

// This indicates that the first row from the plateId has a value for cells, but this does not.
if (!cell && col.name === 'cells' && lastValueByCol[colIdx]) {
doSplitCellsByPool = true;
}
Expand All @@ -832,7 +839,8 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
}, this);

//split cells across rows
if (doSplitCellsByPool) {
var cellsReportedAsTotalPerLane = this.down('#cellsReportedAsTotalPerLane').getValue();
if (cellsReportedAsTotalPerLane || doSplitCellsByPool) {
var cellCountMap = {};
Ext4.Array.forEach(ret, function(data) {
if (data.plateId) {
Expand All @@ -844,8 +852,18 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
Ext4.Array.forEach(Ext4.Object.getKeys(cellCountMap), function(plateId) {
var arr = cellCountMap[plateId];
var size = arr.length;

// Two allowable patterns:
// 1) the first row has a value and rest are blank. Take this as the lane total
// 2) all rows have the same value, so take the first as the lane total
arr = Ext4.Array.remove(arr, null);
arr = Ext4.Array.remove(arr, '');

// Only attempt to collapse if this was selected:
if (cellsReportedAsTotalPerLane) {
arr = Ext4.unique(arr);
}

if (arr.length === 1) {
cellCountMap[plateId] = arr[0] / size;
}
Expand Down

0 comments on commit db93852

Please sign in to comment.