@@ -79,23 +79,25 @@ protected List<String> loadChunkFromFile() throws PipelineJobException
7979 {
8080 String subsetEscaped = subset .replace ("'" , "\\ \' " );
8181
82- ret .add ("\t cells <- c()" );
83- ret .add ("\t tryCatch({" );
84- ret .add ("\t \t cells <- WhichCells(so, expression = " + subset + ")" );
85- ret .add ("\t }, error = function(e){" );
86- ret .add ("\t \t if (!is.null(e) && e$message == 'Cannot find cells provided') {" );
87- ret .add ("\t \t \t print(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 ("\t if (length(cells) == 0) {" );
92- ret .add ("\t \t print(paste0('There were no cells after subsetting for dataset: ', datasetId, ', with subset: ', '" + subsetEscaped + "'))" );
93- ret .add ("\t } else {" );
94- ret .add ("\t \t seuratObj <- subset(seuratObj, cells = cells)" );
95- ret .add ("\t \t print(paste0('Cells after subset: ', ncol(seuratObj)))" );
96- ret .add ("\t \t newSeuratObjects[[datasetId]] <- seuratObj" );
97- ret .add ("\t }" );
82+ ret .add ("\t if (!is.null(seuratObj)) {" );
83+ ret .add ("\t \t cells <- c()" );
84+ ret .add ("\t \t tryCatch({" );
85+ ret .add ("\t \t \t cells <- WhichCells(seuratObj, expression = " + subset + ")" );
86+ ret .add ("\t \t }, error = function(e){" );
87+ ret .add ("\t \t \t if (!is.null(e) && e$message == 'Cannot find cells provided') {" );
88+ ret .add ("\t \t \t \t print(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 \t if (length(cells) == 0) {" );
93+ ret .add ("\t \t \t print(paste0('There were no cells after subsetting for dataset: ', datasetId, ', with subset: ', '" + subsetEscaped + "'))" );
94+ ret .add ("\t \t \t seuratObj <- NULL" );
95+ ret .add ("\t \t } else {" );
96+ ret .add ("\t \t \t seuratObj <- subset(seuratObj, cells = cells)" );
97+ ret .add ("\t \t \t print(paste0('Cells after subset: ', ncol(seuratObj)))" );
98+ ret .add ("\t \t \t newSeuratObjects[[datasetId]] <- seuratObj" );
99+ ret .add ("\t \t }" );
100+ ret .add ("}" );
99101 }
100102 }
101103 else
0 commit comments