<p>Hello everyone,</p>

<p>I'm trying to do a simple t-test on my microarray sample in R. My sample looks like this:</p>

<pre><code>gene_id        gene          sample_1        value_1     sample_2    value_2
XLOC_000001    LOC425783     Renal            20.8152     Heart       14.0945
XLOC_000002    GOLGB1          Renal            10.488     Heart        8.89434
</code></pre>

<p>So the t-test is between sample 1 and sample 2 and my code looks like this:</p>

<pre><code>ttestfun = function(x) t.test(x[4], x[6])$p.value
p.value = apply(expression_data, 1, ttestfun)
</code></pre>

<p>It gives me the following error: Error in t.test.default(x[6], x[8]) : not enough 'x' observations
In addition: Warning message:
In mean.default(x) : argument is not numeric or logical: returning NA</p>

<p>What am I doing wrong? Please help.</p>

<p>Many thanks.</p>

<p>I think there's some misconceptions operating here from the original questioner. First and foremost, a t-test is not just a way of calculating p-values, it is a statistical test to determine whether two populations have varying means. The p-value that results from the test is a useful indicator for whether or not to support your null hypothesis (that the two populations have the same mean), but is not the purpose of the test.</p>

<p>In order to carry out a t-test between two populations, you need to know two things about those populations: 1) the mean of the observations and 2) the variance about that mean. The single value you have for each population <em>could</em> be a proxy for the mean (although it is a particularly bad one - see below), but there is no way that you can know the variance from only one observation. This is why replicates are <em>required</em> for microarray analysis, not a nice optional extra.</p>

<p>The reason a single observation on a single microarray is a bad proxy for the population mean is because you have no way of knowing whether the individual tested is typical for the population concerned. Assuming the expression of a given gene is normally distributed among your population (and this is an assumption that you have to make in order for the t-test to be a valid test anyway), your single individual could come from anywhere on the bell curve. Yes, it is most likely that the observation is somewhere near the mean (by definition, ~68% within 1 standard deviation, see the graph), but there is a significant chance that it could have come from either extreme.</p>

<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Standard_deviation_diagram.svg/500px-Standard_deviation_diagram.svg.png" alt="Normal Distribution"/></p>

<p>Finally, I've read what you suggest about the hypergeometric test in relation to RNA-Seq data recently, but again the use of this test is based on a flawed assumption (that the variance of a gene between the 2 populations is equivalent to the population variance). Picking a random statistical test out of the bag, just because it is able to give you a p-value in your particular circumstance is almost universally bad practise. You need to be able to justify it in light of the assumptions you are making in order to apply the test.</p>

<p>BTW, your data does not look like it is in log2 scale (if it is, there's an ~32-fold difference between the renal and heart observations for the first gene above) - how have you got the data into R &amp; normalised it?</p>
