DAB positive cell in different compartments

Dear All,

I am totally new in image analysis and I got few recommendations regarding qupath software for IHC analysis.
I have to quantify CD4, CD8, CD3, CD68 and CD163 positive cells in 20 tumour slides in stromal and tumoral compartments.
I was thinking to take several pictures of each tumor slide for each marker and quantify DAB positive cells in both compartments that I would have previously defined by training (machine learning based method.
As I have only one week for performing those analyses (short time!), I’ve prefered asking qupath community for getting the different steps I should do to get those cell quantifications.

I’ve attached 2 pictures of 2 tumors slides stained with CD163 antibody. Sorry for my basic questions,
I am pretty sure many people did this job! Many thanks for your help

CD163_004_x20-3.tif (6.7 MB) CD163_007_x20-2.tif (6.7 MB)

The first thing I would recommend would be to get your pixel size metadata figured out :slight_smile:
Big cells is not what people usually mean by “big data.” This can be accomplished either by using the original file format for the images (if they were taken as CZI, LIF, etc), or by adding the metadata back in in FIJI. More info here: https://imagej.nih.gov/ij/docs/menus/image.html#properties

Depending on which version of QuPath you are using, some scripts may not work, so I will shy away from that right now, but it is possible to edit the metadata temporarily in a given image with a script. I took a guess that this was taken with a 10x-20x, which usually has a pixel size of around 0.25-0.5 (not usually exact), which gave something more like:

After that it is mostly up to you to play around with the cell detection settings until you are happy with the results. If you have not yet, I recommend Pete’s IHC tutorial. At least running through the first few videos should help a lot.

Heatmap of DAB staining in your first image.
Some problems you might run into with your images:

  1. There is some odd, very green staining in some locations. This translates into a very strong, but incorrect, hematoxylin signal.
  2. Your tumor cells have large empty (non-hematoxylin stained) areas in the middle. That makes them very difficult to pick up with QuPath’s cell detection. If you only need density (CD163/mm^2), then you can safely ignore missed tumor cells. But if you are going for a percentage positive, this could be a problem.
  3. CD4, CD8, etc run into problems where you frequently cannot see the nucleus. That means you have to play some work-aroundy games with the cell detection. Normally I prefer to use hematoxylin to detect the nuclei, but you may be better off using OD Sum with markers that obscure the nucleus, and treat the nucleus as the whole cell.
    Give it a shot and feel free to ask more specific questions once you do.
1 Like

Thanks for your help!
I tried to get pixel size (slide 1) but how should i use this information in qupath ?

I’ve been trough Pete’s tutorial and tried to annotate stromal and tumoral areas for a pic (slide 2). i then identified positive DAB immune cells in stromal and tumoral compartments. The thing is I am interested in getting a percentage of immune positive cells in both compartments. I could also be interested in getting a density of positive cells in each compartment. however, as the positive cell density is heterogeneous in different areas of the tumor, I wanted to quantify positive DAB cells in both compartments in several pics for each tumor (representing 10 to 15 stromal and tumoral areas) in order to get a value which is more representative of the truth (and with statistics). But, it’s really time consuming and I was thinking to use machine learning options of qupath. What do you think about it ? Can I use it for this purpose? How?
Thanks again for your reply!
questions.pdf (324.6 KB)

The best option is not to use the pixel size information in QuPath, but to fix the original file, as described above. Your PDF shows the correct place to edit the data, but you would need the correct original measurement.

If you want to deal with heterogeneity, you would probably be better off analyzing the whole tissue. QuPath was, in large part, designed to handle whole slide images for this reason.

You could use machine learning to determine positivity, but it seems more likely that a single DAB threshold would be most accurate. You can select this most easily using the Measure->Show Measurement Maps dialog (image shown in previous post). There are various ways of generating a single DAB threshold, though, and which one works best will depend on the project and how the cells are generated. Once you have a single threshold, you should be able to use Positive cell detection to determine some basic statistics.

Note issues with cytoplasmic staining here.

Thanks for your quick answer!
My scanned slides are in .ndpi format because we used nanozoomer hamamatsu. What kind of pic format can handle qupath ?
The only problem regarding analysing the whole slide would be to differentiate immune cells presence within the stroma and within the tumor areas. How would you suggest me to do without machine learning ?

NDPI whole slide should be fine. You don’t even need BioFormats, and the pixel metadata should be included by default.

If you can distinguish the areas by eye (hopefully you can since you are picking small areas for analysis!), you can draw the annotations and classify them as tumor or stroma. The resulting annotation information will be labeled as those types.

For whole project export, see here and here.

I can distinguish the areas by eye only for x20 pics!
unfortunately, I’s going to be too time-consuming if I have to make it on the whole scanned slide …

Loading the NDPI file into QuPath will also give you the pixel size information, possibly. But only if you are exporting the individual fields of view at the base resolution of the image, and in a consistent manner. Otherwise the original pixel size isn’t useful, only the adjusted pixel size.

And you don’t have to use the whole slide, you can use the Rectangle annotation tool to generate small areas. Or the Tiling menu to tile the entire image, and then select random tiles to use for processing. You may also be able to determine whether these tiles are largely tumor or stroma using a classifier, but that is project dependent and it could go badly so many different ways with just a quick description of how :slight_smile:

Looks interesting ! I can not download my .ndpi files into qupath (size from 100 Mb to 2 Gb). Should I use any addition option to import those files ?

Size shouldn’t really be a problem. The Nanozoomer we have is fairly old, it might be that newer versions have adjusted the file format such that they don’t work with Openslide. You could check the View->Show log to see if there is any sort of error message. Better yet, make sure you have the BioFormats extension added, which should also open the NDPI files.

Thanks for your help!
I’ve optimized parameters on a small area and identified positive and negative cells in a bigger area. Then, I’ve used classifiers to identifiy stroma and tumor in this area. How could I identify positive cells in both compartments, stroma and tumor? Should I use the classifiers? (pdf in attached file)

questions.pdf (1001.1 KB)

It sounds like you want derived classes, which are described near the bottom of the page here:

You will probably want to use your tumor/stroma classifier, then apply your threshold to a setCellIntensityClassifications() script to create the derived classes.

More information and a point to its use in the Spot Detection wiki here:

Here’s a blog post describing how to (sub)classify cells as positive or negative:

If you use those steps after having classified cells as tumor or stroma then you should get a subclassification (retaining the tumor/stroma info as the main classification).

1 Like

I tried to use a direct command after classifying stroma and tumor :
setCellIntensityClassifications(“Cell: DAB OD max”, 0.1)
but when i looked at results, most of DAB positive cell were not positive, even with a low threshold (0.1) diapo 4 of my pdf in the attached slide
How can I improve this result ? Otherwise it gives me false positive rates!

questions.pdf (2.0 MB)

The max cell value is easily influenced by outliers and even slight errors in cell boundary (causing overlaps with neighboring cells).

I’d suggest trying differentt measurements, and perhaps a lower cell expansion (or even scoring based on [what QuPath detects as] the ‘nucleus’).

The tutorial videos may also help: https://github.com/qupath/qupath/wiki/Video-tutorials

Thanks Pete for the fast reply!
Do you suggest to use nucleus staining even if the staining should be either membranous or cytoplasmic?

Yes, the main thing is to choose the compartment where you see most of the intensity in QuPath:

  • the nucleus [inner polygon]
  • cytoplasm [outer ring]
  • cell [outer polygon]

It can be best to ignore what QuPath calls the compartment. For example, CD3/CD8 I would typically score based on nucleus - since actually the detected ‘nucleus’ really covered the main region where the DAB was seen. What QuPath called the ‘cytoplasm’ was probably outside the cell entirely, since it was based only on expanding the nucleus by a fixed difference.

(Although I should probably say I’ve also seen CD3/CD8 images where the staining looked different and I might have chosen a different compartment.)

1 Like

great! thanks so much for your clear reply

Thanks Pete for your answer!
I’ve followed your advice regarding CD3/CD8 scores. I’ve tried to quantify CD68 and CD163 by scoring based on nucleus compartment as well. However, as I was expecting CD163 positive cells quantity would be inferior to CD68 postive cells quantity in all tumors, I got discrepancies for few of them. I am now thinking that I might not have chosen the best method to quantify them and am wondering how to improve it. Any clues ?! Thanks

Examples_staining.pdf (1.6 MB)

CD163 and other macrophage markers are very difficult to accurately quantify in terms of cell counts (maybe with IF? but I almost never see any IF macrophage stains, not sure why). You are best off sticking to relative values between samples, not comparing counts between markers. The morphology is very… nonstandard? for a cell, and you could end up with multiple extensions of the same macrophage in the narrow slice of your imaged tissue. Or see a nucleus. Or no nucleus.

Your first images looked a lot more distinct, but you can see lots of very thin and wavey staining in the more recent images, which is going to be problematic.
It looks like you have two different staining patterns in the first image, as well. The central cells with large nuclei and light staining, and the stromal cells with very dark staining.

Based on the pictures, I would also say the background looks a bit dark, so make sure you have been very careful about setting your color vectors.

You may want to look more at total stained area using a positive pixel count, or something similar.