text: user10677: i am trying to calculate mean Phred scores for my sequencing data, but i feel not very comfortable about it. There are actually two ways of calculating. (I just use an existing sample)
  giving: 3 reads with a mean phred score of 20, 10 and 3 (meaning Error rates of 1%, 10% and 50%, respectively)
  Way 1 to calculate: Just take the arithmetic mean of the q scores:
  (20+10+3)/3 = 11
  Way 2:  Take the arithmetic mean of the error rates:
  (0,5+0,1+0,01)/3 ~= 0.2
  And then calculate the q score by
  -10*log10(0.2) = 6.99
  (https://gigabaseorgigabyte.wordpress.com/2017/06/26/averaging-basecall-quality-scores-the-right-way/)
  The Author of this Blog claims, that Way 2 is the correct version, but i still do not get why.
  Is somebody able to answer this question?
  Thanks a lot
  
  user339: Not sure if my explanation is any good but let's try...
  First, let's convince ourselves that converting phred to probability is the right thing to do (i.e. your Way 2).
  Imagine a read of length 10000 bp with half of the bases with Q=10 (or P=0.1) and the other half with Q=20 (or P=0.01). The number of wrong calls you expect is therefore 550:
  n = 10000
  (n * 0.01 * 0.5) + (n * 0.1 * 0.5) # -> 550 wrong calls
  
  So the overall error rate is 550/10000 = 0.055 which corresponds to Q=12.6. If you follow your Way 2 you do get this answer:
  ((n * 0.5 * 0.01) + (n * 0.5 * 0.1))/n = 0.055
  -10*log10(0.055) = 12.6 
  
  If you follow your Way 1 you get Q=15, which means an overoptimistic error rate of ~0.03 or ~316 wrong calls. Why is that?
  Because phred is on a non-linear, logarithmic, scale: a unit change  towards the high values is less important than a unit change towards the lower end. For example, across 10000 bases a change from Q=30 to Q=31 means a change from 10 to ~8 wrong calls - a difference of 2 only. But a change from  Q=10 to Q=11 means 1000 to ~800 wrong calls: the difference is a substantial ~200 calls.
  Having said this, the straight average of phred scores is not "wrong". It measures the overall phred score but it does not reflect the expected number of wrong calls, which is probably what you want in this case.
  
original_text: 10677: <p>i am trying to calculate mean Phred scores for my sequencing data, but i feel not very comfortable about it. There are actually two ways of calculating. (I just use an existing sample)
  giving: 3 reads with a mean phred score of 20, 10 and 3 (meaning Error rates of 1%, 10% and 50%, respectively)</p>
  <p>Way 1 to calculate: Just take the arithmetic mean of the q scores:</p>
  <p><code>(20+10+3)/3 = 11</code></p>
  <p>Way 2:  Take the arithmetic mean of the error rates:</p>
  <p><code>(0,5+0,1+0,01)/3 ~= 0.2</code></p>
  <p>And then calculate the q score by</p>
  <p><code>-10*log10(0.2) = 6.99</code></p>
  <p>(<a href="https://gigabaseorgigabyte.wordpress.com/2017/06/26/averaging-basecall-quality-scores-the-right-way/" rel="nofollow noreferrer">https://gigabaseorgigabyte.wordpress.com/2017/06/26/averaging-basecall-quality-scores-the-right-way/</a>)</p>
  <p>The Author of this Blog claims, that Way 2 is the correct version, but i still do not get why.</p>
  <p>Is somebody able to answer this question?</p>
  <p>Thanks a lot</p>
   339: <p>Not sure if my explanation is any good but let's try...</p>
  <p>First, let's convince ourselves that converting phred to probability is the right thing to do (<em>i.e.</em> your Way 2).</p>
  <p>Imagine a read of length 10000 bp with half of the bases with Q=10 (or P=0.1) and the other half with Q=20 (or P=0.01). The number of wrong calls you expect is therefore 550:</p>
  <pre><code>n = 10000
  (n * 0.01 * 0.5) + (n * 0.1 * 0.5) # -&gt; 550 wrong calls
  </code></pre>
  <p>So the overall error rate is <code>550/10000 = 0.055</code> which corresponds to Q=12.6. If you follow your Way 2 you do get this answer:</p>
  <pre><code>((n * 0.5 * 0.01) + (n * 0.5 * 0.1))/n = 0.055
  -10*log10(0.055) = 12.6 
  </code></pre>
  <p>If you follow your Way 1 you get Q=15, which means an overoptimistic error rate of ~0.03 or ~316 wrong calls. Why is that?</p>
  <p>Because phred is on a non-linear, logarithmic, scale: a unit change  towards the high values is less important than a unit change towards the lower end. For example, across 10000 bases a change from Q=30 to Q=31 means a change from 10 to ~8 wrong calls - a difference of 2 only. But a change from  Q=10 to Q=11 means 1000 to ~800 wrong calls: the difference is a substantial ~200 calls.</p>
  <p>Having said this, the straight average of phred scores is not &quot;wrong&quot;. It measures the overall phred score but it does not reflect the expected number of wrong calls, which is probably what you want in this case.</p>
  