broadinstitute / Tangram

Spatial alignment of single cell transcriptomic data.
BSD 3-Clause "New" or "Revised" License
254 stars 51 forks source link

Incorrect scale factor used by default #56

Closed Nick-Eagles closed 2 years ago

Nick-Eagles commented 2 years ago

Hello,

I've noticed a mismatch between histology pixel coordinates and spots (spatial coordinates) when using the tg.plot_cell_annotation_sc function, which went away when I manually supplied the scale_factor argument. If I understand correctly, when adata_st.uns['spatial'] exists, the idea is to use that information, which should include scale factor, to accurately overlap the histology and spatial coords. In particular, my spatial AnnData had the scale factor stored in adata_st.uns['spatial'][sample_name]['scalefactors']['tissue_hires_scalef'], which I believe is a standard location where it should be found (rather than needing to specify scale_factor explicitly).

I traced the source of the "mismatch" to the default assignment of scale factor as 0.1, which is passed to sc.pl.spatial even when adata_st.uns['spatial'] exists. I imagine the default of 0.1 only makes sense when adata_st.uns['spatial'] doesn't exist.

I believe the same issue exists for the tg.plot_genes_sc function, though I haven't explicitly checked this. Apologies if I'm misunderstanding, and I've stored the scale factor in a non-standard location. Note that I'm using tangram 1.0.2 as installed through pip, and am following along the squidpy tutorial.

Thanks for providing the Tangram software!

Best,

-Nick

lewlin commented 2 years ago

@gaddamshreya Could you also look at this please?

gaddamshreya commented 2 years ago

@Nick-Eagles thank you for identifying this issue! Investigating asap

gaddamshreya commented 2 years ago

@Nick-Eagles I've removed scale factor's default value for the plotting functions and updated the tutorial; thank you for bringing this to our attention!

Nick-Eagles commented 2 years ago

Great! I appreciate you looking into this.