Lesson 2 of 20

Infiltration rate — what do you divide by what?

one denominator, and the ranking changes

Infiltration rate — what do you divide by what?
Counting the red cells is easy. The hard part is deciding what to divide them by.

Counting the red cells in a map takes one line.

til_px = (code == 2).sum()

But you cannot use that number as it stands. Slides come in different sizes — one map is 250,000 cells, another is 20,000. You need a rate before you can compare. And the problem is the denominator.

CandidateFormulaDoes it make sense?
the whole gridred ÷ (width × height)puts bare glass into the denominator
tissue tilesred ÷ (blue + red)counts only where a lymphocyte could be
tumour region onlyred ÷ tumour tilesthe most correct thing to say — but there is no tumour boundary in this data
Same map, same red cells. And yet the numbers are 45.66% and 8.43%.
Python Runs in your browser

"The value changes" you might shrug at. What is serious is when the ranking changes. Because slides differ in how much of the grid their tissue fills, switching the denominator lifts some slides and lowers others.

Measure four slides both ways and the ranking really does flip — by tissue, 44-2668 (45.7%) sits far above BR-8483 (15.9%); by grid it is 8.43% against 8.74% and they swap places.
Python Runs in your browser
Switch the denominator. A bar turns amber when that slide changed places.
Loading…

The third candidate — dividing by the tumour region only — is in fact the most correct thing to do pathologically. A lymphocyte that got inside the tumour and one that was always sitting in the normal tissue next door mean different things.

But this map does not say where the tumour is. Producing that information would need another model that segments tumour regions, and the public data does not have one.

So the infiltration rate we use is "relative to all tissue". That is a limitation, and it follows every result from here on. Do not forget it.

🤔 Check yourself
Why use 'tissue tiles' as the denominator of the infiltration rate?
🤔 Check yourself
What is the worst thing about switching the denominator to 'the whole grid'?