Skip to content

Commit b9cbf04

Browse files
committed
Allow seurat/subset to abort when no further cells found
1 parent aa4d50c commit b9cbf04

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/util/AbstractGenomicsDBImportHandler.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,9 @@ public static void validateNoSplitContigScatter(VariantProcessingStep.ScatterGat
8282
return;
8383
}
8484

85-
if (vj.getScatterGatherMethod() == VariantProcessingStep.ScatterGatherMethod.fixedJobs || vj.getScatterGatherMethod() == VariantProcessingStep.ScatterGatherMethod.chunked)
85+
if (vj.doAllowSplitContigs())
8686
{
87-
if (vj.doAllowSplitContigs())
88-
{
89-
throw new IllegalArgumentException("This job does not support scatter methods with allowSplitContigs=true");
90-
}
87+
throw new IllegalArgumentException("This job does not support scatter methods with allowSplitContigs=true");
9188
}
9289
}
9390

singlecell/src/org/labkey/singlecell/pipeline/singlecell/SubsetSeurat.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,25 @@ protected List<String> loadChunkFromFile() throws PipelineJobException
7979
{
8080
String subsetEscaped = subset.replace("'", "\\\'");
8181

82-
ret.add("\tcells <- c()");
83-
ret.add("\ttryCatch({");
84-
ret.add("\t\tcells <- WhichCells(so, expression = " + subset + ")");
85-
ret.add("\t}, error = function(e){");
86-
ret.add("\t\tif (!is.null(e) && e$message == 'Cannot find cells provided') {");
87-
ret.add("\t\t\tprint(paste0('There were no cells remaining after the subset: ', '" + subsetEscaped + "'))");
88-
ret.add("\t\t}");
89-
ret.add("\t})");
90-
ret.add("");
91-
ret.add("\tif (length(cells) == 0) {");
92-
ret.add("\t\tprint(paste0('There were no cells after subsetting for dataset: ', datasetId, ', with subset: ', '" + subsetEscaped + "'))");
93-
ret.add("\t} else {");
94-
ret.add("\t\tseuratObj <- subset(seuratObj, cells = cells)");
95-
ret.add("\t\tprint(paste0('Cells after subset: ', ncol(seuratObj)))");
96-
ret.add("\t\tnewSeuratObjects[[datasetId]] <- seuratObj");
97-
ret.add("\t}");
82+
ret.add("\tif (!is.null(seuratObj)) {");
83+
ret.add("\t\tcells <- c()");
84+
ret.add("\t\ttryCatch({");
85+
ret.add("\t\t\tcells <- WhichCells(seuratObj, expression = " + subset + ")");
86+
ret.add("\t\t}, error = function(e){");
87+
ret.add("\t\t\tif (!is.null(e) && e$message == 'Cannot find cells provided') {");
88+
ret.add("\t\t\t\tprint(paste0('There were no cells remaining after the subset: ', '" + subsetEscaped + "'))");
89+
ret.add("\t\t\t}");
90+
ret.add("\t\t})");
9891
ret.add("");
92+
ret.add("\t\tif (length(cells) == 0) {");
93+
ret.add("\t\t\tprint(paste0('There were no cells after subsetting for dataset: ', datasetId, ', with subset: ', '" + subsetEscaped + "'))");
94+
ret.add("\t\t\tseuratObj <- NULL");
95+
ret.add("\t\t} else {");
96+
ret.add("\t\t\tseuratObj <- subset(seuratObj, cells = cells)");
97+
ret.add("\t\t\tprint(paste0('Cells after subset: ', ncol(seuratObj)))");
98+
ret.add("\t\t\tnewSeuratObjects[[datasetId]] <- seuratObj");
99+
ret.add("\t\t}");
100+
ret.add("}");
99101
}
100102
}
101103
else

0 commit comments

Comments
 (0)