carmonalab / ProjecTILs

Interpretation of cell states using reference single-cell maps
GNU General Public License v3.0
231 stars 27 forks source link

Add option to plot.states.radar for unknown cell types? #61

Closed mschubert closed 5 months ago

mschubert commented 9 months ago

First of all, thank you for the tool, it's great to see better approaches than just labeling the (somewhat arbitrary) clusters! :+1:

I think it would be nice to get a bit more information from query cells that can not be confidently assigned in the reference.

Would you be willing to add an option in plot.states.radar (and maybe other plots) to include the un-assigned cells?

The easiest option would be:

diff --git a/R/main.R b/R/main.R
index bed9051..1574719 100644
--- a/R/main.R
+++ b/R/main.R
@@ -641,7 +641,7 @@ plot.states.radar = function(ref, query=NULL,

   labels <- ref[[labels.col]][,1]
-  states_all <- levels(factor(labels))
+  states_all <- levels(as.factor(labels))
   nstates <- length(states_all)

   if (!is.null(query)) {

and then add an NA factor level in the reference, but then the gene labels do not show for this panel.

mass-a commented 8 months ago

Hello Michael, thanks for the suggestion!

This feature is now implemented in the 'dev' version of ProjecTILs, available from:

remotes::install_github("carmonalab/ProjecTILs", ref="dev")

If there are any cells annotated as 'NA' in a query dataset, the plot.states.radar() function will display an additional 'Unknown' category showing the average expression profile of these cells. As with any other cell type, the profile will be plotted if there is a min number of cells (controlled by the min.cells parameter).