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

Issue in degbar_data : scale_x_discrete does not respect the true order of datasets #62

Open
BastiDucreux opened this issue Jul 7, 2023 · 0 comments

Comments

@BastiDucreux
Copy link

I dug into the functions and found an error in the draw_degbar function from the package :

draw_degbar <- function(degbar_data) {
    ggplot(degbar_data, aes(dataset)) +
        geom_bar(aes(fill = Regulation)) +
        theme_classic() +
        theme(panel.border= element_blank()) +
        theme(axis.text.x = element_text(angle=90, vjust = 0.5)) +
        theme(axis.line.x = element_line(color="black", size = 0.6, 
                     lineend = "square"),
              axis.line.y = element_line(color="black", size = 0.6, 
                     lineend = "square")) +
        guides(colour = guide_colorbar()) +
        labs(x = "Datasets",
             y = "Number of genes") +
        scale_fill_manual(values=c("#E41A1C", "grey", "#377EB8" )) +
        scale_x_discrete(labels=substr(unique(degbar_data[['dataset']]), 0, 30))
}

The scale_x_discrete function does not respect the true order of bars which is initially set by alphabetical order, whereas the function renames the x graduations with a totally different order : this is FALSE.

Test example :

> degbar_data
       dataset      Regulation
1            b   a.Upregulated
2            b c.Downregulated
3            b   a.Upregulated
4            b   a.Upregulated
5            b c.Downregulated
6            b   a.Upregulated
7            b   a.Upregulated
8            b   a.Upregulated
9            b   a.Upregulated
10           b   a.Upregulated
50001        c   b.Unperturbed
50002        c   b.Unperturbed
50003        c   b.Unperturbed
50004        c   b.Unperturbed
50005        c   b.Unperturbed
50006        c   b.Unperturbed
50007        c   b.Unperturbed
50008        c   b.Unperturbed
50009        c   b.Unperturbed
50010        c   b.Unperturbed
100001       a   b.Unperturbed
100002       a   b.Unperturbed
100003       a   b.Unperturbed
100004       a   b.Unperturbed
100005       a   b.Unperturbed
100006       a   b.Unperturbed
100007       a   b.Unperturbed
100008       a   b.Unperturbed
100009       a   b.Unperturbed
100010       a   b.Unperturbed
image

I suggest to remove the scale_x_discrete function.

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

1 participant