Creating measurement of tumor neighborhood

Hi everyone,

I am working with a TMA and have applied a detection classifier and an intensity threshold for “positivity”. Now I’m trying to restrict my analysis of the stromal cells on the areas within a certain radius r (e.g. 0.2 mm) around the tumor cells classified as such by the detection classifier.

I have read the procedure by Pete here, however this doesn’t seem to be practically applicable in TMAs with multiple annotations.

So I thought even though it might not be the most efficient way, creating a measurement about the neighborhood to tumor cells might be the easiest way to solve this.

I thought about looping through all the detections, creating an annotation (circle with radius r) around the centroid of each detection, then through the hierarchy determine if there are more than n tumor cells (e.g. n=4 in order to smooth as there might be single wrongly-allocated cells by the detection classifier), and creating a measurement for the detection indicating whether it is surrounded by at least n tumor cells within the radius r. (Then remove the annotation and cells with a “negative” measurement of the tumor-environment.

As I’m just new to coding I couldn’t yet manage to get a proper script for that process - especially the part of determining if there are more than n tumor cells within the created annotation.

I’d highly appreciate your ideas of whether this might work and how I could implement that into a script.
Thank you very much.

PS: I’m using v0.1.2 as I started my project here.

1 Like

Unfortunately, most of what I have done recently for cluster analysis has been focused on the newer versions of the software, and much of it crutches off of the new functionality.

There is a nearest neighbor script written around M5, but that would need to be adapted slightly for 1.2. You could give that a try.
https://gist.github.com/Svidro/68dd668af64ad91b2f76022015dd8a45#file-nearest-neighbors-by-class-groovy

That script is extremely slow on large object sets, but it would give you the number of cells of all other classes within X distance.

1 Like

Ah, and sorry, I didn’t remember exactly what that script did, so you would still have to use it somewhat creatively to get what you wanted. I did have a script somewhere that checked the local environment for cells nearby, but I’m not sure what happened to it.

In this case you might classify tumors with a “nearest stroma” below a threshold a certain way (positive?) and then cluster those. Maybe Delaunay would work in 1.2. Not sure.

Ah yes, now I remember, I ditched the slow script since I only had one class.


I think I ended up using Delaunay clusters Num Neighbors measurement, even though that wasn’t quite accurate.

1 Like