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

Vivek Das vd4mm|nd @end|ng |rom gm@||@com
Sat Sep 28 06:43:04 CEST 2019


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 calculate any pvalues. Probability calculation is only needed when you
have distribution of data in each arm to make Ho(null hypothesis) thar
ststes condition 1 vs condition 2 have no difference but when you compute
the distribution, you find a difference that rejects your Null and makes
the alternative hypotheses true.

Just observed your “prop” is between only two values. So no reason for
comparing since there is no distribution.

Just make barplot and compute the Delta that can be difference between
70.42-7.75 or fold change 70.42/7.75. If they are absolute value you can
also scale them in log scale and do the same. Hope this helps. Good luck.

Vivek

On Fri, Sep 27, 2019 at 9:32 PM Ana Marija <sokovic.anamarija using gmail.com>
wrote:

> Hi Vivek,
>
> Thanks for getting back to me and yes that is what I tried:
>
> library(ggpubr)
> library(ggplot2)
> df <- data.frame("prop" = c(7.75,70.42), "Name" = c("All Genes","RG
> Genes"))
> my_comparisons <- list(c("All Genes","RG Genes"))
>
> p <-ggbarplot(df, x="Name", y="prop",fill="Name",legend ="",color =
> "white",palette = "jco",xlab = FALSE,ylab="cis eqtl per gene")
>
> p + stat_compare_means(comparisons=my_comparisons)
>
> I got p value 1, I am wondering does putting here p value makes sense
> because I don't have any distribution, I just have these two numbers
> on y axis:
> "prop" = c(7.75,70.42)
>
> Please advise,
>
> Thanks
> Ana
>
>
> On Fri, Sep 27, 2019 at 11:21 PM Vivek Das <vd4mmind using gmail.com> wrote:
> >
> > 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 <sokovic.anamarija using gmail.com>
> wrote:
> >>
> >> 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") +
> >> theme_minimal()+theme(legend.position = "none")
> >> p
> >>
> >> What do I need to change in my plot so that I have plot with p value
> >> shown on the attached figure?
> >>
> >> Thanks
> >> Ana
> >> ______________________________________________
> >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > --
> > ----------------------------------------------------------
> >
> > Vivek Das, PhD
>
-- 
----------------------------------------------------------

Vivek Das, PhD

	[[alternative HTML version deleted]]



More information about the R-help mailing list