Skip to content

Instantly share code, notes, and snippets.

@Nereare
Created July 19, 2016 11:27
Show Gist options
  • Save Nereare/1c3483bf933fec121ae8768218d7af6c to your computer and use it in GitHub Desktop.
Save Nereare/1c3483bf933fec121ae8768218d7af6c to your computer and use it in GitHub Desktop.
Lymphocyte differential count, based on normal blood proportions. DO NOT USE FOR DIAGNOSTIC PURPOSES. Seek a physician!
# Gets the number of lymphocytes from the WBC count.
puts "Absolute LYMPHOCYTE count:"
$lymph = gets.to_i
puts "Relative lymphocyte proportion:"
$lym_prop = gets.to_f / 100.0
puts ""
# Limits of absolute normality
$min_lim = 900
$top_lim = 3400
if $lymph < $min_lim
puts "Absolute lymphopenia!"
else
if $lymph > $top_lim
puts "Absolute lymphocitosis!"
else
puts "Lymphocytes under normal absolute range."
end
end
#Limits of relative normality
$min_lim = 0.48
$top_lim = 0.56
if $lym_prop < $min_lim
puts "Relative lymphopenia!"
else
if $lym_prop > $top_lim
puts "Relative lymphocytosis!"
else
puts "Lymphocytes under normal relative range."
end
end
# Calculates differential lymphcyte count from ranges of normality.
# Font: https://en.wikipedia.org/wiki/Lymphocyte#Characteristics
# NK Cell proportions
$nk_med = 0.07
$nk_min = 0.02
$nk_max = 0.13
# Th Cell proportions (Including CD4)
$th_med = 0.46
$th_min = 0.28
$th_max = 0.59
# Tct Cell proportions
$tc_med = 0.19
$tc_min = 0.13
$tc_max = 0.32
# B Cell proportions
$bc_med = 0.23
$bc_min = 0.18
$bc_max = 0.47
$nk = "NK Cells = " + ($lymph * $nk_med).round.to_s + " (" + ($lymph * $nk_min).round.to_s + "-" + ($lymph * $nk_max).round.to_s + ")"
$th = "Th Lymph. = " + ($lymph * $th_med).round.to_s + " (" + ($lymph * $th_min).round.to_s + "-" + ($lymph * $th_max).round.to_s + ")*"
$tc = "T Citotoxic Cells = " + ($lymph + $tc_med).round.to_s + " (" + ($lymph * $tc_min).round.to_s + "-" + ($lymph * $tc_max).round.to_s + ")"
$bc = "B Lymph. = " + ($lymph * $bc_med).round.to_s + " (" + ($lymph * $bc_min).round.to_s + "-" + ($lymph * $bc_max).round.to_s + ")"
puts ""
puts "Estimated differential lymphocyte count:"
puts $nk
puts $th
puts $tc
puts $bc
puts ""
puts "* Includes CD4+ count."
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment