How can I compare two lists of means in a dataframe, by row

Viewed 74

I am trying to compare with t-test, two list of gene expressions mean values.

My matrix is built like this

col1 <- c(6.7 , 8.4, 3.1)
col2 <- c(7.7, 8.8, 3.6)
matrix <- cbind(col1, col2)
rownames(matrix) <- c("gene1", "gene2", "gene3")

I want to get the p value for each genes. all that I know is that col1 correspond to means calculated on 22 sample and col2 30 samples.

I tried to apply a t-test per row, but it is not working.

apply(t.test, matrix$col1, matrix$col2, 1)
1 Answers

I think you need to do a better job of defining what, exactly it is that you want to compare. There's no such thing as a p value of a mean. What are you comparing, base pair variance between a gene in column 1 and one in column 2? Or is col. 1 the full sequence of one gene and col2 the full sequence of a second gene? Your question doesn't make it clear what you're analyzing, and without that you may have good math that means nothing.

Here's a good definition of t test, assuming that that test is, in fact, what you ought to be using. Note that this test requires not only the difference between the means (which you could calculate from what you showed us), the standard deviation of each mean (which you didn't), and the number of items (which you did). This means we only have 2 out of 3 of the necessary inputs. To get the 3rd, either you need to supply it, or you need to supply the raw data which produced it.

Related