Ahdee
Ahdee

Reputation: 4949

How plot results from a pairwise.wilcox.test?

I would like to plot a bubble/circle plot of p.values generated from pairwise comparisons. The goal is to be able to visually identify which comparisons are significant p < .05

For example like the one generated from corrplot. The issue I think its because the table that it generates is not complete in that it lacks the full. For example for a comparison for May-Sept the table looks like this. Here is is my attempt to plot this with corrplot?

 library ( corrplot)
    attach(airquality)
    Month <- factor(Month, labels = month.abb[5:9])
    ## These give warnings because of ties :

    test = pairwise.wilcox.test(Ozone, Month, p.adj = "bonf")
    detach()

    corrplot(as.matrix (test$p.value), 
p.mat = as.matrix (test$p.value) ,  is.corr = FALSE, method = "circle", mar = c(1, 1, 2, 0) )

The table the pairwise generate looks like this.

> test$p.value
            May       Jun         Jul        Aug
Jun 1.000000000        NA          NA         NA
Jul 0.000299639 0.1413625          NA         NA
Aug 0.001208078 0.2590776 1.000000000         NA
Sep 1.000000000 1.0000000 0.007442604 0.03247955

is there a way to plot this similar to corrplot? Or any other way to show only significant comparison would be great.

thanks!

Upvotes: 3

Views: 1873

Answers (1)

Dominic van Essen
Dominic van Essen

Reputation: 872

As commented by @dcarlson, your main problem is that significant p-values are small, which is the other way around than expected by corrplot.

So a fairly simple trick is to transform the p-values, so that larger values correspond to more-significant. A commonly-used way to do this is to take the negative of the log (this works nicely, since all p-values are less than one, so all log(p-values) are negative).

my_transformed_pvals=-log10(test$p.value)
corrplot(as.matrix(my_transformed_pvals),is.corr=F)

enter image description here

Upvotes: 1

Related Questions