Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control border thickness of Stacked_VlnPlot #32

Closed
massonix opened this issue Apr 11, 2022 · 9 comments
Closed

control border thickness of Stacked_VlnPlot #32

massonix opened this issue Apr 11, 2022 · 9 comments
Assignees
Labels
enhancement Enhance existing function/feature Not Working As Intended This doesn't seem right

Comments

@massonix
Copy link

Hi @samuel-marsh! Thanks for this useful package.

Is there anyway to change the border thickness of Stacked_VlnPlot? When I save it with ggsave and arrange it into a figure it looks incredibly thick:

image

Thanks in advance for looking into this !

@samuel-marsh
Copy link
Owner

Hi @massonix

Thanks so much!! You’re just in time of me trying to squash bunch of bugs for next master release. I’ll look into this. In your experience does number of stacks (features) and/or groups (idents) effect line thickness? How about size of output when using ggsave?

Thanks,
Sam

@massonix
Copy link
Author

I cannot say much about the number of stacks or groups because it's the first time I use it :)

In terms of ggsave, yes, if I increase the width then it's less thick. However, I need to narrow it because I have limited space in the figure I'm creating.

Thanks Sam!

@samuel-marsh samuel-marsh self-assigned this Apr 11, 2022
@samuel-marsh samuel-marsh added enhancement Enhance existing function/feature Not Working As Intended This doesn't seem right labels Apr 11, 2022
@samuel-marsh
Copy link
Owner

got it! I'll take look and see what I can find!

@samuel-marsh
Copy link
Owner

@massonix been looking into couple things but also just wanted to get some more info on your figure assembly process. After saving the vlnplot in this case what packages/how are you assembling things into figures? Trying to think if maybe there is secondary method to fix the issue in addition to possible primary solution.

@massonix
Copy link
Author

Hey Sam,

Sorry for the delayed response, I was on vacation. That's the code I'm using:

vln1 <- Stacked_VlnPlot(
  seurat_object = seurat_rna,
  features = goi_rna[1:(floor(length(goi_rna) / 2))],
  x_lab_rotate = TRUE,
  colors_use = colors_rna,
  plot_spacing = 0.05
) &
  theme(
    axis.text.x = element_blank(),
    axis.title.y = element_text(size = 6),
    axis.text.y = element_text(size = 5))
vln2 <- Stacked_VlnPlot(
  seurat_object = seurat_rna,
  features = goi_rna[((floor(length(goi_rna) / 2)) + 1):length(goi_rna)],
  x_lab_rotate = TRUE,
  colors_use = colors_rna,
  plot_spacing = 0.05
)  &
  theme(
    axis.text.x = element_blank(),
    axis.title.y = element_text(size = 6),
    axis.text.y = element_text(size = 5))
vlns <- vln1 | vln2
ggsave(
  filename = glue("{path_to_wd}/results/paper/figures/figure_3_cytotoxic_vln_markers.pdf"),
  plot = vlns,
  height = 15,
  width = 11.5,
  units = "cm"
)

Later, I import it to inkscape and I merge it with other panels, add labels etc.

Hope that helps! Thanks again for looking into it

Ramon

@samuel-marsh
Copy link
Owner

I think this might be what we are looking for!! Will check it out and if so then when it gets pushed to full ggplot release I will update function.

https://twitter.com/thomasp85/status/1536996957616492549?s=20&t=1_ItFXaGT14A3YfpOFLzSg

@massonix
Copy link
Author

Nice! Thanks Sam :)

@samuel-marsh
Copy link
Owner

ok just popping back in to say that this is still coming. Working on dev branch of ggplot2 (Hadley Wickham posted recently its targeted for end of Oct release) and I can start to get things closer and hope to have fully complete solution sometime soon. Right

now having to hack linewidth param manually into the patchwork and also need to do it iteratively over all the features. But here is proof of principle:
test

Will work on integrated solution to change all linewidths within the plot. But for now happy that can control the geom_violin thickness finally.

@samuel-marsh
Copy link
Owner

Hi @massonix

Ok sorry again for such a long wait on this but fix is now live in dev branch (v1.0.2.9020). There is new parameter called vln_linewidth which takes numeric input and adjusts the outline line thickness of the violins thanks to new ggplot2 updates and linewidth parameter.

The axis lines can then also be easily modified using standard ggplot2/patchwork notation and new linewidth param as well so I've left that to end user because it's straightforward.

p1 <- Stacked_VlnPlot(pbmc, c("FOS", "CD4", "CD8A"))
p1 & theme(axis.line=element_line(linewidth=2))

Hope this helps!! :)
Best,
Sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhance existing function/feature Not Working As Intended This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants