TITLE: QuPath Immunofluorescence Cell Detection and Co-localization Protocol
AUTHORS: Patricia Lumanto, Diana Nakib, Xinle Wang, Sonya Macparland

[DESCRIPTION]
QuPath is an open-source imaging software that provides a user-friendly platform for digital pathology and whole slide image analysis. This protocol aims to provide a step-by step introduction to optimizing and running total cell detection and positive cell detection on QuPath for Immunofluorescence (IF) images. The protocol offers the possibility of assessing stain localization and co-localization within the liver immune environment and can be further applied to other tissues. Positive cell detection allows for the quantification of marker-specific positive cells across the tissue sample, and stain co-localization allows for the characterization of cells that are positive for two markers of interest, representing specific cell-cell interaction within the tissue sample, both providing a better understanding of the liver microenvironment. 

This protocol was used to quantify and characterize the localization of different liver immune cell subpopulations (presence of liver sinusoidal endothelial cells, Kupffer cells, cholangiocytes, and bipotent hepatocytes) as seen in Andrews & Nakib et al. (J Hepatol 2024 doi:10.1016/j.jhep.2023.12.023).



[STEPS]
SECTION: Image Brightness and Contrast Adjustment
1. Click on File: Project to start a project.
Note: a project must be created in order for annotations and measurements to be exported.
Tip: prepare an empty folder with an appropriate folder name prior to starting the project.
SECTION: Image Brightness and Contrast Adjustment
2. Import the desired image by clicking on File: Open.
Note: scanned image files (e.g. .czi, .tiff) may take up quite a bit of space on your internal memory, make sure sufficient space is available on your local drive.
SECTION: Image Brightness and Contrast Adjustment
4. Double click on any channel to change its name and color. 
Note: the original scan colors are not permanent and can be changed to make visualization easier.
Tip: complementary colors (e.g. red and green, yellow and purple) will be easiest to distinguish for visualization.
 
SECTION: Region of Interest Selection and Annotation
6. Use rectangle tool to select region of interest.
SECTION: Region of Interest Selection and Annotation
7. Rotate the rectangle by using the transform tool (Objects: Annotations: Transform annotations).
SECTION: Region of Interest Selection and Annotation
8. Select the rectangle and run the following script (Automate: Show script editor).
Note: if lengthwise sections are preferred, change "d1 < d2" to "d1 > d2" (on line 45 of the script).
Tip: change the name for each region of interest by changing the ROI number ("ROI 1 Layer ${i+1}") on the last line of the script.

 


 
SECTION: Region of Interest Selection and Annotation
9. Rename Annotations by right clicking on the selected layer then select Set properties.
 
2. 
SECTION: Positive Cell Detection and Measurements
10. Select the region (largest rectangle) and click on Analyze: Cell detection: Positive Cell Detection.
SECTION: Positive Cell Detection and Measurements
10.1. Select the desired stain for cell detection by clicking on the drop down menu next to Detection channel.
SECTION: Positive Cell Detection and Measurements
10.2. Modify the Threshold value such that all positive cells are accounted for. 
Note: a threshold of 300-400 would be ideal for a DAPI nuclei stain.
SECTION: Positive Cell Detection and Measurements
10.3. Change the Score compartment by clicking on the dropdown menu next to it such that the stain selected matches its localization within the cell.
Note: it is easier to adjust the threshold when stain localization is known (e.g. Nucleus: DAPI max)
Tip: if unsure about stain localization, select the cell option for easiest detection.
 
SECTION: Positive Cell Detection and Measurements
11. Click Run to start positive cell detection.
Keep adjusting the Threshold value until the correct cells are detected.
Note: it may take several adjustments to optimize the threshold value, zoom in and our of the image, if necessary, to help determine appropriate detection.
Repeat for other regions
SECTION: File Export
18. Click on Measurements: Export measurements to export data into a tsv file.
Click on export annotations.
Click on browse to select a name and file path for the export.
Note: the generated tsv file can be opened on spreadsheet programs such as Microsoft Excel and copied to data analyzing softwares.
SECTION: Cell Detection and Co-localization
12. Select the annotation and run cell detection by clicking Analyze: Cell detection: Cell detection.
SECTION: Cell Detection and Co-localization
12.1. Select the desired stain for cell detection by clicking on the drop down menu next to Detection channel.
SECTION: Cell Detection and Co-localization
12.2. Modify the Threshold value such that all positive cells are accounted for. 
Note: a threshold of 300-400 would be ideal for a DAPI nuclei stain.
SECTION: Cell Detection and Co-localization
12.4. If only cell detection or cell count is required, skip steps 12 to 16 and move forward with the file export. 
If co-localization assessment is required proceed to step 12.
SECTION: Cell Detection and Co-localization
13. Create new classes by going to Annotations, and right clicking on the class list to add a new class.
Tip: creating classes for both positive and negative cells makes classification easier (e.g. HNF4A and non-HNF4A).
 

13. 
SECTION: Cell Detection and Co-localization
14. Create cell classifications by clicking Classify: Object classification: Create single measurement classifier.
SECTION: Cell Detection and Co-localization
14.1. Select the desired channel filter (e.g. DAPI, AF647) by clicking on the dropdown menu next to Object filter.
SECTION: Cell Detection and Co-localization
14.2. Adjust the Threshold using the slider.
Note: turn on live preview for better visualization.
SECTION: Cell Detection and Co-localization
14.3. Save the classifier using the stain name.
 
SECTION: Cell Detection and Co-localization
15. Select the region of interest (previously selected using the rectangle tool).
SECTION: Cell Detection and Co-localization
16. Classify object by clicking Classify: Object classification: Load object classifier.
SECTION: Cell Detection and Co-localization
17. Apply object classification by clicking on the name of each classifier then clicking Apply classifier.
Tip: To apply more than one classifier to the same region select both using the command or control key and click Apply classifier sequentially.
 
SECTION: Image Brightness and Contrast Adjustment
5. Adjust the brightness and contrast of the image by changing the min and max display values using the slider.
Note: The default gamma value is 1.
Tip: Refer to IHC experiments (e.g. from The Human Protein Atlas) to help visualize expected stain localization and intensity. 
 

SECTION: Cell Detection and Co-localization
12.3. Change the Score compartment by clicking on the dropdown menu next to it such that the stain selected matches its localization within the cell.
Note: it is easier to adjust the threshold when stain localization is known (e.g. Nucleus: DAPI max)
Tip: if unsure about stain localization, select the cell option for easiest detection.
 
SECTION: Image Brightness and Contrast Adjustment
3. Select View: Brightness/Contrast
Select the desired channels for visualization (e.g. DAPI, AF568)