# Determine the chances of blood group type and rhesus factor of unknown parent?

First of all, I'm not a biologist so my jargon might not exactly be common on this site. I'm a programmer and as a hobby project I try to make an algorithm that does two things:

• Determine the possible blood group and rhesus factor of a child based on the blood groups and rhesus factors of both parents.
• Determine the possible blood group and rhesus factor of an "unknown parent" based on the blood group and rhesus factors of the child and the known parent.

I found two great examples online, the "Child Blood Type Calculator" and the "Parent Blood Type Calculator" calculator on endmemo.com.

The first calculator shows some percentages of the chances. But the second calculator does only show a static answer when it comes to the blood group type and rhesus factor. According to the calculator that indicates that the rhesus factor of the "unknown parent" can only be negative when both the child and the known parent have a negative rhesus factor too.

In case the known parent and child have both RH+ the calculator shows that the unknown parent must have had RH+ as well. But isn't the statistical chance 6.25% that the unknown parent still have had RH- instead?

Secondly, how can I calculate the likelihood/chance that the unknown parent has a certain rhesus factor or blood group type? Now the calculator shows 'A/B/O' and 'RH+' when the child has 'O+' and the known parent has 'O+' but what are the chances the unknown parent has A, B or O or RH- anyway?

Side-note: I'm not related to endmemo.com.

• I see you know PHP, thus I believe you're gonna easily understand my answer explaining the problem with that site, if statements are pretty standard in most languages I'm aware of.
– user24284
May 24, 2017 at 2:09

Simple explanation: that "Blood Type Calculator" is wrong.

Inspecting the source code of that page we can find the if statement that chooses the outcome for the unknown parent, regarding the Rh factor. And it has a problem. Whoever knows JavaScript will understand the problem, but even people that don't know programming languages can follow this, it's not complicated. Let me explain it.

When you choose the Rh blood type in the dropdown menu, the Rh+ blood is associated to the value p and the Rh- blood is associated to the value n. Those are just strings, the programmer can chose any value he/she wants, that's not important, as you know. The variables that hold those values are msel2 for the known parent and csel2 for the child.

Now comes the if statement:

var frh = "+";
if (csel2 == "n" && msel2 == "n") frh = "-";


Let's break it down:

The default value that will be printed on the result, called frh, is + (positive), as you can see before the if statement. As already said, msel holds the value for the known parent, and csel holds the value for the child.

In the if statement, only if the user chooses the known parent type as Rh- (msel2 == "n") AND the child as Rh- as well (csel2 == "n"), the value of frh will be changed to - (the double && represents the AND). Any other combination will not change frh, which will remain +.

And that's plain wrong!

There is no need for me to explain you the genetics of Rh factor, there are plenty of resources online and answers here at Bio SE as well, but here is a summary:

Given that Rh+ individuals can be either DD or Dd, it's easy to show that the unknown parent can be Rh- in case that the known parent and the child have both Rh+:

(Known parent)     (Unknown parent)
D_ --------------- dd
|
|
Dd
(Child)


The lesson to learn here: don't trust everything you find online.

Correct algorithm:

For your second task ("Determine the possible blood group and rhesus factor of an "unknown parent" based on the blood group and rhesus factors of the child and the known parent."), let's see all possible cases:

• Known parent Rh+ and child Rh+: the unknown parent can be either Rh+ or Rh-.
• Known parent Rh+ and child Rh-: the unknown parent can be either Rh+ or Rh-.
• Known parent Rh- and child Rh-: the unknown parent can be either Rh+ or Rh-.
• Known parent Rh- and child Rh+: the unknown parent has to be Rh+.

As you can see, in only one case the unknown parent cannot be either Rh+ or Rh-. That being said, this is a possible solution:

var frh = "+/-";
if (csel2 == "p" && msel2 == "n") frh = "+";


What this snippet does is this:

It assigns the default value for the unknown parent (frh) as +/- (meaning that he/she can be Rh+ or Rh-, we can't know) for all possible combinations. However, if the mother is Rh- AND the child is Rh+, that value is changed for + (because, in that situation, the unknown parent has to be Rh+).

• Thanks a lot, you confirmed my thoughts on the wrong "calculator". The ABO group algorithm works like a charm already. But the one thing that I'm stuck with is the chances of Rh+ / Rh-. I get your "Correct algorithm" but does that mean it's always a 50/50 chance? I'd like to use percentages, just like the ABO group calculator in my example. I'm not sure if it's possible with the rhesus factor. Can it be more accurately determined in some cases? (For example: not 50/50 but 80/20)? May 24, 2017 at 7:21
• Nope, saying "+/-" doesn't mean 50/50, it means only that the unknown parent cannot be determined: he/she can be either + or -. To have a better estimation of the probabilities one has to know the frequencies of the alleles in the population, which is certainly out of the scope of such "calculator".
– user24284
May 24, 2017 at 7:31
• 1. so with child/known parent being +/+, +/- or -/- the chances of the unknown parent having either + or - are (because it's unknown, statistically 50%) in the three cases? Or can is be more "confident" in a certain combination? Cause a 50/50% estimation seems quite useless. The only useful thing to "predict" is the -/+ relation. 2. Is the outcome -/+ relation always 100% + or can (as a rare exception) the outcome be - anyhow? May 24, 2017 at 7:38
• I'll say the same thing I just said in the previous comment: it's not a 50/50 estimation. And it is not useless, as you said: eliminating some genotypes is very important in genetics.
– user24284
May 24, 2017 at 7:40
• No, it cannot be determined, unless you have all the allele frequencies in that population (as I said in my first comment) and assume some conditions, like random mating between the individuals for instance. Again, totally out of the scope of such calculator. If you want, you can post a new question like this: "How to determine the chances of the father being Rh+ or Rh- when the mother is Rh+ and the child is Rh-?", and see what people will answer.
– user24284
May 24, 2017 at 7:50