Geom bar postive and negative values in a flipped plot
0
0
Entering edit mode
13 months ago
luzglongoria ▴ 50

Hi there,

I'm trying to do a plot like this one: What I would like

But I am not able with my command:

ggplot(Heatmap_Go, aes(x = Molecular_function,y=-log10(padj), fill=Cond)) +
  theme_classic() +
  geom_bar(stat = "identity", position = "dodge",color="black") +
  geom_vline(xintercept = 0,colour = "grey90") +
  facet_grid(~ Group, switch = "x", scales = "free_x", space = "free_x") +
  coord_flip() +
  scale_fill_manual(values=c("#ffffff", "#000000")) +
  xlab("Molecular function")

With this command I get this: What I get

My data set look like this:

Molecular_function  padj    Moment  Group   Cond
nucleic acid binding    0.000389804 d   Down regulated  Signi
RNA binding 0.003802644 d   Down regulated  Signi
iron ion binding    0.000460617 d   Up regulated    Signi
heme binding    0.000953612 d   Up regulated    Signi
tetrapyrrole binding    0.001045832 d   Up regulated    Signi
oxidoreductase activity, acting on paired donors, with incorporation or reduction of molecular oxygen   0.006341203 d   Up regulated    Signi
ATP-dependent microtubule motor activity, minus-end-directed    0.007685289 d   Up regulated    Signi
monooxygenase activity  0.030799501 d   Up regulated    Signi
transporter activity    0.041251611 d   Up regulated    Signi
phosphoenolpyruvate carboxykinase activity  0.049891016 d   Up regulated    Signi
phosphoenolpyruvate carboxykinase (GTP) activity    0.049891016 d   Up regulated    Signi
iron ion binding    0.58    d   Down regulated  No_Signi
heme binding    0.41    d   Down regulated  No_Signi
tetrapyrrole binding    0.21    d   Down regulated  No_Signi
oxidoreductase activity, acting on paired donors, with incorporation or reduction of molecular oxygen   0.87    d   Down regulated  No_Signi
ATP-dependent microtubule motor activity, minus-end-directed    0.25    d   Down regulated  No_Signi
monooxygenase activity  0.58    d   Down regulated  No_Signi
transporter activity    0.26    d   Down regulated  No_Signi
phosphoenolpyruvate carboxykinase activity  0.14    d   Down regulated  No_Signi
phosphoenolpyruvate carboxykinase (GTP) activity    0.89    d   Down regulated  No_Signi
nucleic acid binding    0.398039992 d   Up regulated    No_Signi
RNA binding 0.802643739 d   Up regulated    No_Signi

I don't know how to flip the "Down regulated" axis. I just want values starting from the same point : from zero to right and from zero to left.

Any help is more than welcome.

Thank you in advance.

flip_coord ggplot geom_bar • 552 views
ADD COMMENT
2
Entering edit mode

Can you transform your data so your downregulated terms have negative -log10(padj) values?

ADD REPLY
2
Entering edit mode

Maybe not the best way, but an easy one is to use negative values for padj for the down regulated group and afterwards remove the negative values manually or annotate the x axis accordingly. Hope it helps.

ggplot(Heatmap_Go, aes(x = Molecular_function,y=ifelse(Group == "Up regulated", -log10(padj), log10(padj)))) +
  theme_classic() +
  geom_bar(stat = "identity", position = "dodge",color="black") +
  geom_vline(xintercept = 0,colour = "grey90") +
  facet_grid(~ Group, switch = "x", scales = "free_x", space = "free_x",) +
  coord_flip() +
  xlab("Molecular function") + ylab("log10(padj) <----> -log10(padj)")
ADD REPLY
0
Entering edit mode

Thank you so much. It perfectly worked !

ADD REPLY

Login before adding your answer.

Traffic: 2212 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6