Reputation: 11
I have a data set that is paired data from multiple samples that I want to do a parallel coordinates graph with and include a p-value
above (i.e. plot each data point in each group and link the pairs with a line and have the comparison statistic above the plotted data).
I can get the graph to (largely) look the way I want it to, but when I try and add a p-value
using stat_compare_means(paired=TRUE)
, I get 3 errors:
2 x:
"Don't know how to automatically pick scale for object of type quosure/formula. Defaulting to continuous."
1 x:
"Error in validDetails.text(x) : 'pairlist' object cannot be coerced to type 'double'".
My data is a data.fram
e with three variables: a sample variable so I know which pair is which, a group variable so I know which category the value is, and the value variable. I've pasted the code below and am more than happy to take other suggestions on any other ways to make the code look better as well.
ggplot(test_OCI, aes(x=test_OCI$variable, y=test_OCI$value, group =test_OCI$Pt)) +
geom_point(aes(x=test_OCI$variable),size=3)+
geom_line(aes(x=test_OCI$variable),group=test_OCI$Pt)+
theme_bw()+
theme(panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
axis.line=element_line(color="black"))+
scale_x_discrete(labels=c("OCI_pre_ART"="Pre-ART OCI", "OCI_on_ART"="On-ART OCI"))+
stat_compare_means(paired=TRUE)
edit 1: adding sample data
There isn't too much data, but I've added it below per request.
Pt variable value
1 Pt1 OCI_pre_ART 0.024
2 Pt2 OCI_pre_ART 0.027
3 Pt3 OCI_pre_ART 0.027
4 Pt4 OCI_pre_ART 0.010
5 Pt5 OCI_pre_ART 0.075
6 Pt6 OCI_pre_ART 0.040
7 Pt7 OCI_pre_ART 0.070
8 Pt8 OCI_pre_ART 0.011
9 Pt9 OCI_pre_ART 0.022
10 Pt10 OCI_pre_ART 0.006
11 Pt11 OCI_pre_ART 0.019
12 Pt1 OCI_on_ART 0.223
13 Pt2 OCI_on_ART 0.166
14 Pt3 OCI_on_ART 0.163
15 Pt4 OCI_on_ART 0.126
16 Pt5 OCI_on_ART 0.090
17 Pt6 OCI_on_ART 0.139
18 Pt7 OCI_on_ART 0.403
19 Pt8 OCI_on_ART 0.342
20 Pt9 OCI_on_ART 0.092
edit 2: packages
all lines in the figure code are from ggplot2 except stat_compare_means(paired=TRUE) which is from ggpubr.
Upvotes: 0
Views: 150
Reputation: 11
I'm not sure if this is the reason, but it appears that the stat_compare_means()
line was not interpreting the x~y aesthestic. Changing the line to
stat_compare_means(comparisons = list(c("OCI_pre_ART","OCI_on_ART")), paired=TRUE)
resulted in a functional graph.
Upvotes: 1