Skip to content

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

@BastiDucreux

Description

@BastiDucreux

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions