<p>I can see that there would be a three step process to doing this:</p>

<ol>
<li><p>Merge counts from all samples in the group and then resample pseudo-replicates from this. If <code>x</code> is a matrix with samples in the group being columns and genes being rows</p>



<pre><code>s &lt;- sample(row.names(x), n = mean(colSums(x)), probs=rowSums(x)/sum(rowSums(x))
stab &lt;- table(s)
s &lt;- as.vector(stab)
names(s) &lt;- names(stab)
</code></pre>

<p>Do this thousands of times.</p></li>
<li><p>You would then want to project those onto your MDS plot space - i'm less clear about how you could do this without perturbing the space itself.</p></li>
<li><p>Calculate the parameter for an ellipise that would contain 95% of these points. Again, I'm not so sure about how to do this, but I think the <code>car</code> pacakge might be a good place to start looking.</p></li>
</ol>

CC BY-SA 3.0
2017-06-06T11:28:46.080Z
2017-06-06T14:18:36.500Z
2017-06-06T14:18:36.500Z
Ian Sudbery
<p>Is it possible to draw e.g. 95% confidence ellipses around samples from the same group on the results from the plotMDS function under edgeR? If so, how?</p>

CC BY-SA 3.0
2017-06-05T17:28:32.703Z
What does the 95% confidence correspond to? MDS doesn’t directly give confidence intervals.
Konrad Rudolph
CC BY-SA 3.0
2017-06-05T21:07:31.713Z
That depends on whether or not you have a frequentist or bayesian view about confidence intervals. I would expect (from a bayesian interpretation) that the confidence ellipses on a 2D plot would contain 95% of the points that would be expected in a given sample group.
gringer
CC BY-SA 3.0
2017-06-06T11:40:59.517Z
@gringer Hmm. For a typical experimental setup in NGS, a sample group contains < 10 points. Often < 5. So there’s *a lot* of uncertainty about the placement of the ellipses based on this. ;-)
Konrad Rudolph
CC BY-SA 3.0
2017-06-06T14:08:19.527Z
I agree to what @KonradRudolph said. If your group has less < 10 or  < 5 , in that case the ellipse criterion might not even hold true or I would not believe in it. First of all MDSplot might not be needed as well for doing the 95% ellipse as well. This link explains pretty well about its use. I am just thinking some times we do a lot of over-estimation or over-calculation of certain statistical measures which for the first choice might not be required. Do you even want to do that? https://stats.stackexchange.com/questions/217374/real-meaning-of-confidence-ellipse .
ivivek_ngs
CC BY-SA 3.0
2017-06-06T14:25:02.240Z
The question assumes that the position on an MDS plot is a population parameter for a population from which each of the samples in the group are drawn from. It assumes that each sample is a point estimate of the population for that group. Under this interpretation, a confidence ellipse is a valid thing. However, i'm not sure position on an MDS plot can be called a population parameter due to the nature of how an MDS plot is constructed (specifcally the position of each sample is not independent of the position of the others). But perhaps some suitable parameter does exist?
Ian Sudbery
<r><edger>
confidence ellipses for MDS plot in edgeR?
# confidence ellipses for MDS plot in edgeR?

(Asked by: username_0 on 2017-06-05)

Is it possible to draw e.g. 95% confidence ellipses around samples from the same group on the results from the plotMDS function under edgeR? If so, how?

**Tags:** r, edger
> **Comments:**
> **username_1**: What does the 95% confidence correspond to? MDS doesn’t directly give confidence intervals.  
> **username_2**: That depends on whether or not you have a frequentist or bayesian view about confidence intervals. I would expect (from a bayesian interpretation) that the confidence ellipses on a 2D plot would contain 95% of the points that would be expected in a given sample group.  
> **username_1**: @gringer Hmm. For a typical experimental setup in NGS, a sample group contains < 10 points. Often < 5. So there’s *a lot* of uncertainty about the placement of the ellipses based on this. ;-)  
> **username_3**: I agree to what @KonradRudolph said. If your group has less < 10 or  < 5 , in that case the ellipse criterion might not even hold true or I would not believe in it. First of all MDSplot might not be needed as well for doing the 95% ellipse as well. This link explains pretty well about its use. I am just thinking some times we do a lot of over-estimation or over-calculation of certain statistical measures which for the first choice might not be required. Do you even want to do that? https://stats.stackexchange.com/questions/217374/real-meaning-of-confidence-ellipse .  
> **username_4**: The question assumes that the position on an MDS plot is a population parameter for a population from which each of the samples in the group are drawn from. It assumes that each sample is a point estimate of the population for that group. Under this interpretation, a confidence ellipse is a valid thing. However, i'm not sure position on an MDS plot can be called a population parameter due to the nature of how an MDS plot is constructed (specifcally the position of each sample is not independent of the position of the others). But perhaps some suitable parameter does exist?  

---

## 1 answers

### Answer by username_4 on 2017-06-06. Score: 2

I can see that there would be a three step process to doing this:

Merge counts from all samples in the group and then resample pseudo-replicates from this. If x is a matrix with samples in the group being columns and genes being rows
s <- sample(row.names(x), n = mean(colSums(x)), probs=rowSums(x)/sum(rowSums(x))
stab <- table(s)
s <- as.vector(stab)
names(s) <- names(stab)

Do this thousands of times.
You would then want to project those onto your MDS plot space - i'm less clear about how you could do this without perturbing the space itself.
Calculate the parameter for an ellipise that would contain 95% of these points. Again, I'm not so sure about how to do this, but I think the car pacakge might be a good place to start looking.


---

