This is a test version of Biostars. For the public version, visit https://www.biostars.org.
adjusting parameters in ViolinPlot did not work

Dear All,

I am using stack violin plot to visualize expression of genes in my single cell, but having hard time modifying the angle (circle in red, I would like to have it straight) and size of the markers in the plot (circle in blue, I would like to reduce the font size). Anyone could have a look at my script. I have tried to adjust all these parameters, but none of them work.

features <- c("CD3E","CD3D", "CD4", "CD8A", "FOXP3", "CCR7", "CD69", "CXCR3", "CXCR5", "CXCR6", "CCR4", "CCR6", "KLRB1", "IL2RA", "IL7R", "KLRG1", "CXCL13", "TOX", "LAG3", "CTLA4", "PDCD1", "HAVCR2", "TIGIT", "EOMES", "CX3CR1", "MKI67", "TRGV9", 
              "TRGV2", "FCGR3A", "NCAM1")

#plot
VlnPlot(all.annotated.subsets, features = features, stack = TRUE, flip = TRUE, adjust = 0.5) &
  theme(legend.position = "none",
        axis.text.x =  element_text(size = 8, angle = 90),
        axis.title = element_blank(),
        axis.text.y = element_text(angle = 90, hjust = 1), 
        strip.text.y.left = element_text(angle = 90))  + 
  RotatedAxis()

enter image description here

single-cell

VlnPlot() produces a ggplot object, correct? Use +, not & to add your layers.

Hi Ram, thank for your response! + or & did not work at all

"did not work at all" is insufficient feedback. Did you experiment with it, making sure the + ... was affecting the output at all or did you just replace the & with +, run the code and not see any change?

VlnPlot() with multiple features will produce patchworked ggplot object - meaning there are multiple plots in a single returned visualization. Adding additional layers with the + as previously mentioned will only modify the last plot in the series of plots.

You could try:

  1. setting VlnPlot(..., combine = FALSE )
  2. Loop through the list of plots returned and modify them using +
  3. Combining them with the patchwork package

Alternatively, if I were you, I'd ggsave() the plot as a pdf or svg and just manually edit the plot. It would take < 1 min.

Reproducibility is key and when the function is giving you a ggplot object, manipulating it manually is just a bad approach.

Adjusting the orientation of an axis label has no effect on reproducibility. I don't think your comment adds to the discussion.

I've edited my comment and removed the irrelevant part. If OP were to change parameters and generate a slightly different plot, they'd have to manually do the edits again. Plotting is usually an iterative process and I think as long as an automatable way exists to make the required change, using a manual tool to do it is just an unnecessary burden.

0 answers

No answers yet.

Log in to answer this question.