Skip to content

Add ImageDimPlot, ImageFeaturePlot to Seurat Visualize#7501

Open
khaled196 wants to merge 22 commits intogalaxyproject:mainfrom
bioinfbrad:seurat
Open

Add ImageDimPlot, ImageFeaturePlot to Seurat Visualize#7501
khaled196 wants to merge 22 commits intogalaxyproject:mainfrom
bioinfbrad:seurat

Conversation

@khaled196
Copy link
Contributor

@khaled196 khaled196 commented Dec 2, 2025

FOR CONTRIBUTOR:

  • I have read the CONTRIBUTING.md document and this tool is appropriate for the tools-iuc repo.
  • License permits unrestricted use (educational + commercial)
  • This PR adds a new tool or tool collection
  • This PR updates an existing tool or tool collection
  • This PR does something else (explain below)

@khaled196 khaled196 requested a review from nsoranzo as a code owner December 2, 2025 15:58
@khaled196 khaled196 marked this pull request as draft December 2, 2025 15:58
@khaled196 khaled196 marked this pull request as ready for review December 3, 2025 13:23
khaled196 and others added 2 commits December 3, 2025 13:44
Co-authored-by: Ona <no-reply@ona.com>
<param argument="smooth" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Smooth the graph"/>
</xml>
<xml name="plot_boundaries">
<param argument="boundaries" type="text" optional="true" value="" label="Boundaries" help="A vector of segmentation boundaries per image to plot"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please give an example of such vector in the help text?

<param argument="boundaries" type="text" optional="true" value="" label="Boundaries" help="A vector of segmentation boundaries per image to plot"/>
</xml>
<xml name="plot_molecules">
<param argument="molecules" type="text" optional="true" value="" label="Molecules" help="A vector of molecules to plot"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also an example vector in the help text

</xml>
<xml name="plot_molecules">
<param argument="molecules" type="text" optional="true" value="" label="Molecules" help="A vector of molecules to plot"/>
<param argument="mols_size" type="float" value="0.1" label="Point size for molecules" help="(mols.size)"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there min, max?

Copy link
Contributor Author

@khaled196 khaled196 Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No min and max here. It has nmols that work as max, but this is only used for imagedimplot and not for imagefeatureplot, so I can't add it to the macros as one

<param name="mols_alpha" type="float" value="1.0" min="0.0" max="1.0" label="Alpha value for molecules" help=""/>
</xml>
<xml name="plot_nmols">
<param name="nmols" type="integer" value="1000" label="Max number of each molecule specified in `molecules` to plot" help=""/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min, max?

Comment on lines 261 to 264
#if $method.plot.cols.cols == 'one'
cols = '$method.plot.cols.cols',
#else if $method.plot.cols.cols == 'more'
cols = c(unlist(strsplit(gsub(" ", "", '$method.plot.cols.cols_more'), ","))),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a select param missing in the xml with one and more values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this option and made it a vector, no need to specify

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for spatial transcriptomics visualization in Seurat by introducing two new plotting functions: ImageDimPlot for visualizing clusters or categorical groupings in a spatial context, and ImageFeaturePlot for visualizing gene expression in a spatial context. The PR also refactors some existing macro definitions to improve code reuse.

Key Changes:

  • Added ImageDimPlot and ImageFeaturePlot methods with comprehensive parameter support including FOV selection, boundary visualization, molecule overlays, and spatial-specific styling options
  • Refactored common plot parameters into reusable XML macros (e.g., plot_na_value, plot_cells, plot_boundaries)
  • Added test cases with test data files for both new visualization methods

Reviewed changes

Copilot reviewed 2 out of 8 changed files in this pull request and generated 5 comments.

File Description
tools/seurat/plot.xml Added R code templates for ImageDimPlot and ImageFeaturePlot functions (lines 249-339), added UI conditional sections for both methods (lines 797-865), added two test cases (lines 1322-1357), and wrapped FeaturePlot min/max_cutoff in conditionals (lines 405-410)
tools/seurat/macros.xml Added 14 new reusable macros for spatial plotting parameters including plot_fov, plot_boundaries, plot_molecules, plot_border, plot_dark_background, plot_crop, plot_overlap, plot_axes, plot_combine, plot_coord_fixed, plot_flip_xy, and refactored plot_na_value and plot_cells into macros
tools/seurat/test-data/imagefeatureplot.png Added test output PNG file for ImageFeaturePlot validation
tools/seurat/test-data/imagedimplot.png Added test output PNG file for ImageDimPlot validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<xml name="plot_molecules">
<param argument="molecules" type="text" optional="true" value="" label="Molecules" help="A vector of molecules to plot"/>
<param argument="mols_size" type="float" value="0.1" label="Point size for molecules" help="(mols.size)"/>
<param argument="mols_cols" type="text" optional="true" value="" label="Molecules Colores" help="A vector of color for molecules. The 'Set1' palette from RColorBreweris used by default (make sure they vector has the same length as the molecules)"/>
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple issues in the help text: "RColorBreweris" should be "RColorBrewer is" (missing space), and "they vector" should be "the vector"

Suggested change
<param argument="mols_cols" type="text" optional="true" value="" label="Molecules Colores" help="A vector of color for molecules. The 'Set1' palette from RColorBreweris used by default (make sure they vector has the same length as the molecules)"/>
<param argument="mols_cols" type="text" optional="true" value="" label="Molecules Colores" help="A vector of color for molecules. The 'Set1' palette from RColorBrewer is used by default (make sure the vector has the same length as the molecules)"/>

Copilot uses AI. Check for mistakes.
</test>
<test expect_num_outputs="2">
<!-- test12: ImageDimPlot PNG -->
<param name="seurat_rds" ftype="rds" value="test_seurat_spatial.rds"/>
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The seurat_rds parameter is defined twice. The first definition on line 1324 with ftype="rds" value="test_seurat_spatial.rds" should be removed, as the second definition on line 1325 with the location attribute is the correct one.

Suggested change
<param name="seurat_rds" ftype="rds" value="test_seurat_spatial.rds"/>

Copilot uses AI. Check for mistakes.
khaled196 and others added 3 commits December 3, 2025 16:37
Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
Comment on lines 13 to 25
<requirement type="package">fit-sne</requirement>
<requirement type="package">bioconductor-limma</requirement>
<requirement type="package">bioconductor-mast</requirement>
<requirement type="package">bioconductor-deseq2</requirement>
<requirement type="package">r-svglite</requirement>
<requirement type="package">r-metap</requirement>
<requirement type="package">bioconductor-glmGamPoi</requirement>
<requirement type="package">umap-learn</requirement>
<requirement type="package">leidenalg</requirement>
<requirement type="package">r-harmony</requirement>
<requirement type="package">bioconductor-batchelor</requirement>
<requirement type="package">numpy</requirement>
<requirement type="package">pandas</requirement>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use fixed tool versions. Otherwise, it breaks the reproducibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am solving the conda compatibility right now. But my girpod disconnected.

@khaled196
Copy link
Contributor Author

hi @pavanvidem

Is the pull request ready, or are changes still needed?

</xrefs>
</xml>
</xml>
<xml name="creators">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarisaJL wrote this entire tool suite initially. Her name is missing. Please carefully check the previous contributors and include only them. Otherwise, I am also fine with removing this whole section :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author: Alex Ostrovsky 40246333+astrovsky01@users.noreply.github.com
Author: Alexander OSTROVSKY alexanderostrovsky@Chell.local
Author: Bjoern Gruening bjoern.gruening@gmail.com
Author: Björn Grüning bjoern.gruening@gmail.com
Author: Björn Grüning bjoern@gruenings.eu
Author: Khaled196 56037954+khaled196@users.noreply.github.com
Author: Khaled196 khalled.jooma@yahoo.com
Author: Lance Parsons lparsons@princeton.edu
Author: M Bernt m.bernt@ufz.de
Author: Maria Doyle maria.doyle@petermac.org
Author: Matthias Bernt m.bernt@ufz.de
Author: Mehmet Tekman mtekman89@gmail.com
Author: Nicola Soranzo nicola.soranzo@earlham.ac.uk
Author: Pavankumar Videm pavanvidem@gmail.com
Author: khaled196 khalled.jooma@yahoo.com
Author: mvdbeek m.vandenbeek@gmail.com

The GitHub list of computers from the API

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now I understand what is happening :)
There was an older Seurat (v4) tool in this same folder. The current Seurat (v5) tool was initially named seurat_v5. Seurat v4 has been deprecated, and seurat_v5 has since been renamed to seurat. So this is what I get

$ git log 8ae488affa6ce0299999a4164747d8c160bd994e..HEAD --format='%aN <%aE>' -- seurat | sort -u
Bjoern Gruening <bjoern.gruening@gmail.com>
Khaled196 <56037954+khaled196@users.noreply.github.com>
khaled196 <khalled.jooma@yahoo.com>
Khaled196 <khalled.jooma@yahoo.com>
Matthias Bernt <m.bernt@ufz.de>
M Bernt <m.bernt@ufz.de>
Pavankumar Videm <pavanvidem@gmail.com>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, but this still did not get Marisa's contribution :) Let me check again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added it but didn't push the changes yet 😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should hopefully get everyone

$ (git log --format='%aN <%aE>' -- seurat_v5;   git log 8ae488affa6ce0299999a4164747d8c160bd994e..HEAD --format='%aN <%aE>' -- seurat; ) | sort -u
Bjoern Gruening <bjoern.gruening@gmail.com>
Björn Grüning <bjoern@gruenings.eu>
Khaled196 <56037954+khaled196@users.noreply.github.com>
khaled196 <khalled.jooma@yahoo.com>
Khaled196 <khalled.jooma@yahoo.com>
MarisaJL <115314387+MarisaJL@users.noreply.github.com>
MarisaJL <marisa.loach@open.ac.uk>
Matthias Bernt <m.bernt@ufz.de>
M Bernt <m.bernt@ufz.de>
Pavankumar Videm <pavanvidem@gmail.com>

<param argument="smooth" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Smooth the graph"/>
</xml>
<xml name="plot_boundaries">
<param argument="boundaries" type="text" optional="true" value="" label="Boundaries" help="A vector of segmentation boundaries per image to plot e.g boundaries ('slideA_fov1' = 'segmentation', 'slideB_fov2' = 'centroids')"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hard to expect an input that looks like ('slideA_fov1' = 'segmentation', 'slideB_fov2' = 'centroids') from users. If it requires a dictionary like input, then split this param into a repeat with two params. If a simple comma-separated list of FOVs is good enough, then please adjust the help text.

</xml>
<xml name="plot_alpha">
<param argument="alpha" type="integer" value="1" label="Alpha value for points"/>
<param argument="alpha" type="integer" optional="true" value="1" label="Alpha value for points"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min, max?

</assert_contents>
</output>
<output name="rds_out" location="https://zenodo.org/records/13732784/files/rawdata.rds" ftype="rds"/>
<output name="rds_out" location="https://zenodo.org/records/17817806/files/rawdata.rds" ftype="rds"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please submit this zenodo record to Galaxy tool-devs community so that the community can maintain the record. If you edit the record, there should be an option to choose the community.

<output name="rds_out" location="https://zenodo.org/records/13732784/files/conserved_markers.rds" ftype="rds"/>
<output name="markers_tabular" location="https://zenodo.org/records/13732784/files/conserved_markers.csv" ftype="csv">
<output name="rds_out" location="https://zenodo.org/records/17817806/files/conserved_markers.rds" ftype="rds"/>
<output name="markers_tabular" location="https://zenodo.org/records/17817806/files/conserved_markers.csv" ftype="csv">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with such p-low values in the table, this strict file comparison might break in the future. Please use assert_contents with expression.

<output name="rds_out" location="https://zenodo.org/records/13732784/files/markersMAST.rds" ftype="rds"/>
<output name="markers_tabular" location="https://zenodo.org/records/13732784/files/markersMAST.csv" ftype="csv">
<output name="rds_out" location="https://zenodo.org/records/17817806/files/markersMAST.rds" ftype="rds" compare="sim_size" />
<output name="markers_tabular" location="https://zenodo.org/records/17817806/files/markersMAST.csv" ftype="csv" compare="sim_size">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with such p-low values in the table, this strict file comparison might break in the future. Please use assert_contents with expression.

<output name="rds_out" location="https://zenodo.org/records/13732784/files/markersDESeq2.rds" ftype="rds"/>
<output name="markers_tabular" location="https://zenodo.org/records/13732784/files/markersDESeq2.csv" ftype="csv">
<output name="rds_out" location="https://zenodo.org/records/17817806/files/markersDESeq2.rds" ftype="rds" compare="sim_size"/>
<output name="markers_tabular" location="https://zenodo.org/records/17817806/files/markersDESeq2.csv" ftype="csv" compare="sim_size">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. please use assert_contents

khaled196 and others added 3 commits January 27, 2026 16:13
Co-authored-by: Pavankumar Videm <pavanvidem@gmail.com>
Co-authored-by: Pavankumar Videm <pavanvidem@gmail.com>
Co-authored-by: Pavankumar Videm <pavanvidem@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants