Derived classes Stroma:positive

417 views
Skip to first unread message

dnka...@gmail.com

unread,
Jan 26, 2017, 10:19:11 AM1/26/17
to QuPath users
Hi
I am trying to analyses a IHC differentiating the positive counts in tumor and stroma. Unfortunately QuPath only shows the positive counts for the tumor. Is there a way to export/display the values for stroma too?

Cheers Daniel

Pete

unread,
Jan 26, 2017, 4:14:11 PM1/26/17
to QuPath users
Hi Daniel,

I also needed this functionality myself a few times.
I'm afraid it requires writing a script, but it should be easier now with v0.1.2, since I added a setCellIntensityClassifications method.  Using this, you should only need one line.

If you replace 'Subcellular: DAB: Num spots estimated' with the name of the measurement you want to use, and add your threshold/thresholds after the comma, then this should classify all detections - not only those classified as tumor.

Prior to that, a more complicated script was needed.  If you download the supplementary material from the preprint at http://biorxiv.org/content/early/2017/01/12/099796 then look for the script called 'PDL1_classify_and_export.groovy'.  This shows the old method I used... but hopefully you won't need it, if 'setCellIntensityClassifications' works for you.

Pete

dnka...@gmail.com

unread,
Jan 27, 2017, 3:43:05 AM1/27/17
to QuPath users
Hi Pete,

thanks it worked perfectly with the easy way ;)

setCellIntensityClassifications("Cell: DAB OD mean", 0.2)

Just a minor follow up question is it possible to set the colors for positive and negative counts. For Tumor it uses red and blue, for the other classes it uses a light and dark version of the original color.
I think this is fine specially if you compare multiple classes, but if you compare only two it would be straight forward to use 4 (class1 pos/neg, class2 pos/neg) distinct colors.

Cheers
Daniel

Pete

unread,
Jan 27, 2017, 1:40:30 PM1/27/17
to QuPath users
Hi Daniel,

Great!

A script can also be used to change the colors... although it's questionable whether it counts as an easy way or not.

This should do it:

getDerivedPathClass(getPathClass('Stroma'), 'Positive').setColor(qupath.lib.common.ColorTools.makeRGB(200, 50, 120))
getDerivedPathClass(getPathClass('Stroma'), 'Negative').setColor(qupath.lib.common.ColorTools.makeRGB(50, 150, 200))
setCellIntensityClassifications("Cell: DAB OD mean", 0.2)

The 3 numbers inside 'makeRGB(r, g, b)' give the red, green and blue components of the colors that will be used.

As you may already have seen, you can change the main color for any classification quite easily by double-clicking on the classification under the 'Annotations' tab.  But the script above is the best way I can think of for handling the colors of 'derived' classes, for which QuPath tries to give something reasonable that won't clash automatically (i.e. darker or lighter, as you describe) but doesn't display them in this list.

Pete

Karin Kühne

unread,
Apr 12, 2017, 5:36:51 AM4/12/17
to QuPath users
Hi

I have an additional question. Do you at first classifiy the sample in tumor and stroma cells with the help of the classifier? I've tried it that way but by using the setcellintensityclassifications advise afterwards it deletes all the previous informations (e.g. classification of tumor 1+,2+,3+, stroma cells and H-Score) How can I fix this problem?
Thanks a lot for all advises!

micros...@gmail.com

unread,
Apr 12, 2017, 6:29:06 PM4/12/17
to QuPath users
Hmm, it does delete the H-Score for me, but it does not remove the tumor/stroma setting, instead it shows Class Stroma: Negative, etc.

I think to create a second entire population of positives and negatives, you would need to get into some scripting and create new variables.  These would also may not show up well in the Annotation measurements, so you would probably need to handle the data primarily externally to QuPath, say in R. 

For example, here I created a script that added a "CellType" variable with a 1 or 0 value to all of the subcellular detections.  You could use something similar to loop through the cells and check the value of some number of variables, and then apply a new variable depending on what you are checking.

-------

def clusters = getObjects({p -> p.class == qupath.imagej.detect.cells.SubcellularDetection.SubcellularObject.class})

// Loop through all clusters
for (c in clusters) {
    // Find the containing cell
    def cell = c.getParent()
    def cellClass = cell.getPathClass()
    def cellname = cell.getPathClass().getName()
    //cellType will be 0 in all cases except when the containing cell is dual positive, then it will be set to 1 by the if statement
    def cellType = 0  
    if (["Dual Positive"].contains(cellname)) {
        cellType=1
    } 
    def ml = c.getMeasurementList()
    ml.putMeasurement("CellType", cellType)
    ml.closeList()
    }
    fireHierarchyUpdate

Pete

unread,
Apr 13, 2017, 12:18:11 AM4/13/17
to QuPath users
Hi,
You will need exactly 3 thresholds to be able to get H-scores (from negative, 1+, 2+ and 3+ cells) - with a single threshold, QuPath can only give positive/negative.

You can include 3 thresholds in the script, e.g.

setCellIntensityClassifications("Nucleus: DAB OD mean", 0.2, 0.4, 0.6)

If you have already run a classifier to distinguish tumor/stroma, then the tumor/stroma distinction should stay after you run this line.  But if you have already classified the tumor cells according to intensity, the intensity part will be 'overwritten' with the new threshold values (in my example 0.2, 0.4 and 0.6) which may or may not be the same.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages