When running stat_compare_means
I am unable to run a t-test. If I leave the brackets empty it will attempt a Wilcoxen but I don't think it is accurate.
I have tried editing several settings under stat_compare_means
and tried changing to using geom_signif
but have gotten a variety of different results.
Note: The data needs to be grouped this way as there are other groups I have left out.
#functions
se = function(x) {
sd(x)/sqrt(length(x))
}
data_summary <- function(x) {
m <- mean(x)
ymin <- m-sd(x)
ymax <- m+sd(x)
return(c(y=m,ymin=ymin,ymax=ymax))
}
plot.mean <- function(x) {
m <- mean(x)
c(y = m, ymin = m, ymax = m)
}
#data set
HET.MOUSE.P
Mouse Brca1 Sex Tx Stage Count
001 fl/+ M OLAPARIB AnnexinV+ 33.90
002 fl/+ F DMSO AnnexinV+ 44.20
003 -/+ F OLAPARIB AnnexinV+ 40.00
004 -/+ M DMSO AnnexinV+ 32.60
005 -/+ M OLAPARIB AnnexinV+ 34.80
006 -/+ M OLAPARIB AnnexinV+ 21.82
007 fl/+ F OLAPARIB AnnexinV+ 27.09
008 -/+ F OLAPARIB AnnexinV+ 30.92
009 fl/+ M DMSO AnnexinV+ 4.82
010 -/+ M DMSO AnnexinV+ 3.97
011 -/+ F DMSO AnnexinV+ 3.01
012 -/+ F DMSO AnnexinV+ 2.91
013 -/+ M DMSO AnnexinV+ 2.42
014 -/+ M DMSO AnnexinV+ 4.15
015 -/+ M OLAPARIB AnnexinV+ 4.28
#plot code
HET.MOUSE.P.perT.med <- aggregate(Count ~ Stage + Tx, data = HET.MOUSE.P, median)
HET.MOUSE.P.perT.med <- HET.MOUSE.P.perT.med %>%
rename(med = Count)
HET.MOUSE.P.perT.med
HET.MOUSE.P.perT.se <- aggregate(Count ~ Stage + Tx, data = HET.MOUSE.P, se)
HET.MOUSE.P.perT.se <- HET.MOUSE.P.perT.se %>%
rename(se = Count)
HET.MOUSE.P.perT.se
HET.MOUSE.P.perT.simp <- merge(HET.MOUSE.P.perT.med, HET.MOUSE.P.perT.se)
HET.MOUSE.P.perT.simp[is.na(HET.MOUSE.P.perT.simp)] <- 0
HET.MOUSE.P.perT.simp
HET.MOUSE.P$Stage <-factor(HET.MOUSE.P$Stage)
HET.MOUSE.P$Stage <-factor(HET.MOUSE.P$Stage, levels = c("AnnexinV+"))
HET.MOUSE.P.perT.simp$Stage <-factor(HET.MOUSE.P.perT.simp$Stage, levels = c("AnnexinV+"))
MOUSE.ttest <- compare_means(data = HET.MOUSE.P, Count~Tx, method = "t.test", paired = FALSE, group.by = "Stage")
HET.MOUSE.P.perT.barplot = ggplot(HET.MOUSE.P.perT.simp, aes(x = Stage, y = med, fill = Tx)) +
geom_bar(stat="identity", color="black",
position=position_dodge()) +
geom_point(data = HET.MOUSE.P, aes(x = Stage, y = Count, fill = Tx),
color = "white", pch=21, size= 3, position = position_dodge(width = .9), show.legend = FALSE) +
geom_errorbar(aes(ymin = med, ymax=med+se), width=.2,
position=position_dodge(.9)) +
scale_fill_manual(values = c("darkblue", "deepskyblue1")) +
scale_shape_manual(values = c(0, 2)) +
scale_x_discrete(limits=c("AnnexinV+")) +
labs(x = NULL, y = "% Total Cells", fill ="Treatment", cex.lab = 5) +
theme_classic() + ylim(0,50) +
theme(text = element_text(family = "Arial"),
plot.title = element_text(size = 16, hjust = 0.5, face = "bold"),
axis.title.y = element_text(size = 12, face = "bold"),
axis.text.x = element_text(size = 10, color = "black"),
axis.text.y = element_text(size = 14, color = "black"),
axis.line = element_line(color = "Black"),
legend.title = element_text(size = 11),
legend.text = element_text(size = 11),
legend.position = 'right',
legend.justification = c(-0.05,-0.05)) +
stat_compare_means(method = "t.test")
HET.MOUSE.P.perT.barplot
After running this I get the error message:
Warning message:
Computation failed in stat_compare_means()
:
Problem while computing p = purrr::map(...)
.