3  Nebulosa plots

This plot comes straight from the Nebulosa package. For more information, here is their vignette. In short, it computes a “density” of whether the surrounding cells (in the UMAP embedding) also express the variable that you provide to the function, same variables that one could feed to Seurat::FeaturePlot(). This is how their default plot looks like:

3.1 Basic usage

p <- Nebulosa::plot_density(sample,
                            features = "CD14")
p

Nebulosa plot.

This way, not only we do know which clusters are enriched in CD14, we also know the regions of it with the highest density of cells expressing it. Minor modifications, on the line of the rest of plots, are applied in SCpubr:

p <- SCpubr::do_NebulosaPlot(sample = sample, 
                             features = "CD14")
p

Nebulosa plot with SCpubr.

Then, this type visualization becomes a natural partner to `Seurat::FeaturePlot()’ as not only we are able to visualize the expression of a variable, but also query the density of the surrounding cells. Here is an example:

p1 <- SCpubr::do_FeaturePlot(sample = sample, 
                             features = "CD14") 

p2 <- SCpubr::do_NebulosaPlot(sample = sample, 
                              features = "CD14")
p <- p1 | p2
p

Comparison of a Nebulosa vs a FeaturePlot.

Nebulosa package also offers the option to query multiple features at the same time:

p <- SCpubr::do_NebulosaPlot(sample, 
                             features = c("CD14", "CD8A"))
p

Nebulosa plot with multiple features.

3.2 Compute joint densities

But, more intriguingly, it can also compute the joint density of the features. This is achieved by parsing joint = TRUE.

p <- SCpubr::do_NebulosaPlot(sample = sample, 
                             features = c("CD14", "CD8A"), 
                             joint = TRUE)
p 

Plot joint densities.

If we were interested in retrieving only the joint density plot, we can accomplish it with return_only_joint parameter. Please note that, since this will return only one plot, if wanted to modify the plot title, use plot.title instead:

features.use <- c("CD14", "CD8A")

p <- SCpubr::do_NebulosaPlot(sample = sample, 
                             features = c("CD14", "CD8A"), 
                             joint = TRUE, 
                             return_only_joint = TRUE,
                             plot.title = "Joint density CD14+-CD8A+")

p

Plot joint densities and return only the last plot.