neurorestore / Augur

Cell type prioritization in single-cell data
MIT License
94 stars 10 forks source link

plot_umap error and problem with mutate() column metrics #11

Closed hwenxi closed 3 years ago

hwenxi commented 3 years ago

Hi, Thank you in advance for your help and for providing this great tool. While trying to plot the AUC over the UMAP, I ran into the following error.

Error in `$<-.data.frame`(`*tmp*`, "auc", value = numeric(0)) : 
replacement has 0 rows, data has 48804

I am using a seurat object that has a umap dimensional reduction. After skimming the plot_umap.R file I cannot pinpoint where this error is occuring.

Furthermore, I am not sure if this is relevant or a separate error but I am getting 50+ occurrences of this error when I run the calculate auc. But I am still presented with AUC scores for each of my cell types at the end.

Problem with `mutate()` column `metrics`.
i `metrics = pred %>% map(metric_fun)`.
i While computing binary `precision()`, no predicted events were detected (i.e. `true_positive + false_positive = 0`). 
Precision is undefined in this case, and `NA` will be returned.
Note that 6 true event(s) actually occured for the problematic event level, 'hibd 24h'

Please let me know if you could point me in the right direction for fixing these issues! Thanks.

jordansquair commented 3 years ago

Having trouble reproducing this. Can you provide a bit more info on what you are passing into plot_umap? Are you passing in the entire augur results (i.e., including the y, cell_types, results, etc slots) or just the AUC data frame?

To help reproduce the error. Can you download the Kang2018.rds from here: https://zenodo.org/record/4772064#.YOtN7BNKh24

I've just done the following and I am not getting any issues:

library(Seurat)
library(tidyverse)
library(Augur)

# load in the Kang dataset
sc = readRDS("data/rnaseq/seurat/Kang2018.rds") %>%
  NormalizeData() %>%
  FindVariableFeatures() %>%
  ScaleData() %>%
  RunPCA() %>%
  RunUMAP(dims = 1:10)

# run augur
augur = calculate_auc(sc)

# plot
plot_umap(augur, sc)

Thanks for the note about the warning. This is just for the calculation of precision so not to worry, we will suppress it.

hwenxi commented 3 years ago

Hi, I discovered my error was naming the cell annotations column differently and not specifying the new column name in plot_umap. I am now running into a ggplot error:

> plot_umap(tfaug, twofour, cell_type_col = "reclustered")
Error: Breaks and labels are different lengths
Run `rlang::last_error()` to see where the error occurred.
In addition: Warning message:
`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 

Do you have any idea what could be causing this? Thanks for all the help!

jordansquair commented 3 years ago

I am still not quite able to reproduce your error. Are you sure you do not have some NAs in your cell type vector?

hwenxi commented 3 years ago

I'm not sure how to explain this, but I just reran everything exactly the same as I have before and it worked? I am pretty sure I did not change anything and I have not reset my environment since first posting this problem. Hopefully this bug doesn't appear again for me or anyone else...

Thanks Jordan for all the help!