Search code examples
rggplot2seurat

ggplot2 overlapping causing issues with ridgeplot


I am creating ridge plots from the Seurat package. This packages utilizes ggplot2. All of my ridge plots look great except for one. I am trying to manually adjust the bandwidth to make this plot look similar to the others but I wind up with two ridge plots overlapping one another.

I can't post an example of the data as the data is a Seurat object and not a standard df. Apologies in advance!

RidgePlot(object = sc1, features = "FGF2+Heparin") produces: Ridge plot 1

When I attempt to change the bandwidth using + geom_density_ridges(scale = 2) I get this: enter image description here

I am trying to get it to look more similar to this: enter image description here

Thank you for your help!

EDIT 02/23/22

I have made good progress but I am still running into an issue. Ideally, ggplot2 would completely overwrite the previous points.


   RidgePlot(sc1, features = "FGF2+Heparin") + geom_density_ridges2(scale = 4, bandwidth = 2) + theme(legend.position = "none") +  xlab("Concentration [AU]") + ylab("Cluster")  +
     scale_fill_manual(
       values = c("#FF3500A0", "#CC9933FF", "#33C04CCF", "#39CCCAAF", "#0000FFA0", "#FF88EEE9")
     )

enter image description here


Solution

  • I indirectly solved the issue I was having by changing the size of the bandwidth and the colors of the plots.

    I made some colors translucent so that you can see the peaks behind them. Example:

    This code applies to a single plot. p12 <- RidgePlot(sc1, features = "Y-27632") + geom_density_ridges2(scale = 4, bandwidth = 2.05) + theme(legend.position = "none") + xlab("Concentration [uM]") + ylab("Cluster") + scale_fill_manual( values = c("#FF3500A0", "#CC9933FF", "#33C04CCF", "#66CCFF", "#0000FF", "#FF66CC") )