hbctraining / scRNA-seq_online

https://hbctraining.github.io/scRNA-seq_online/.
493 stars 175 forks source link

08 clustering qc errors #109

Closed hwick closed 10 months ago

hwick commented 10 months ago

Note, I am using my own data set and getting these issues:

Following errors for the following code:

> # Plotting a UMAP plot for each of the PCs
> map(paste0("PC_", 1:16), function(pc){
+         ggplot(pc_data, 
+                aes(UMAP_1, UMAP_2)) +
+                 geom_point(aes_string(color=pc), 
+                            alpha = 0.7) +
+                 scale_color_gradient(guide = FALSE, 
+                                      low = "grey90", 
+                                      high = "blue")  +
+                 geom_text(data=umap_label, 
+                           aes(label=ident, x, y)) +
+                 ggtitle(pc)
+ }) %>% 
+         plot_grid(plotlist = .)
Don't know how to automatically pick scale for object of type <function>. Defaulting to continuous.
Error in `geom_text()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 2nd layer.
Caused by error in `compute_aesthetics()`:
! Aesthetics are not valid data columns.
✖ The following aesthetics are invalid:
✖ `label = ident`
ℹ Did you mistype the name of a data column or forget to add `after_stat()`?
Run `rlang::last_trace()` to see where the error occurred.

When commenting geom_text out, get the following error, but it will create a plot if run again. The plot will have no legends or cluster labels though:

> # Plotting a UMAP plot for each of the PCs
> map(paste0("PC_", 1:16), function(pc){
+         ggplot(pc_data, 
+                aes(UMAP_1, UMAP_2)) +
+                 geom_point(aes_string(color=pc), 
+                            alpha = 0.7) +
+                 scale_color_gradient(guide = FALSE, 
+                                      low = "grey90", 
+                                      high = "blue")  +
+                 #geom_text(data=umap_label, 
+                 #          aes(label=ident, x, y)) +
+                 ggtitle(pc)
+ }) %>% 
+         plot_grid(plotlist = .)
Warning message:
The `guide` argument in `scale_*()` cannot be `FALSE`. This was deprecated in ggplot2 3.3.4.
ℹ Please use "none" instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 

Issue appears to be with the umap_label object, which only contains one line:

> umap_label <- FetchData(seurat_integrated, 
+                         vars = c("ident", "UMAP_1", "UMAP_2"))  %>%
+   group_by(ident) %>%
+   summarise(x=mean(UMAP_1), y=mean(UMAP_2))
> umap_label
              x             y
1 -5.274869e-14 -5.497192e-14
mistrm82 commented 10 months ago

using lower case letters solves the problem. Update the Seurat object to a newer version and we update the code in the lesson accordingly

mistrm82 commented 10 months ago

added a note to the lesson about using your own object. If it looks good we can close this issue