0

I am trying to make a barplot (using ggplot) with qRT-PCR values for 5 genes (SHP....PHB) side by side on the x axis comparing normalized fold induction on the y axis (for example, the most induced gene is SHP with normalized fold induction of ~30, then NGA1, etc). I have struggled a lot and cannot make this figure in R. Could anyone please give me a hand with this? Many thanks.

Rep |SHP |NGA1 |PAN |TUB |PHB

Rep1 |29.77|4.55 |3.23|1.28|0.06|

Rep2 |30.37|3.43 |2.07 |0.81|4.93

1
  • 1
    Please also share the code you used. If not, this question would be closed. Commented Nov 22, 2014 at 1:12

1 Answer 1

2

Well I think this is what you want:

library(ggplot2) #load library

genes<-factor(c('SHP', 'NGA1', 'PAN', 'TUB', 'PHB')) 
values1<-c(29.77,4.55,3.23,1.28,0.06)
values2<-c(30.37,3.43,2.07,0.81,4.93)
df<- data.frame(genes,values1,values2)  #put your data in dataframe

ggplot(data=df,aes(x=genes,y=values1)) + geom_bar(stat='identity') +  #plot with ggplot2
  scale_x_discrete(limits=df$genes[order(levels(df$genes))])          #order your data descending

I plotted the data having the names on the x axis and values 1 on the y axis. you can use the above code as is for values 2 if you want.

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Just because you are very new to the site I want to tell you a couple of things about posting a question. First of all you need to create a reproducible example of your problem so that people can help you out and you need to provide sample of your data too. It is also encouraged to provide code of the things you have done so far otherwise it looks like you want someone else to do the job for you. Finally, since you are new when a reply answers your question (only then) you need to mark it as accepted by pressing the green tick mark next to the answer that helped you.
Also, if an answer has not fully covered you, you are advised to specify why it didn't answer your problem and also what you would like the outcome to be. Hope this is clear now and welcome to SO!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.