adjusting parameters in ViolinPlot did not work
0
0
Entering edit mode
10 weeks ago
synat.keam ▴ 100

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 • 539 views
ADD COMMENT
2
Entering edit mode

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.

ADD REPLY
2
Entering edit mode

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

ADD REPLY
2
Entering edit mode

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

ADD REPLY
2
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

"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?

ADD REPLY

Login before adding your answer.

Traffic: 2611 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6