<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/balancing-a-centrifuge/"></div></div><div><a data-url="http://www.r-bloggers.com/balancing-a-centrifuge/" data-counturl="http://www.r-bloggers.com/balancing-a-centrifuge/" data-count="horizontal" data-text="Balancing a centrifuge" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://martinsbioblogg.wordpress.com/2016/06/11/balancing-a-centrifuge/"> R – On unicorns and genes</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I saw this cute little paper on arxiv about balancing a centrifuge: Peil &amp; Hauryliuk (2010) <a target="_blank" href="https://arxiv.org/ftp/arxiv/papers/1004/1004.3671.pdf">A new spin on spinning your samples: balancing rotors in a non-trivial manner.</a> Let us have a look at the maths of balancing a centrifuge.</p>
<p>The way I think most people (including myself) balance their samples is to put them opposite of each other, just like Peil &amp; Hauryliuk write. However, there are many more balanced configurations, some of which look really weird. The authors generate three balanced configurations with increasing oddity, show them to researchers and ask them whether they are balanced. About half, 30% and 15% of them identified each configuration as balanced. Here are the configurations:</p>
<p><a target="_blank" href="https://martinsbioblogg.files.wordpress.com/2016/06/configuration_plot1.png"><img height="213" alt="configuration_plot" width="640" class="wp-image-4604" src="https://martinsbioblogg.files.wordpress.com/2016/06/configuration_plot1.png?w=640&h=213"></a><br>
(Drawn after their paper.)</p>
<p>Take a rotor in a usual bench top centrifuge. It’s a large, in itself balanced, piece of metal with holes to put microcentrifuge tubes in. We assume that all tubes have the same mass <em>m</em> and that the holes are equally spaced. The rotor will spin around its own axis, helping us separate samples and pellet precipitates etc. When the centrifuge is balanced, the centre of mass of the samples will be aligned with the axis of rotation. So, if we place a two-dimensional coordinate system on the axis of rotation like so,</p>
<p><a target="_blank" href="https://martinsbioblogg.files.wordpress.com/2016/06/koordinater.jpg"><img height="300" alt="koordinater" width="300" class="wp-image-4600" src="https://martinsbioblogg.files.wordpress.com/2016/06/koordinater.jpg?w=300&h=300"></a></p>
<p>the tubes are positioned on a circle around it:</p>
<p><img title="x_i = r \cos {\theta_i}" alt="x_i = r \cos {\theta_i}" class="latex" src="https://s0.wp.com/latex.php?latex=x_i+%3D+r+%5Ccos+%7B%5Ctheta_i%7D&bg=ffffff&%23038;fg=666666&%23038;s=0"><br>
<img title="y_i = r \sin {\theta_i}" alt="y_i = r \sin {\theta_i}" class="latex" src="https://s0.wp.com/latex.php?latex=y_i+%3D+r+%5Csin+%7B%5Ctheta_i%7D&bg=ffffff&%23038;fg=666666&%23038;s=0"></p>
<p>The angle to each position in the rotor will be</p>
<p><img title="\theta(i) = \dfrac{2\pi(i - 1)}{N}" alt="\theta(i) = \dfrac{2\pi(i - 1)}{N}" class="latex" src="https://s0.wp.com/latex.php?latex=%5Ctheta%28i%29+%3D+%5Cdfrac%7B2%5Cpi%28i+-+1%29%7D%7BN%7D&bg=ffffff&%23038;fg=666666&%23038;s=0"></p>
<p>where <em>i</em> is the position in question, starting at 1, and <em>N</em> the number of positions in the rotor. Let’s label each configuration by the numbers of the positions that are occupied. So we could talk about (1, 16)<sub>30</sub> as the common balanced pair of tubes in a 30-position rotor. (Yeah, I know, counting from 1 is a lot more confusing than counting from zero. Let’s view it as a kind of practice for dealing with genomic coordinates.)</p>
<p>We express the position of each tube (treated as a point mass) as a vector. Since we put the origin on the axis of rotation, these vectors have to sum to zero for the centrifuge to be balanced.</p>
<p><img title="\sum \limits_{i} {m\mathbf{r_i}} = \mathbf{0}" alt="\sum \limits_{i} {m\mathbf{r_i}} = \mathbf{0}" class="latex" src="https://s0.wp.com/latex.php?latex=%5Csum+%5Climits_%7Bi%7D+%7Bm%5Cmathbf%7Br_i%7D%7D+%3D+%5Cmathbf%7B0%7D&bg=ffffff&%23038;fg=666666&%23038;s=0"></p>
<p>Since the masses are equal, they can be removed, as can the radius, which is constant, and we can consider the x and y coordinates separately.</p>
<p><img title="\left(\begin{array}{c} \sum \limits_{i} {\cos {\theta(i)}} \\ \sum \limits_{i} {\sin {\theta(i)}} \end{array}\right) = \left(\begin{array}{c} 0 \\ 0 \end{array}\right)" alt="\left(\begin{array}{c} \sum \limits_{i} {\cos {\theta(i)}} \\ \sum \limits_{i} {\sin {\theta(i)}} \end{array}\right) = \left(\begin{array}{c} 0 \\ 0 \end{array}\right)" class="latex" src="https://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Csum+%5Climits_%7Bi%7D+%7B%5Ccos+%7B%5Ctheta%28i%29%7D%7D+%5C%5C+%5Csum+%5Climits_%7Bi%7D+%7B%5Csin+%7B%5Ctheta%28i%29%7D%7D+%5Cend%7Barray%7D%5Cright%29+%3D+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+0+%5C%5C+0+%5Cend%7Barray%7D%5Cright%29&bg=ffffff&%23038;fg=666666&%23038;s=0"></p>
<p>For the (1, 16)<sub>30</sub> configuration, the vectors are</p>
<p><img title="\left(\begin{array}{c} \cos {\theta(1)} \\ \sin {\theta(1)} \end{array}\right) + \left(\begin{array}{c} \cos {\theta(16)} \\ \sin {\theta(16)} \end{array}\right) = \left(\begin{array}{c} \cos {0} \\ \sin {0} \end{array}\right) + \left(\begin{array}{c} \cos {\pi} \\ \sin {\pi} \end{array}\right) = \left(\begin{array}{c} 1 \\ 0 \end{array}\right) + \left(\begin{array}{c} -1 \\ 0 \end{array}\right) " alt="\left(\begin{array}{c} \cos {\theta(1)} \\ \sin {\theta(1)} \end{array}\right) + \left(\begin{array}{c} \cos {\theta(16)} \\ \sin {\theta(16)} \end{array}\right) = \left(\begin{array}{c} \cos {0} \\ \sin {0} \end{array}\right) + \left(\begin{array}{c} \cos {\pi} \\ \sin {\pi} \end{array}\right) = \left(\begin{array}{c} 1 \\ 0 \end{array}\right) + \left(\begin{array}{c} -1 \\ 0 \end{array}\right) " class="latex" src="https://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ccos+%7B%5Ctheta%281%29%7D+%5C%5C+%5Csin+%7B%5Ctheta%281%29%7D+%5Cend%7Barray%7D%5Cright%29+%2B+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ccos+%7B%5Ctheta%2816%29%7D+%5C%5C+%5Csin+%7B%5Ctheta%2816%29%7D+%5Cend%7Barray%7D%5Cright%29+%3D+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ccos+%7B0%7D+%5C%5C+%5Csin+%7B0%7D+%5Cend%7Barray%7D%5Cright%29+%2B+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ccos+%7B%5Cpi%7D+%5C%5C+%5Csin+%7B%5Cpi%7D+%5Cend%7Barray%7D%5Cright%29+%3D+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+1+%5C%5C+0+%5Cend%7Barray%7D%5Cright%29+%2B+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+-1+%5C%5C+0+%5Cend%7Barray%7D%5Cright%29+&bg=ffffff&%23038;fg=666666&%23038;s=0"></p>
<p>So we haven’t been deluding ourselves. This configuration is balanced. That is about as much maths as I’m prepared to do in LaTex in a WordPress blog editor. So let’s implement this in R code:</p>
<pre>
library(magrittr)
theta &lt;- function(n, N) (n - 1) * 2 * pi / N
tube &lt;- function(theta) c(cos(theta), sin(theta))
</pre>
<p>Now, we can look at Peil &amp; Hauryliuk’s configurations, for instance the first (1, 11, 14, 15, 21, 29, 30)<sub>30</sub></p>
<pre>
positions &lt;- c(1, 11, 14, 15, 21, 29, 30)
tubes &lt;- positions %>% lapply(theta, N = 30) %>% lapply(tube)
c(sum(unlist(lapply(tubes, function(x) x[1]))),
  sum(unlist(lapply(tubes, function(x) x[2]))))
</pre>
<p>The above code 1) defines the configuration; 2) turns positions into angles and then tube coordinates; and 3) sums the x and y coordinates separately. The result isn’t exactly zero (for computational reasons), but close enough. Putting in their third configuration, (4, 8, 14, 15, 21, 27, 28)<sub>30</sub>, we again get almost zero. Even this strange-looking configuration seems to be balanced.</p>
<p>I’m biased because I read the text first, but if someone asked me, I would have to think about the first two configurations, and there is no way I would allow a student to run with the third if I saw it in the lab. That conservative attitude, though not completely scientific, might not be the worst thing. Centrifuge accidents are serious business, and as the authors note:</p>
<blockquote><p>Finally, non-symmetric arrangement (Fig. 1C) was recognized as balanced by 17% of researchers. Some of these were actually calculating moment of inertia, i.e. were coming to solution knowingly, the rest where basically guessing. The latter should be banished from laboratory practice, since these people are ready to make dangerous decisions without actual understanding of the case, which renders them extremely dangerous in the laboratory settings.</p>
</blockquote>
<p>(Plotting code for the first figure is on <a target="_blank" href="https://github.com/mrtnj/rstuff/blob/master/centrifuge.R">Github</a>.)</p>
<p>Postat i:<a target="_blank" href="https://martinsbioblogg.wordpress.com/category/computer-stuff/">computer stuff</a>, <a target="_blank" href="https://martinsbioblogg.wordpress.com/category/data-analysis/">data analysis</a>, <a target="_blank" href="https://martinsbioblogg.wordpress.com/category/sa-kallad-humor/">så kallad humor</a> Tagged: <a target="_blank" href="https://martinsbioblogg.wordpress.com/tag/balance/">balance</a>, <a target="_blank" href="https://martinsbioblogg.wordpress.com/tag/centrifuge/">centrifuge</a>, <a target="_blank" href="https://martinsbioblogg.wordpress.com/tag/r/">R</a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/martinsbioblogg.wordpress.com/4565/"><img alt="" src="http://feeds.wordpress.com/1.0/delicious/martinsbioblogg.wordpress.com/4565/" border="0"></a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/martinsbioblogg.wordpress.com/4565/"><img alt="" src="http://feeds.wordpress.com/1.0/facebook/martinsbioblogg.wordpress.com/4565/" border="0"></a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/martinsbioblogg.wordpress.com/4565/"><img alt="" src="http://feeds.wordpress.com/1.0/twitter/martinsbioblogg.wordpress.com/4565/" border="0"></a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/martinsbioblogg.wordpress.com/4565/"><img alt="" src="http://feeds.wordpress.com/1.0/stumble/martinsbioblogg.wordpress.com/4565/" border="0"></a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/martinsbioblogg.wordpress.com/4565/"><img alt="" src="http://feeds.wordpress.com/1.0/digg/martinsbioblogg.wordpress.com/4565/" border="0"></a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/martinsbioblogg.wordpress.com/4565/"><img alt="" src="http://feeds.wordpress.com/1.0/reddit/martinsbioblogg.wordpress.com/4565/" border="0"></a> <img height="1" alt="" width="1" src="https://pixel.wp.com/b.gif?host=martinsbioblogg.wordpress.com&blog=13039394&%23038;post=4565&%23038;subd=martinsbioblogg&%23038;ref=&%23038;feed=1" border="0"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/balancing-a-centrifuge/"></div></div><div><a data-url="http://www.r-bloggers.com/balancing-a-centrifuge/" data-counturl="http://www.r-bloggers.com/balancing-a-centrifuge/" data-count="vertical" data-text="Balancing a centrifuge" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://martinsbioblogg.wordpress.com/2016/06/11/balancing-a-centrifuge/"> R – On unicorns and genes</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/fadZKioMFKk"></a></div>