Dave Dave - 1 month ago 7
R Question

How to use p.adjust

The code below runs t-test (un-paired) using 2 matrices as input and returns p-values but can someone show me the exact code needed to generate the p.adjusted values aka the

FDR
corrected/adjusted p.values (p.adjust)

m1 <-go_samp_matrix_data[grep(paste(input$mychooser2$left, collapse='|'), rownames(go_samp_matrix_data), ignore.case=TRUE),]
m2 <-go_samp_matrix_data[grep(paste(input$mychooser2$right, collapse='|'), rownames(go_samp_matrix_data), ignore.case=TRUE),]

ttestmat1<-sapply(seq(ncol(m1)), function(x) f(m1[,x], m2[,x]))

f <- function(x,y){
test <- t.test(x,y, paired=FALSE)
out <- data.frame(pval = sprintf("%.3f", test$p.value))
return(out)
}

Answer

You need a vector of p-values, say p.vect. Then you simply include that in p.adjust() like so:

p.adjust(p.vect, "fdr")
Comments