2
$\begingroup$

Using Seurat's VlnPlot, how can I remove the black outline around the violin plot?

For example, how can I change from the following graph with a (black) outline:

    VlnPlot(ilc2,
        features = "gene",
        split.by = "group", 
        cols = c("#198BFD", "#EC6464"),
        pt.size = 0) +
  geom_boxplot(width = 0.1) + theme(aspect.ratio = 1)

enter image description here

To a graph like the one below, which does not have an outline around the violin plot:

enter image description here

$\endgroup$
0

3 Answers 3

0
$\begingroup$

wish there was a more subtle answer, but this works. Place this previous to your VlnPlot

update_geom_defaults("violin", aes(linewidth = 0))
$\endgroup$
0
$\begingroup$
vln_df = data.frame(gene = ilc2_bs[["RNA"]]@data[ "gene", ],
                    group = ilc2$group)

ggplot(vln_df, aes(x = group, 
                   y = gene, fill = group)) + 
  geom_violin(aes(fill = group, 
                  color = gene),
              color = NA) +
  scale_fill_manual(values = c("#619CFF", "#F8766D")) +
  geom_boxplot(aes(fill = group),
               width = 0.1) + theme(aspect.ratio = 1)
$\endgroup$
-1
$\begingroup$

I'd much prefer this as a comment, but anyway ...

 VlnPlot(ilc2,
        features = "gene",
        split.by = "group", 
        cols = c("#198BFD", "#EC6464"),
        color = NA, #  <--- HERE
        pt.size = 0) +
  geom_boxplot(width = 0.1) + theme(aspect.ratio = 1)

What I'm guessing is seurat is leveraging ggplot2 and thats how its done in ggplot2

$\endgroup$
3
  • $\begingroup$ Error in VlnPlot(ilc2, features = "gene", split.by = "group", cols = c("#198BFD", : unused argument (color = NA) gives an error $\endgroup$
    – Charles
    Sep 19, 2022 at 20:02
  • $\begingroup$ Okay it was just a guess. $\endgroup$
    – M__
    Sep 19, 2022 at 22:06
  • $\begingroup$ I added one possible way to do it. $\endgroup$
    – Charles
    Sep 20, 2022 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.