tansey-lab / bayestme

BayesTME: A reference-free Bayesian method for analyzing spatial transcriptomics data
Other
14 stars 3 forks source link

How to adjust the plotting parameters? #180

Open bmlett opened 6 months ago

bmlett commented 6 months ago

Hi! I am trying to adjust and make the images clearer from the plot_bleeding_correction portion of the workflow. I have tried in both the command line and in a python notebook and the result is this: image

The command line method looks better than the notebook, but both are hard to see. Any insights on what I am missing would be greatly appreciated!

Packages was installed using the pip method last week. Thanks.

jeffquinn-msk commented 6 months ago

That plot should look something like this:

Screenshot 2024-04-30 at 1 26 12 PM

We generate this plot as a PDF in our workflow, I would recommend maybe doing this same (i know you cannot display PDF inline in IPython notebooks though sorry).

I would also recommend running BayesTME in its docker container, I cannot support installing it directly with pip, its too complex to consider all the factors in your host environment that might cause matplotlib to behave differently. You can install jupyter inside the BayesTME container if you want to use it that way.

bmlett commented 6 months ago

Thanks. The screenshot above is from the pdf format but I'll look into see about getting Docker to run with our server and see if that fixes the issue.

bmlett commented 5 months ago

Hi - So I finally got docker to run and install. I used the command line for bleed_correction and plotting and still got these style images as pdfs:
image

jeffquinn-msk commented 5 months ago

Oh ok sorry about that, I just updated this plot the other day actually, might want to pull the latest container and try that, but I'm wondering if maybe this is a data issue.. what kind of Visium are you using? Is it 6.5mm Visium, 11mm Visium, or VisiumHD ? We have only really tested this with 6.5mm Visium so far maybe the other kinds break some plot layouts

bmlett commented 5 months ago

Hi

Yeah I think its a data issue. I had a few preprocessing steps I did using scanpy. I used their adata.obsm['spatial'] for positions in the data.SpatialExpressionDataset.from_arrays. I think because scanpy sets that to the physical positions but bayesTME expected array its causing the error. I've updated the script to use array_col and array_pos. Not sure how many other differences there are between the anndata objects between bayesTME and scnapy

bmlett commented 5 months ago

Updating the position file settings and the latest version of the docker seems to have corrected the plotting issues! Thanks!! I'd recommend maybe in some future iteration adding in a import/export for scanpy.

image

jeffquinn-msk commented 5 months ago

Ah yes that would do it. Glad you got it working. As you point out when scanpy reads in the data it uses the physical spot coordinates in the spatial attribute (X,Y points in slide micrometer offset), while the plotting code I wrote expects the logical spot coordinates in the spatial attribute (integer indices into hexagonal grid). A little confusing I agree, we should persist both into the anndata and use them appropriately.