Skip to content

Commit

Permalink
Support additional params for nimble append
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Jan 26, 2025
1 parent 585b31a commit 46f5727
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
3 changes: 2 additions & 1 deletion singlecell/resources/chunks/AppendNimble.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ for (datasetId in names(seuratObjects)) {
for (genomeId in names(nimbleGenomes)) {
maxAmbiguityAllowed <- nimbleGenomeAmbiguousPreference[[genomeId]]
queryDatabaseForLineageUpdates <- queryDatabaseForLineageUpdatesPreference[[genomeId]]
seuratObj <- Rdiscvr::DownloadAndAppendNimble(seuratObject = seuratObj, allowableGenomes = genomeId, ensureSamplesShareAllGenomes = ensureSamplesShareAllGenomes, targetAssayName = nimbleGenomes[[genomeId]], enforceUniqueFeatureNames = TRUE, maxAmbiguityAllowed = maxAmbiguityAllowed, maxLibrarySizeRatio = maxLibrarySizeRatio, queryDatabaseForLineageUpdates = queryDatabaseForLineageUpdates)
replaceExistingAssayData <- replaceExistingAssayDataByGenome[[genomeId]]
seuratObj <- Rdiscvr::DownloadAndAppendNimble(seuratObject = seuratObj, allowableGenomes = genomeId, ensureSamplesShareAllGenomes = ensureSamplesShareAllGenomes, targetAssayName = nimbleGenomes[[genomeId]], enforceUniqueFeatureNames = TRUE, maxAmbiguityAllowed = maxAmbiguityAllowed, maxLibrarySizeRatio = maxLibrarySizeRatio, queryDatabaseForLineageUpdates = queryDatabaseForLineageUpdates, replaceExistingAssayData = replaceExistingAssayData)
}

saveData(seuratObj, datasetId)
Expand Down
21 changes: 16 additions & 5 deletions singlecell/resources/web/singlecell/panel/NimbleAppendPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Ext4.define('SingleCell.panel.NimbleAppendPanel', {
initComponent: function(){
Ext4.apply(this, {
style: 'padding: 10px;margins: 5px;',
minWidth: 950,
minWidth: 1025,
border: true,
items: [{
html: 'This step will query nimble results for the selected genome(s). It will then append these results to the seurat object on the target assay.',
Expand All @@ -20,7 +20,7 @@ Ext4.define('SingleCell.panel.NimbleAppendPanel', {
},{
xtype: 'ldk-gridpanel',
clicksToEdit: 1,
width: 875,
width: 1000,
tbar: [{
text: 'Add',
handler: function(btn){
Expand All @@ -40,7 +40,7 @@ Ext4.define('SingleCell.panel.NimbleAppendPanel', {
},LABKEY.ext4.GRIDBUTTONS.DELETERECORD()],
store: {
type: 'array',
fields: ['genomeId', 'targetAssay','maxAmbiguityAllowed', 'queryDatabaseForLineageUpdates']
fields: ['genomeId', 'targetAssay','maxAmbiguityAllowed', 'queryDatabaseForLineageUpdates', 'replaceExistingAssayData']
},
columns: [{
dataIndex: 'genomeId',
Expand Down Expand Up @@ -86,6 +86,16 @@ Ext4.define('SingleCell.panel.NimbleAppendPanel', {
allowBlank: true,
value: false
}
},{
dataIndex: 'replaceExistingAssayData',
width: 150,
header: 'Replace Existing Data?',
editor: {
xtype: 'checkbox',
allowBlank: true,
value: true
}

}]
}]
});
Expand All @@ -96,7 +106,7 @@ Ext4.define('SingleCell.panel.NimbleAppendPanel', {
getValue: function(){
var ret = [];
this.down('ldk-gridpanel').store.each(function(r, i) {
ret.push([r.data.genomeId, r.data.targetAssay, r.data.maxAmbiguityAllowed ?? '', !!r.data.queryDatabaseForLineageUpdates]);
ret.push([r.data.genomeId, r.data.targetAssay, r.data.maxAmbiguityAllowed ?? '', !!r.data.queryDatabaseForLineageUpdates], !!r.data.replaceExistingAssayData);
}, this);

return Ext4.isEmpty(ret) ? null : JSON.stringify(ret);
Expand Down Expand Up @@ -133,7 +143,8 @@ Ext4.define('SingleCell.panel.NimbleAppendPanel', {
genomeId: row[0],
targetAssay: row[1],
maxAmbiguityAllowed: row[2],
queryDatabaseForLineageUpdates: !!row[3]
queryDatabaseForLineageUpdates: !!row[3],
replaceExistingAssayData: !!row[4]
});
grid.store.add(rec);
}, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur
for (int i = 0; i < json.length(); i++)
{
JSONArray arr = json.getJSONArray(i);
if (arr.length() != 4)
if (arr.length() != 5)
{
throw new PipelineJobException("Unexpected value: " + json.get(i));
}
Expand All @@ -96,7 +96,7 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur
for (int i = 0; i < json.length(); i++)
{
JSONArray arr = json.getJSONArray(i);
if (arr.length() < 3)
if (arr.length() != 5)
{
throw new PipelineJobException("Unexpected value: " + json.getString(i));
}
Expand All @@ -118,13 +118,32 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur
for (int i = 0; i < json.length(); i++)
{
JSONArray arr = json.getJSONArray(i);
if (arr.length() != 4)
if (arr.length() != 5)
{
throw new PipelineJobException("Unexpected value: " + json.getString(i));
}

int genomeId = arr.getInt(0);
String valStr = arr.get(2) == null ? null : StringUtils.trimToNull(String.valueOf(arr.get(2)));
String valStr = arr.get(3) == null ? null : StringUtils.trimToNull(String.valueOf(arr.get(2)));
boolean val = Boolean.parseBoolean(valStr);

ret.bodyLines.add("\t" + delim + "'" + genomeId + "' = " + (val ? "TRUE" : "FALSE"));
delim = ",";
}
ret.bodyLines.add(")");

ret.bodyLines.add("replaceExistingAssayDataByGenome <- list(");
delim = "";
for (int i = 0; i < json.length(); i++)
{
JSONArray arr = json.getJSONArray(i);
if (arr.length() != 5)
{
throw new PipelineJobException("Unexpected value: " + json.getString(i));
}

int genomeId = arr.getInt(0);
String valStr = arr.get(4) == null ? null : StringUtils.trimToNull(String.valueOf(arr.get(2)));
boolean val = Boolean.parseBoolean(valStr);

ret.bodyLines.add("\t" + delim + "'" + genomeId + "' = " + (val ? "TRUE" : "FALSE"));
Expand Down

0 comments on commit 46f5727

Please sign in to comment.