scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
400 stars 70 forks source link

remove spots from spatial transcriptomics #604

Closed sophieRAIBAUD closed 2 days ago

sophieRAIBAUD commented 1 year ago

Description

... dear all; I have a data coming from an experiment where the tissus seams to have moved and then I got spots with signal where there is no tissus (see image). If I want to remove these spots how cana I do that ?? many many thanks

image

giovp commented 1 year ago

hi @sophieRAIBAUD ,

thanks for the issue, I think the only way is by doing it manual. I think loupe actually provides a way to correct/subset the spots under tissue, it should be somewhere in this guide (or in related pages of the loupe browser) https://support.10xgenomics.com/spatial-gene-expression/software/visualization/latest/alignment

another option would be to open this tissue with napari, create a shape layer that overlap those points (again, manually) and then filter the anndata based on points that are not contained in the drawn shape. you can check this tutorial from the squidpy docs https://squidpy.readthedocs.io/en/latest/external_tutorials/tutorial_napari.html but I'd suggest to follow this step while using the napari-spatialdata napari plugin.

Let me know if you manage!

sophieRAIBAUD commented 1 year ago

I'll try it thanks !!

sophieRAIBAUD commented 1 year ago

@giovp I have other questions:

  1. Is it possible to annotate the data with something else than TRUE or FALSE ? for example, how can I create this annotation: image

  2. Once I have labelled my data with napari, I would like to do the whole analysis on the data of interest (clustering, differential expression, cell type deconvolution ,...): how can I remove the 'true' data image

thanks !! Sophie

Many thanks for your help !

giovp commented 1 year ago

hi @sophieRAIBAUD ,

Is it possible to annotate the data with something else than TRUE or FALSE ? for example, how can I create this annotation:

unfortunately no, but it's something we want to support in the future

Once I have labelled my data with napari, I would like to do the whole analysis on the data of interest (clustering, differential expression, cell type deconvolution ,...): how can I remove the 'true' data

so the vector is saved in the anndata in viewer._model._adata.obs[<shapes_key>] . It turns out, that that anndata is just a view of the one you passed as input to the viewer when you were adding layers. THerefore, check that specific anndata in the notebook if there is a new boolean series in adata.obs It should be there! If not, then you can access it again with viewer._model._adata.obs[<shapes_key>] and use it to filter your original anndata (ofc check that the indexes match and that you didn't do any subsetting or the likes before.

sophieRAIBAUD commented 1 year ago

@giovp

  1. thanks. it wil be very precious to be able to delimit regions from H&E image and to correlate it with spatial transcriptomics data !
  2. I have indeed the data with the shape name in the .obs columns : image

image

BUT I can not remove the TRUE part : image

Many thanks !!

giovp commented 1 year ago

mmh this is really weird, are you sure you passed the same anndata to napari construction and the on you get for the index?

sophieRAIBAUD commented 1 year ago

I guess I saved it in a .h5ad file format and if I look at the shape it correspond to what I have done: image

sophieRAIBAUD commented 1 year ago

I guess I can not replace the .obs of my data because anndata expect 1435 raws and I try to keep only 1184...

giovp commented 1 year ago

but it shoiuldn't be. I think you can return the obs_names from the boolean obs and then use those to subset the original anndata you'd want to subset? Sorry, it might be an issue from the napari side as well but I don't have time to investigate now and we are currently rewriting anyway.

giovp commented 1 year ago

hi @sophieRAIBAUD did you ever manage to follow this up? did you find a solution?

sophieRAIBAUD commented 1 year ago

no I didnt :(