Entering edit mode
3.9 years ago
fouerghi20
▴
80
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]
tSNE_2 <- scADAR$tsne@cell.embeddings[,2]
# 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.