COSIE.downstream_analysis.plot_marker_comparison

plot_marker_comparison(molecule_name, adata1, adata2, section1_label='Section 1', section2_label='Section 2', basis='spatial', s=50, alpha=0.9, colormap='turbo', plot_style='original', swap_xy=False, invert_x=False, invert_y=False, save_path=None, dpi=500, remove_legend=False, remove_spine=False, remove_title=False)[source]

Compare the spatial expression pattern of a specified molecule (e.g., gene, protein..) across two tissue sections at the spot level, each represented by an AnnData object.

Parameters

molecule_namestr

The molecule name to visualize. Must be present in .var of both AnnData objects.

adata1AnnData

The first AnnData object, e.g., for predicted data.

adata2AnnData

The second AnnData object, e.g., for observed data.

section1_labelstr, optional

Plot title label for the first section. Default is ‘Section 1’.

section2_labelstr, optional

Plot title label for the second section. Default is ‘Section 2’.

basisstr, optional

Key in .obsm specifying the spatial coordinate basis (e.g., ‘spatial’). Default is ‘spatial’.

sint, optional

Dot size in the scatter plot. Default is 50.

alphafloat, optional

Transparency level of plotted points (between 0 and 1). Default is 0.9.

colormapstr, optional

Name of the matplotlib colormap used to represent expression intensity. Default is turbo.

plot_stylestr, optional

Must be one of {‘equal’, ‘original’}.

  • ‘equal’: Enforces equal aspect ratio on axes.

  • ‘original’: Keeps raw coordinate scale.

Default is ‘original’.

swap_xybool, optional

If True, swaps x and y coordinates in both sections. Default is False.

invert_xbool, optional

If True, inverts the x-axis direction. Default is False.

invert_ybool, optional

If True, inverts the y-axis direction. Default is False.

save_pathstr or None, optional

If provided, saves the resulting figure to the specified path. The file format is inferred from the extension (e.g., .pdf, .png). Default is None.

dpiint, optional

Resolution of the saved figure in dots per inch. Default is 300.

Returns

None

This function does not return any value. It displays a side-by-side comparison plot of molecule expression across the two sections at the spot level. If save_path is specified, the figure is also saved to disk.