Skip to content

Commit 8f03a13

Browse files
committed
Add error handling
1 parent 6474554 commit 8f03a13

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

singlecell/resources/chunks/FeaturePlots.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@ for (datasetId in names(seuratObjects)) {
77
next
88
}
99

10-
P1 <- Seurat::FeaturePlot(seuratObj, features = c(field), reduction = 'tsne', min.cutoff = 'q05', max.cutoff = 'q95')
11-
P2 <- Seurat::FeaturePlot(seuratObj, features = c(field), reduction = 'umap', min.cutoff = 'q05', max.cutoff = 'q95')
10+
tryCatch({
11+
P1 <- Seurat::FeaturePlot(seuratObj, features = c(field), reduction = 'tsne', min.cutoff = 'q05', max.cutoff = 'q95')
12+
P2 <- Seurat::FeaturePlot(seuratObj, features = c(field), reduction = 'umap', min.cutoff = 'q05', max.cutoff = 'q95')
1213

13-
if ('wnn.umap' %in% names(seuratObj@reductions)) {
14-
P3 <- Seurat::FeaturePlot(seuratObj, features = c(field), reduction = 'wnn.umap', min.cutoff = 'q05', max.cutoff = 'q95')
15-
P1 <- P1 | P2 | P3
16-
} else {
17-
P1 <- P1 | P2
18-
}
14+
if ('wnn.umap' %in% names(seuratObj@reductions)) {
15+
P3 <- Seurat::FeaturePlot(seuratObj, features = c(field), reduction = 'wnn.umap', min.cutoff = 'q05', max.cutoff = 'q95')
16+
P1 <- P1 | P2 | P3
17+
} else {
18+
P1 <- P1 | P2
19+
}
1920

20-
P1 <- P1 + patchwork::plot_annotation(title = field) + patchwork::plot_layout(guides = "collect")
21+
P1 <- P1 + patchwork::plot_annotation(title = field) + patchwork::plot_layout(guides = "collect")
2122

22-
print(P1)
23+
print(P1)
24+
}, error = function(e){
25+
print(paste0('Error running FeaturePlots for: ', datasetId))
26+
print(conditionMessage(e))
27+
traceback()
28+
})
2329
}
2430

2531
# Cleanup

0 commit comments

Comments
 (0)