FeaturePlot on a KDE Plot/density plot
0
0
Entering edit mode
19 months ago
fouerghi20 ▴ 60

I created a KDE plot (density plot) using the following code:

contplus <- data.frame(scADAR$tsne@cell.embeddings) tSNE_1 <- scADAR$tsne@cell.embeddings[,1]

# Initialize arrays for data subsets for each condition and for plots
plotData <- list()
modGalaxyPlot <- list()

# Take each subset of data and generate a plot

# Use grep to subset the data
plotData[[1]] <- contplus[grepl(as.numeric(1), rownames(contplus)),]

# Generate galaxy plot for each condition
modGalaxyPlot[[1]] <- ggplot(plotData[[1]], aes(tSNE_1, tSNE_2)) +
stat_density_2d(aes(fill = ..density..), geom = 'raster', contour = FALSE) +
scale_fill_viridis(option = "magma") +
coord_cartesian(expand = FALSE, xlim = c(min(tSNE_1), max(tSNE_1)), ylim = c(min(tSNE_2),max(tSNE_2))) +
geom_point(shape = '.', col = 'white')

# to visualize one of the two plots
FeaturePlot(modGalaxyPlot[[1]])


I was wondering if it would be possible to highlight a density plot with certain genes. I basically want to do what FeaturePlot does but on a KDE plot and I am not sure how to adapt my code to do that.

single cell seurat r RNA-Seq • 505 views