Re: [R] how to add p values to bar plot?

2019-09-28 Thread Jim Lemon
Hi Ana, You seem to have a p-value at the top of the second plot. Do you just want that p-value in a different place? My first guess would be the "annotate" argument. Say you wanted your p-value in the middle of the plot. # your ggplot line p+annotate("text",x=1.5,y=0.05,label="p = 1.6x10-16") p

Re: [R] how to add p values to bar plot?

2019-09-27 Thread Vivek Das
Well that means already a ratio. Could you show me how the data frame looks like? If they are array of values then you compare the distribution of your ratios like Ratio1 array from “ (#of EQTLs)/(#of genes)” vs Ratio 2 arrays of the “same for the other, RG condition”. ratio1 = c(ratio1Value1, rat

Re: [R] how to add p values to bar plot?

2019-09-27 Thread Ana Marija
Awesome, thanks! Yes those two numbers on y axis I calculated as (#of EQTLs)/(#of genes) and the same for the other, RG condition. So implicitly I do have a spread just that data was not used to plot this, only those ratios. Is in this case still p value not necessary? On Fri, 27 Sep 2019 at 23:4

Re: [R] how to add p values to bar plot?

2019-09-27 Thread Vivek Das
Ah, this is a single observation and not pvalue calculation over a distribution. You don’t seem to have a spread. Here your code seemed like it was over all genes(more than 1) vs RG genes(also more than one). But it is basically an observation of difference of 2 values. So it doesn’t need to calcul

Re: [R] how to add p values to bar plot?

2019-09-27 Thread Vivek Das
You will need to add stat_compare_means. Take a look at here. http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/ library(ggpubr) p + stat_compare_means() Should be fine. Vivek On Fri, Sep 27, 2019 at 7:29 PM Ana Marija

[R] how to add p values to bar plot?

2019-09-27 Thread Ana Marija
Hi, I created a bar plot with this code: library(ggplot2) df <- data.frame("prop" = c(7.75,70.42), "Name" = c("All Genes","RG Genes")) p<-ggplot(data=df, aes(x=Name, y=prop,fill=Name)) + geom_bar(stat="identity")+ labs(x="", y = "Proportion of cis EQTLs")+ scale_fill_brewer(palette="Greens") +