Workflow in fluorescent images, score cells after classifier

560 views
Skip to first unread message

Renaud

unread,
Aug 4, 2018, 6:59:51 PM8/4/18
to QuPath users
Hi,

I have what seem to be a simple problem... I am using fluorescent slide scans with 4 channels.
Channel 1: Dapi
Channel 2: GFP
Channel 4: Ki67

Essentially, I want to count the number of Ki67 positive cells (based on "Channel 4 mean") after having classified cells in the GFP+ or GFP- class... But I can't find how to do it best within QuPath.

I have successfully done the following:
- drawn an annotation
- found nuclei/cells using Analyze>Cell analysis>Cell Detection
- did a classifier using mix of Channel 1 and Channel 2, saved it, and applied it

But I get stuck here. Now if I want to score Ki67+ cells in both classes (GFP+/-), and get a summary table of number (and/or % of Ki67+ cells) per class, what would be the best way?
Also in other cases I would be interested in scoring cells according to various intensities (1,2,3 for example). I could export the results here and do the classification from the single cell data, in R for example, but I guess there is a way of doing it in a more visual manner within QuPath but I cannot find the best approach... despite several attempts.

Any help would be greatly appreciated!

Many thanks


micros...@gmail.com

unread,
Aug 5, 2018, 3:05:52 AM8/5/18
to QuPath users
Have you tried running setCellIntensityClassifications("4th channel mean", threshold) after performing your first classification?  I think it is supposed to sub-classify any already existing classes as positive or negative.  You can see a bit more here: https://petebankhead.github.io/qupath/tips/2018/03/22/setting-positive.html


Similarly, if you want to do 2 or 3 thresholds, you can add multiple thresholds after.  Though I think by default it only goes up to 3 thresholds.  Somewhere around here there is a thread showing how to create more.

Renaud

unread,
Aug 5, 2018, 6:44:05 PM8/5/18
to QuPath users
Many thanks for the blog post... missed that one. I have also found more info here later on https://github.com/qupath/qupath/wiki/Spot-detection#classifying-positive-cells-easy which I had also missed in my reading before!
Just an idea for Pete maybe: this could be a section on its own in the wiki with a more explicit name such as "cell scoring" as it is a major step for phenotyping tissues... I thought the "spot detection" would have only referred to signals such as FISH/foci/RNAscope...

micros...@gmail.com

unread,
Aug 5, 2018, 7:37:39 PM8/5/18
to QuPath users
Yes, I happen to really like subcellular detections.  It is far more accurate, in many cases, than "cytoplasmic means" since the cytoplasm does not really trace the outline of the cell.  And in addition, you can reclassify annotations and other regions as "cells" in order to use subcellular detections within them.
You may also find: https://github.com/qupath/qupath/issues/119 interesting if you want subcellular localization. Sort of.

micros...@gmail.com

unread,
Aug 5, 2018, 7:38:57 PM8/5/18
to QuPath users
Oh, nevermind, that is in the wiki too!

Pete

unread,
Aug 6, 2018, 4:44:16 AM8/6/18
to QuPath users
Just an idea for Pete maybe: this could be a section on its own in the wiki with a more explicit name such as "cell scoring" as it is a major step for phenotyping tissues... I thought the "spot detection" would have only referred to signals such as FISH/foci/RNAscope...

Thanks, - good point. For now I've added a reference in the intensity-related part of https://github.com/qupath/qupath/wiki/Classifying-objects

Renaud

unread,
Aug 8, 2018, 9:37:13 AM8/8/18
to QuPath users
I have played a bit with the setCellIntensityClassifications command and it's really useful. Will it be integrated in the following QuPath version as part of an integrated module rather than through a script?

I have also 2 more questions:
  • If I set 3 thresholds, and go to see the annotation measurement summary, I get the total number of cells, total number of 1+, 2+, 3+ cells, an H-score etc.... which are great. But then there is % positive which is basically the % of "any positive", but it doesn't display the % of 1+, 2+, 3+. It's obviously trivial to calculate separately if needed.
    But I was wondering if there was a reason why it wasn't displayed in the table? or am I doing something wrong?
  • What would be the best way of looking at colocalisation within QuPath? and possibly getting summary data within the annotation summary table.
    In this case I would only look at positive vs negative cells. But I would be interested in getting informations about the number of, for example: double positives, single positives, double negative, for say "channel 2 cytoplasmic mean" and "channel 4 nucleus mean"
    A more specific application of this would be to count the number of positive cells for a nuclear marker in different cell lineages, which are stained with a membrane/cytoplasmic stain. 1 channel defines lineage A, the other channel lineage B, and the third is the nuclear marker. I need % of positives in each lineage. I guess I could use a classifier on the lineages and then count positives? but maybe there is already a way of looking at colocalisation? which wouldn't rely on cell classification as I am already using a classifier to distinguish epithelium vs stroma.


Pete

unread,
Aug 8, 2018, 9:47:29 AM8/8/18
to QuPath users
I have played a bit with the setCellIntensityClassifications command and it's really useful. Will it be integrated in the following QuPath version as part of an integrated module rather than through a script?

I want to say the answer to that is 'yes'... I haven't done it yet, but I think it would be important.  I need to think some more about the implementation, and whether it can/should be combined with some of the considerations below...

If I set 3 thresholds, and go to see the annotation measurement summary, I get the total number of cells, total number of 1+, 2+, 3+ cells, an H-score etc.... which are great. But then there is % positive which is basically the % of "any positive", but it doesn't display the % of 1+, 2+, 3+. It's obviously trivial to calculate separately if needed.
But I was wondering if there was a reason why it wasn't displayed in the table? or am I doing something wrong?

I don't think you're doing anything wrong - it is really just that the number of columns could become pretty huge pretty quickly, and it was a matter of trying to only have the key measurements displayed automatically.  As you say, the others can be calculated pretty easily.
 
There isn't a general mechanism for selecting which columns you do/don't want, and for now QuPath makes those decisions for you.  Of course that's only more convenient when it matches what you wanted...


What would be the best way of looking at colocalisation within QuPath? and possibly getting summary data within the annotation summary table.
In this case I would only look at positive vs negative cells. But I would be interested in getting informations about the number of, for example: double positives, single positives, double negative, for say "channel 2 cytoplasmic mean" and "channel 4 nucleus mean"
A more specific application of this would be to count the number of positive cells for a nuclear marker in different cell lineages, which are stained with a membrane/cytoplasmic stain. 1 channel defines lineage A, the other channel lineage B, and the third is the nuclear marker. I need % of positives in each lineage. I guess I could use a classifier on the lineages and then count positives? but maybe there is already a way of looking at colocalisation? which wouldn't rely on cell classification as I am already using a classifier to distinguish epithelium vs stroma.

I've written a two-part blog post on that very subject this week, starting here: https://petebankhead.github.io/qupath/tips/2018/08/06/multichannel-fluorescence.html

Basically, I think it should be a fairly small change to make it possible - but also somewhat far-reaching.  So it's a change I'd like to get right, and therefore would welcome any feedback / requests for how exactly that should look.

Renaud

unread,
Aug 8, 2018, 10:10:54 AM8/8/18
to QuPath users
Thanks a lot for the reply. I should have checked the blog! I will definitely spend some time on this and come back to you about it.

micros...@gmail.com

unread,
Aug 8, 2018, 11:05:48 AM8/8/18
to QuPath users
What I would probably do in that case is create a new measurement per cell called "tissue" and assign it either a 1 or a 0 depending on whether it was tumor or stroma.  Then in the classification later (I usually do manual scripting for thresholds) I would use that value to determine whether the final class was "Tumor Lineage A Positive."  Or I suppose you could simplify the script and just handle the Tumor/Lineage parts manually, then use setCellIntensityClassifications for the Positive/Negative across all classes.

If you are willing to take the time to script, you can get as complicated with your if-then classifications as you want.  There are a few more scripts in each location showing classification options and measurement creation options.

micros...@gmail.com

unread,
Aug 8, 2018, 11:07:11 AM8/8/18
to QuPath users
Ack, I should have specified, in the first line, the create new measurement is after your first classifier (tumor vs stroma)... and after you assign that tissue measurement, you can wipe the classifications and start over.

Renaud

unread,
Aug 9, 2018, 1:39:23 PM8/9/18
to QuPath users
Great! Many thanks for all your answers! It's great to be able to get so much support.
My scripting abilities in groovy are fairly null for now, but as I start using already written scripts, it will eventually get better, hopefully :)

I was actually trying to set up a workflow to batch process several images with the same settings. I have built and saved a classifier which I would like to use when processing all slides of a project. But when I do classify>load classifier, this doesn't get recorded in the "command history". Therefore I have no idea how to "call/import" the appropriate classifier in the script after the "cell detection" step. Do you know what line of code would do this?

Pete

unread,
Aug 9, 2018, 1:44:18 PM8/9/18
to QuPath users
Good!

The classifier gets recorded at the saving stage, not the loading stage (maybe it should be both...)
Anyway the command looks like this:

runClassifier('C:\\some\\classifier');

For batch processing, the supplementary material for https://www.nature.com/articles/s41598-017-17204-5 could be useful - it has the scripts I used.
Reply all
Reply to author
Forward
0 new messages