So I'm trying to do a wilcox.test across rows for several proteins in the example dataset below
> dput(head(all.data))
structure(list(`Quant View:3404 Proteins in 3219 Clusters<BR>With 26 Decoys` = c("Tripeptidyl-peptidase II OS=Tetradesmus obliquus OX=3088 GN=BQ4739_LOCUS1693 PE=3 SV=1",
"AAA domain-containing protein OS=Tetradesmus obliquus OX=3088 GN=BQ4739_LOCUS15172 PE=4 SV=1",
"Importin N-terminal domain-containing protein OS=Tetradesmus obliquus OX=3088 GN=BQ4739_LOCUS16570 PE=4 SV=1",
"Uncharacterized protein OS=Tetradesmus obliquus OX=3088 GN=BQ4739_LOCUS8107 PE=4 SV=1",
"Uncharacterized protein OS=Tetradesmus obliquus OX=3088 GN=BQ4739_LOCUS6067 PE=4 SV=1",
"CBM20 domain-containing protein OS=Tetradesmus obliquus OX=3088 GN=BQ4739_LOCUS16954 PE=3 SV=1"
), `Accession Number` = c("A0A383V887", "A0A383WCV6", "A0A383WGG7",
"A0A383VTM6", "A0A383VJ69", "A0A383WH22"), `Mann-Whitney Test (p-value)Benjamini-Hochberg (p < 0.01200)` = c(0.00011,
0.00012, 0.00012, 0.00012, 0.00013, 0.00014), R_avg = c(20.2,
20.45, 20.25, 21.35, 20.25, 20.35), A28d_avg = c(21.25, 21.95,
21, 20.95, 21, 21.85), R_nolog = c(1204497.52628937, 1432397.0282665,
1246974.03982109, 2672947.36870384, 1246974.03982109, 1336473.68435192
), A28d_nolog = c(2493948.07964218, 4051430.60815479, 2097152,
2025715.3040774, 2097152, 3780118.42033046), `A28d/R` = c(2.07052984768276,
2.82842712474619, 1.68179283050743, 0.757858283255199, 1.68179283050743,
2.82842712474619), LogFC = c(1.05, 1.5, 0.750000000000002, -0.4,
0.750000000000002, 1.5)), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))
So basically I want to do a wilcox test for each accession number, comparing the value in column "R_avg" and "A28d_avg" and have each of the p-values be placed into a new column so I can make a volcano plot. I tried the two methods below and received errors.
> all.data$p-value<-wilcox.test(R_avg ~ A28d_avg, data=all.data)
Error in wilcox.test.formula(R_avg ~ A28d_avg, data = all.data) :
grouping factor must have exactly 2 levels
> all.data %>%
+ rowwise() %>%
+ wilcox.test(R_avg ~ A28d_avg, data=all.data)
Error in wilcox.test.default(., R_avg ~ A28d_avg, data = all.data) :
'x' must be numeric
Any help would be greatly appreciated