Module: ViralSeq::Math

Defined in:
lib/viral_seq/math.rb

Overview

math functions reqruied for ViralSeq

Defined Under Namespace

Classes: BinomCI, PoissonDist, RandomGaussian

Class Method Summary collapse

Class Method Details

.calculate_pid_cut_off(m, error_rate = 0.02) ⇒ Integer

A function to calcuate cut-off for offspring primer IDs.

Parameters:

  • m (Integer)

    PID abundance

  • error_rate (Float) (defaults to: 0.02)

    estimated platform error rate, the model supports error rate from 0.003 to 0.03.

Returns:

  • (Integer)

    an abundance cut-off (Integer) for offspring Primer IDs.

See Also:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/viral_seq/math.rb', line 125

def self.calculate_pid_cut_off(m, error_rate = 0.02)
  if m <= 10
    return 2
  end
  n = 0
  case error_rate
  when 0...0.0075
    n = -9.59*10**-27*m**6 + 3.27*10**-21*m**5 - 3.05*10**-16*m**4 + 1.2*10**-11*m**3 - 2.19*10**-7*m**2 + 0.004044*m + 2.273
  when 0.0075...0.015
    n = 1.09*10**-26*m**6 + 7.82*10**-22*m**5 - 1.93*10**-16*m**4 + 1.01*10**-11*m**3 - 2.31*10**-7*m**2 + 0.00645*m + 2.872
  when 0.015..0.03
    if m <= 8500
      n = -1.24*10**-21*m**6 + 3.53*10**-17*m**5 - 3.90*10**-13*m**4 + 2.12*10**-9*m**3 - 6.06*10**-6*m**2 + 1.80*10**-2*m + 3.15
    else
      n = 0.0079 * m + 9.4869
    end
  else
    raise ArgumentError.new('Error_rate has be between 0 to 0.03')
  end
  n = n.round
  n = 2 if n < 3
  return n
end