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

how can I joint ggsankey and a dotplot? #25

Open
Sagityq opened this issue Jul 16, 2022 · 2 comments
Open

how can I joint ggsankey and a dotplot? #25

Sagityq opened this issue Jul 16, 2022 · 2 comments

Comments

@Sagityq
Copy link

Sagityq commented Jul 16, 2022

Hi:

I put it together myself. The coordinates don't match:

image

This is what I'm looking for:

image

my code:

library(ggplot2)
library(ggsankey)
library(dplyr)
pl <- ggplot(dat3, aes(x = x, 
                       next_x = next_x,
                       node = node, 
                       next_node = next_node,
                       fill = factor(node),
                       label = node2
                       )) +
  geom_sankey(flow.alpha = 0.5, node.color = "black") +
  geom_sankey_label(size = 6, color = "black", fill = "white", hjust = 1, family = "Times") +
  scale_fill_viridis_d(option = "magma") +
  theme_sankey(base_size = 16) +
  scale_x_discrete(expand = c(0.01,0.1)) +
  theme(legend.position = "none",
        axis.title = element_blank(),
        axis.text = element_blank())
pl

library(clusterProfiler)
kk_dot <- dotplot(kk, showCategory=10) +
  theme(text = element_text(family = "Times"),
        axis.text.y = element_text(size = 12, face = "bold"),
        axis.text.x = element_text(size = 10, face = "bold"),
        axis.title.x = element_text(size = 14, face = "bold"),
        legend.title = element_text(face = "bold"))
kk_dot
kk_dot2 <- kk_dot + theme(axis.text.y = element_blank(),
                          axis.ticks.y = element_blank())
library(patchwork)
design <- c("
            AAAA#
            AAAAB
            AAAAB
            AAAAB
            AAAA#
            ")
all_p <- pl + kk_dot2 + theme(text = element_text(size = 20), 
                              axis.title.x = element_text(size = 25),
                              axis.text.x = element_text(size = 20)) +
  plot_layout(design = design)
all_p

Looking forward to your reply!

@Sagityq
Copy link
Author

Sagityq commented Jul 16, 2022

This is my plot data:

data.zip

@microbioin
Copy link

Actually, the reference figure was plotted with our SRplot online website, written in pysankey2 and matplotlib. We set the height of the right sankey the same to the height of right dot plot. Hope this can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants