I've been trying to perform Wilcoxon Signed Rank Test on my huge dataset. below is a representative of my sample
sample Abiotrophia Abyssicoccus Acaryochloris yield day season
R11P4_BS 0.454828660436137 8.71569632259294 0 low 60 2
R13P1_BS 0.013239875389408 10.8649859288577 0.147574819401445 high 60 1
R13P3_BS 0 5.13545281606475 0.386996904024768 low 30 1
I would like to compare and get a p-value for my sample group (ex: yield-high and low) for each bacteria (Abyssicoccus albus, Acaryochloris marina, Acetilactobacillus jinshanensis) baed on Wilcoxon Signed Rank Test. Final goal is to determine which bacteria differs significantly in 'high' and 'low'.
> dput(head(dat))
structure(list(Abiotrophia = c(0, 3.21408045977011, 0.117816091954023,
0, 0.002873563218391, 0), Abyssicoccus = c(0.454828660436137,
0.013239875389408, 0, 0, 0, 0.007009345794393), Acaryochloris = c(8.71569632259294,
10.8649859288577, 5.13545281606475, 5.72940386089162, 0.888392623745432,
3.93946335292641), day = c(0L, 60L, 60L, 60L, 90L, 90L), yield = c("low",
"high", "high", "low", "high", "high"), season = c(1L, 1L,
1L, 1L, 1L, 1L)), row.names = c("R11P4_BS", "R13P1_BS", "R13P3_BS",
"R13P6_BS", "R14P1_BS", "R14P3_BS"), class = "data.frame")
this is what i managed to do so far, i believe this shows the p-value for data in row no7
wilcox.test(data[data$yield == "low", 7],
data[data$yield == "high", 7], exact=FALSE)$p.val
[1] 0.09657031
and the code below gave me error:
sapply(2:ncol(data),
function(x) {
wilcox.test(data[data$yield == "low", 7],
data[data$yield == "high", 7], exact=FALSE)$p.val
}
)