2
$\begingroup$

I have a Seurat object and plotted the Dimplot for UMAP visualization for 2 variables, as shown in the image below.

enter image description here

Now, the problem is that I want the group by variables such as Non-responder and Responder and anti-CLTA4, anti-CLTA4+PD1, anti-PD1 on the top of the UMAP plot and not on the right side. My desired output would look like the following.

enter image description here

The timely help is highly appreciated, many thanks.

$\endgroup$
2
  • $\begingroup$ If you plan to export the graph anyway, the easiest way could be to edit it with a vector graphics program. The other option is to save the ggplot object returned by Dimplot() and modify it to suit your needs. $\endgroup$
    – Cloudberry
    Jan 5, 2023 at 15:48
  • $\begingroup$ Could you please provide an example of Seurat DimPlot() to ggplot ? @Cloudberry $\endgroup$
    – cst
    Jan 6, 2023 at 4:09

1 Answer 1

3
$\begingroup$

DimPlot returns a ggplot object, so ggplot functions can be applied to it. You can change the legend position like this:

DimPlot(data) + theme(legend.position = "top")
# or
DimPlot(data) + theme(legend.position = c(.1, .9))
$\endgroup$
1
  • $\begingroup$ Thank you so much, problem solved. I was trying to solve it from DimPlot() method. $\endgroup$
    – cst
    Jan 6, 2023 at 17:15

Your Answer

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

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