could you please help me add median IQR labels to x-axis of panel produced from facet_wrap. I'm afraid I wasn't able to replicate previous SO suggestions. I've attached my code and example output. Thanks.
#data
>head(df.tnbc,10)
# A tibble: 10 x 3
variable.x value.x value.y
<fct> <dbl> <fct>
1 Tumor_Fraction_ULPS 24.2 TNBC/basal (ER-/PR-/HER2-) +
2 Tumor_Fraction_30xWGS 24.3 TNBC/basal (ER-/PR-/HER2-) +
3 Tumor_Fraction_ULPS 13.2 TNBC/basal (ER-/PR-/HER2-) +
4 Tumor_Fraction_30xWGS 14.5 TNBC/basal (ER-/PR-/HER2-) +
5 Tumor_Fraction_ULPS 12.3 TNBC/basal (ER-/PR-/HER2-) +
6 Tumor_Fraction_30xWGS 11.7 TNBC/basal (ER-/PR-/HER2-) +
7 Tumor_Fraction_30xWGS 8.66 Non-TNBC/basal (ER-/PR-/HER2-)
8 Tumor_Fraction_ULPS 9.38 Non-TNBC/basal (ER-/PR-/HER2-)
9 Tumor_Fraction_ULPS 6.57 Non-TNBC/basal (ER-/PR-/HER2-)
10 Tumor_Fraction_30xWGS 7.61 Non-TNBC/basal (ER-/PR-/HER2-)
#code I tried
ggplot(data=df.tnbc ,aes(x=factor(value.y), y=value.x),color=value.x) +
geom_boxplot(outlier.size = 0,fill="darkgoldenrod2")+geom_jitter(shape=16, size=2,height=0)+
xlab("TNBC status by Immunohistochemistry staining") + ylab("ctDNA fractions / %")+scale_y_continuous(limits = c(0,25))+
ggtitle("ctDNA fractions by TNBC status") +
theme(plot.title=element_text(family="Times", face="bold", size=14,hjust = 1),
axis.text.x = element_text(family="Times", angle = 45, hjust = 1, face="bold"),
axis.text.y = element_text(family="Times", size = 14, face="bold"),
axis.title.y = element_text(family="Times", size = 14, face="bold"),
axis.title.x = element_text(family="Times", size = 14, face="bold"),
legend.title = element_text(family="Times",color = "black", size = 14, face="bold"),
legend.text = element_text(family="Times",color = "black", face="bold"))+stat_compare_means(na.rm=TRUE,label.x=3,hjust = 2.9)+
theme_pubclean() +
facet_wrap(~variable.x, scale="free")
##editing individual x- axis to append median IQR fails
ggplot(data=df.tnbc ,aes(x=factor(value.y), y=value.x),color=value.x) +
geom_boxplot(outlier.size = 0,fill="darkgoldenrod2")+geom_jitter(shape=16, size=2,height=0)+
xlab("TNBC status by Immunohistochemistry staining") + ylab("ctDNA fractions / %")+scale_y_continuous(limits = c(0,25))+
ggtitle("ctDNA fractions by TNBC status") +
theme(plot.title=element_text(family="Times", face="bold", size=14,hjust = 1),
axis.text.x = element_text(family="Times", angle = 45, hjust = 1, face="bold"),
axis.text.y = element_text(family="Times", size = 14, face="bold"),
axis.title.y = element_text(family="Times", size = 14, face="bold"),
axis.title.x = element_text(family="Times", size = 14, face="bold"),
legend.title = element_text(family="Times",color = "black", size = 14, face="bold"),
legend.text = element_text(family="Times",color = "black", face="bold"))+stat_compare_means(na.rm=TRUE,label.x=3,hjust = 2.9)+
theme_pubclean() +
facet_wrap(~variable.x, scale="free",
labeller = labeller(variable.x = c("Tumor_Fraction_ULPS","Tumor_Fraction_30xWGS"),
value.y = c("Non-TNBC/basal Med[IQR] 4.76% [1.12%-5.84%]","TNBC/basal (ER-/PR-/HER2-) Med[IQR] 12.8% [10.1%-15.9%]",
"Non-TNBC/basal Med[IQR] 3.08% [2.12%-6.33%]","TNBC/basal (ER-/PR-/HER2-) Med[IQR] 13.1% [9.41%-17.0%]")))