Question: Adding p-value to box plot
0
gravatar for khn
11 months ago by
khn110
khn110 wrote:

I want to add p-value for box plots for independent two groups.

But the error said,,,

> p + stat_compare_means()
Don't know how to automatically pick scale for object of type quosure/formula. Defaulting to continuous.
Don't know how to automatically pick scale for object of type quosure/formula. Defaulting to continuous.
Error in validDetails.text(x) : 
  'pairlist' object cannot be coerced to type 'double'

Do you know how to resolve this? Maybe box plot does not show means, but I want to show p-value based on means?

Thank you in advance!!

R • 1.1k views
ADD COMMENTlink modified 11 months ago • written 11 months ago by khn110

Share an excerpt of the dataset and the code you are using.

ADD REPLYlink written 11 months ago by Arup Ghosh2.4k

How is your datatable ?

I used this some weeks ago:

ggplot(mean_expressed, aes(x = mean_expressed$variable, y = mean_expressed$value)) + 
  geom_boxplot(outlier.colour='black') + stat_compare_means(aes(group = mean_expressed$variable)

mean_expressed$variable is a qualitative variable that refers to groups to compare, and mean_expressed$value for the values

boxplot

ADD REPLYlink modified 11 months ago by RamRS27k • written 11 months ago by darbinator220

Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

ADD REPLYlink written 11 months ago by RamRS27k

Try this.

stat_compare_means(aes(group = Data), label = "p.format")
ADD REPLYlink modified 11 months ago • written 11 months ago by archana.bioinfo87180

Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

ADD REPLYlink written 11 months ago by RamRS27k
0
gravatar for khn
11 months ago by
khn110
khn110 wrote:

Thank you so much for everybody! The codes you provided me did not work again, so I tried as below, which worked actually.

my_comparisons <- list( c("1", "2"), c("1", "3"), c("1", "4"),c("1", "5"), c("1", "7"), c("2", "3"), c("2", "4"), c("2", "5"), c("2", "7"), c("3", "4"), c("3", "5"), c("3", "7"), c("4", "5"), c("4", "7"), c("5", "7") )

ggboxplot(x, x = "B", y = "A", + color = "B", palette = "jco")+ + stat_compare_means(comparisons = my_comparisons)

Though this did not show the name of analysis (Kruscal Wallis) on the plot.

Thank you!!

ADD COMMENTlink modified 11 months ago • written 11 months ago by khn110
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1798 users visited in the last hour