Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAregion fails with confusing error message if no cells are DA #4

Open
HectorRDB opened this issue Jan 26, 2021 · 3 comments
Open

DAregion fails with confusing error message if no cells are DA #4

HectorRDB opened this issue Jan 26, 2021 · 3 comments

Comments

@HectorRDB
Copy link

HectorRDB commented Jan 26, 2021

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

@HectorRDB
Copy link
Author

HectorRDB commented Jan 26, 2021

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)

@JunZhao1990
Copy link
Member

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

@ACMGlueck
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants