Tutorial for QuST: QuPath Extension for Integrative Whole Slide Image and Spatial Transcriptomics Analysis
- Prerequisites
- Creating a New QuPath Project
- Image Registration
- Sample Preparation
- Tissue and Nucleus Segmentation
- Loading Xenium Annotations
- Generating Dataset
- Applying a Trained Model
- Running DBSCAN-CellX
- Conclusion
- The images you wish to analyze (Xenium as well as H&E)
- A folder containing the transcriptomic information for each Xenium image
- Annotations for each Xenium data (.csv file)
Create a new QuPath project. If you have any issues creating a project, feel free to reference this tutorial.
Image alignment and Xenium single cell data loading can be found Here.
- Download
tiss_nucl_dtxn.groovy
to your project directory. - Go to
Automate
-->Script Editor
-->File
-->Open
and selecttiss_nucl_dtxn.groovy
and run it. Do this for each image in your project (Xenium and H&E). - If the tissue selection is unsatisfactory, you can look at the commands in the script and perform the corresponding GUI operations manually, specifically playing around with the
232
threshold value for Pete’s Simple Tissue Detection until the annotation is satisfactory.
For each of the Xenium images, perform the following steps:
- Click
Extensions
-->QuST analysis toolbox
-->10X Xenium Annotation
. - Select the Xenium directory for the image you are working on and click
Run
. - Under
Annotations
, select a class and right-click toPopulate from Existing Objects
. - Save the annotation file you want to use to your project directory. Go to
Automate
-->Script Editor
-->File
--> andOpen
that file. - In this script, be sure to comment/uncomment the appropriate filepaths in lines 14-16. Then click
Run
.
Once this has run, adjust the classes by performing the following:
- Choose
No
toKeep existing available classes
. - Select all the remaining classes that are labeled with numbers, right-click and
Select objects by classification
and then clickDelete
. - Highlight the numerical classes again and
Populate from existing objects
-->All classes
.
- Go to
Measure
-->Show Detection Measurements
-->Save
, and save the subsequent file within your project folder as the name of the sample you’re working on (e.g.,C83377.txt
). This is a CSV file where each row represents a cell and all the information about it (including what cell-type class it belongs to). - Go to
Extensions
-->QuST Analysis Toolbox
-->Export Images for Object Classification
. Create a destination folder in the same directory as your.txt
file and with the same name. The parameters should look like the image below. This will export an image for each cell in the sample. This is your training dataset.
To apply your trained model to an image within QuPath, navigate to Extensions
--> QuST Analysis Toolbox
--> Object Classification
.
- From the
Model
drop-down menu, select the model you wish to apply. You also have the option to adjust batch size and number of parallel threads. - When you are ready, click
Run
. - Once the model has run, within the Annotation pane,
Populate from Existing Classes
again to show the model’s cell-type classifications. - To export the data generated from QuPath and the model, go to
Measure
-->Show Detection Measurements
. - Each row in this table is a different cell and information on it. The
Classification
column contains the model’s cell type classification. HitSave
to save the resulting table to a text file.
- To run DBSCAN-CellX, make sure within the
Annotations
pane to right-click the group of cell-types you are interested in running the algorithm on and selectSelect Objects by Classification
. - Navigate to
Extensions
-->QuST Analysis Toolbox
-->DBSCAN-CellX
and run it with your desired parameters. This will run DBSCAN-CellX on the cells you have highlighted. Make sure to specify the name of the DBSCAN-CellX run (e.g.,DBSCAN-CellX-LYMPHOCYTES
). - To save the results of DBSCAN-CellX in tabular form, go to
Measure
-->Show Detection Measurements
. You will see new columns appended to the end of the table, which correspond to DBSCAN-CellX's output. HitSave
to save the new file. - To visualize the results of DBSCAN-CellX, go to
Measure
-->Show Measurement Maps
. Scroll down to the last few measurement types and select<DBSCAN-CellX-run_name>: Edge Degree
. I prefer to use the color scaleViridis
. To better see the cells and their distinct color labels, clickView
-->Cell Display
-->Cell Boundaries Only
, and be sure to have the following button selected.
The result should look something like this:
!DBSCAN-CellX Result
In conclusion, we’ve covered how to access QuPath, prep and analyze samples, generate a dataset from them to train a ML model on, install and apply the model within QuPath, and then run DBSCAN-CellX on the results. I hope this tutorial was helpful. Feel free to reach out to me (sara.lichtarge@pfizer.com) or Chao-Hui Huang (Chao-Hui.Huang@pfizer.com) with any questions.