Link between plot chart and image


Is there a way to directly identify or select a detected cell on a image from a scattered plot? For instance, by double clicking in coordinates on the plot, corresponding cell on the image is selected as well.

Can such link be extended with R studio for instance.

Thank you

You would have to specifically define which scatter plot, and generated by what. It is probably possible in some instances but very difficult in others. I don’t know of an easy way to do it instantly, but you can do things like use FCSExpress or other flow cytometry software to gate cell populations from QuPath text file lists of cells, sheets, modify the entries based on the gate, and then apply a new measurement to all cells based on whether or not they were gated.

That would require at least two scripts, one for the export and one for the import. Someone did something similar for clustering back in… February I think.

Scatter plot of what?
Think of this situation, two cells have the same coordinates in the scatter plot. Which is which?

… of detected cells.
One thing at a time, for now i’m interested in being able to visualize exactly where a cell is located on the image by, for instance, double clicking its coordinates on a plot chart.

Thank you

Thank you for the reply,
I am very new to this and was wondering if you could be kind with me to provide more details please.
Also can you link me to the one developed in February please.

Thanking you in anticipation

It was a very long thread, but the idea was to run the clustering algorithm outside of qupath, and import the results back into QuPath.

If you had a way to figure out which cells you were clicking on in the other program, you could use those cells (identified by a variable that counts from 1 to… however many cells you have) to do something in QuPath. That something could be labeling them a certain color, zooming in on them at a given XY coordinate, or something else.

None of that is built in, however, and you would have to code it.

Well, of course, but what are the axes of the plot, what are you plotting?
(I am assuming IJ here…). Unless you are storing (somewhere) the coordinates (or the index) of the cells the data was extracted from and link that to the plot points, you would not know which point in a plot corresponds to a given observation (of course if the axes of the plot were the x and y coordinates of the cells you would know, but I guess that is not the case here).
I think Norbert Vischer’s plugin ObjectJ could do that kind of linking, but it is a long time since I played with that:

@Delice_Lumamba It looks like you may be interested in our Image Data Explorer.

1 Like

That looks great, thanks for sharing.

The repository says:

:balance_scale: No license. All rights reserved.

Are there any plans to make this accessible under a permissive license such as MIT or BSD?

1 Like

This is an R Shiny app and many components are under GPL-type of licenses (including R itself) so it’s unclear (at least to me) what kind of license we can use. I’ll look into it.

1 Like

I only skimmed and I did not see it mentioned, but will this work for whole slide images?

In principle it should but we haven’t tested.

I’m not totally sure if a solution to this is ideally required in QuPath, ImageJ or R, but here’s a QuPath-only way:

Note all the caveats in the comments at the top of the script.

Screenshot with outlier on the upper right of the plot selected.


Way cooler than what was used for the R-squared calculations between detection measurements!

Hi Pete
Thank you so much. this is really cool.
Now I’m planning to pursue a MSc on image analysis in South Africa, do you have any suggestion on research topic?

Again thank you

@Delice_Lumamba Good!

Regarding research projects, I really don’t know… there are lots of problems requiring bioimage analysis, and there is pretty much always a better way to do things than anything that currently exists (although finding that can be very hard).

Since I’m from a computer science background, I always end up collaborating with at least one other person (biologist or clinician). Often it’s the people I’d be working with and the data they have access to that determines the projects I choose… the computational side can always be made interesting by getting deeply enough into it :slight_smile:

If you don’t have a chance to collaborate with someone, you could look for a public dataset that interests you (e.g. the Broad Bioimage Benchmark Collection or something on Kaggle). Benchmarking information helps a lot, since often one of the biggest problems is figuring out how to assess if your image analysis method works well enough.

1 Like

Hi @petebankhead

I tested the script on a whole slide and it worked like a charm and was wondering if you wouldn’t mind adding more options as this can be integrated on QuPath

  1. would you consider adding an option to export the scatter-plot
  2. have two drop-down lists populated with the column names for changing the values of each axis
  3. Multiple selection - by holding down the “Ctrl” key…
  4. the possibility to graphically compare different areas of the same slide (e.g. compare the intensity level of cells around the granuloma vs the healthish tissue)

Thank you

Hi @jkh1

I have been trying to run this app but it has been a nightmare so far. I followed the steps as provided but,

  1. every time i run image_data_explorer.R on Rstudio i get different errors concerning packages
  2. i don’t seem to find this file ( git clone anywhere.

I am stuck on the installation step. I have install the Docker as well and it is not running either.

Any advise please. I really want to test this app as well and make recommendations.

Hi @Delice_Lumamba, thanks for the feedback – I’d definitely like to further develop this, although don’t have any time for it at the moment… but it helps to know what features would be useful :slight_smile:

Regarding two of the requests…

There’s a trick to copy it to the clipboard here:

def window = getWindow('Scatter Chart') // Enter the title of the window here

Or integrated into the script:

def viewer = getCurrentViewer()
def cells = getCellObjects()
def stage = Charts.scatterChart()
    .title('My scatterplot')
    .measurements(cells, 'Nucleus: Area', 'Nucleus: DAB OD mean')

This may already be achievable just by scripting. Note that the classification of the cells is preserved, so that if you have classified your cells differently in the different regions then this should be visible in the plot.

Additionally, the line

def cells = getCellObjects()

gets all the cells in the image. Potentially you could identify the cells some other way, e.g. filtering to keep only cells that have been detected inside an annotation that has the name ‘granuloma’:

def cells = getCellObjects().findAll {it.getParent()?.getName() == 'granuloma'}

This does however all become quite specific; so your workflow would need to be designed to make it possible. I can’t really suggest an easy generic way to do this, it involves getting quite deep into the specific application and how QuPath works.


1- I noticed that a couple of packages were not listed in the README file but they should be installed by the app if you didn’t install them so I don’t think they are the problem. What errors do you get?
2- This is not a file you’re supposed to find. You clone the repository by running this command in a terminal: git clone Anyway, currently, the only file needed is image_data_explorer.R which you can also download manually.

Can you show the commands you run?

Also how do you build and run the docker image?

1 Like