DAseq
DAseq copied to clipboard
DAregion fails with confusing error message if no cells are DA
Hi, Thanks a lot for the tool! However, I found that the following fails
library(DAseq)
labels_res <- X.label.info[X.label.info$condition == "R", "label"][c(1, 3)]
labels_nonres <- X.label.info[X.label.info$condition == "NR", "label"][c(1, 3)]
id <- X.label.melanoma %in% c(labels_res, labels_nonres)
da_cells <- getDAcells(
X = X.melanoma[id, ],
cell.labels = X.label.melanoma[id],
labels.1 = labels_res,
labels.2 = labels_nonres,
do.plot = F
)
da_cells$da.up <- da_cells$da.down <- integer()
da_regions <- getDAregion(
X = X.melanoma[id, ],
da.cells = da_cells,
cell.labels = X.label.melanoma[id],
labels.1 = labels_res,
labels.2 = labels_nonres
)
with error message Error in [<-(tmp, ii, , value = getDAscore(cell.labels = cell.labels, : subscript out of bounds. It was quite hard to troubleshoot what is going on simulations.
Although I understand you would want users to check the output of getDAcells, it might be nice to just return a warning and an object with no da regions or something more informative.
Best
Some follow up. Replacing the line da_cells$da.up <- da_cells$da.down <- integer() with either da_cells$da.up <-integer() or - da_cells$da.down <- integer() causes the same failure.
Replacing it with da_cells$da.up <- da_cells$da.up[1] causes a different failure
Error in CreateAssayObject(counts = counts, min.cells = min.cells, min.features = min.features) :
No feature names (rownames) names present in the input matrix
traceback()
5: stop("No feature names (rownames) names present in the input matrix")
4: CreateAssayObject(counts = counts, min.cells = min.cells, min.features = min.features)
3: CreateSeuratObject.default(counts = t(X[da.cells$da.up, ]))
2: CreateSeuratObject(counts = t(X[da.cells$da.up, ]))
1: getDAregion(X = X.melanoma[id, ], da.cells = da_cells, cell.labels = X.label.melanoma[id],
labels.1 = labels_res, labels.2 = labels_nonres)
Hi @HectorRDB, thank you so much for your interest in DAseq. Your tests are highly appreciated and I will update the code accordingly. Best, Jun
Hi @JunZhao1990
Although this is an old thread and you addressed Hector's comment, I'd like to revisit the issue of running getDAregion() when there turn out to be no DA regions.
I am running getDAregion() in a loop over several contrasts. My issue is that getDAregion() fails with an "Error: Must request at least one colour from a hue palette." when no DA regions are found. I'd like to catch that error so that the loop can continue to run over the remaining contrasts.
I see two ways to address this:
- inspect the results of getDAcells() to prevent the error; but I don't know which parameters to inspect to reliably catch situations that would lead to the getDAregion() error
- run getDAregion() once with do.plot = F, inspect the results (e.g. for "are all da.region.labels 0?"), and then run getDAregion() a second time with do.plot = T only if at least one DA region was found (and in that case also draw and save the plot)
Would you have a suggestion for how to handle this? Especially, how to determine from the getDAcells() results whether getDAregion() will fail or not?
Thank you for any input - and for the DAseq package in the first place!
Best regards,
Anton