Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using asSPATA2: 'Invalid spatial measure input at position 1' #170

Open
RookieA1 opened this issue Sep 9, 2024 · 7 comments
Open

Comments

@RookieA1
Copy link

RookieA1 commented Sep 9, 2024

hello,I encountered an error when trying to convert a seurat object to SPATA2 format using the asSPATA2 function from the SPATA2 R package. The error message suggests there is an issue with the spatial measure input, but I'm unsure how to resolve this. Could you please help me to sovle it?
image
image
image
image

@SavKilPat
Copy link

Just commenting to say that I'm having the same issue with my own HD dataset. Let me know if you have a workaround!

I'm wondering if it could be due to changes in the spatial coordinates metadata between platforms? For e.g. V2 uses parameters such as spot.size whereas HD has microns_per_pixel.

@kueckelj
Copy link
Collaborator

Hi, we are currently looking into that and come back to you in no time.

@kueckelj
Copy link
Collaborator

Hello, could you install the devbranch with devtools::install_github("theMILOlab/SPATA2", "dev") and see if the error persists?

@SavKilPat
Copy link

Hi Jan,

Thanks very much for sending over the devbranch, I am now able to convert my Seurat-processed Visium HD dataset to a SPATA object using asSPATA2 as long as I include the square_res argument (I otherwise get an error requesting it).

One issue following this conversion is that my H&E images are now cropped and don't align with the data - I see this when using commands likeplotImage, (first picture) and createSpatialTrajectories, whereas plotSurface (second picture) shows the uncropped data and the mis-aligned H&E image. This is after setImageDir and some pre-processing including identifyPixelContent, identifyTissueOutline, etc.

image
image

Do you have any suggestions as to what could be my error?

One workaround is to use initiateSpataObjectVisiumHD instead, however I'll have to transfer all of my metadata and clustering annotations, and I worry about loss of data.

Thank you so much for your help so far, I really appreciate it!

Sincerely,

Savannah

@kueckelj
Copy link
Collaborator

kueckelj commented Oct 1, 2024

Hi, does the mismatch between image and barcode coordinates exist right after asSPATA2() or does it start to exist after a certain processing step? In terms of "data loss" - what do you fear to loose while transferring meta data to a SPATA2 object with addFeatures()?

@SavKilPat
Copy link

Hi Jan,

The mismatch and cropping of images is immediately after I run asSPATA2(). Could it be due to setting the image directory after the fact? A description of my SPATA2 object immediately after running the function is below.

Overall though you're right, the metadata transfer options for initiateSpataObjectVisiumHD seem to work just fine. Thanks again for sending the devbranch!

Sincerely,

Savannah

FAM3WT_test <-
 SPATA2::asSPATA2(FAM3WT,
   sample_name = "FAM3_WT",
   platform = "VisiumHD",
 assay_name = "Spatial.008um",
 assay_modality = "gene",
  img_scale_fct = "hires",
 square_res = "8um",
transfer_meta_data = TRUE,
 transfer_dim_red = TRUE,
 dim_red_naming = list(pca = "pca.sketch", harmony = "harmony", umap = "umap"),
  verbose = TRUE) 
```#Missing directory for image storage and error of "Error in .local(object, ...) : 
  Could not deduce square resolution of VisiumHD data set from assay name. Please specify `square_res`." if not including  square_res = "8um",

 `FAM3WT_test`

> An object of class SPATA2
> Sample: FAM3_WT 
> Size: 76761 x 18085 (spots x molecules)
> Memory: 2.93 Gb
> Platform: VisiumHD (Resolution: 8um) 
> Molecular assays (1):
> 1. Assay
>  Molecular modality: gene
>  Distinct molecules: 18085
>  Matrices (3):
>  -counts (active)
>  -data
>  -scale.data
> Registered images (1):
> - slice1.008um.2 (457x600 px, active, loaded)
> Meta variables (20): sample, orig.ident, nCount_Spatial.008um, nFeature_Spatial.008um, nCount_Spatial.016um, nFeature_Spatial.016um, genotype.id, family.id, percent.mt, percent_mito ...
> 

@kueckelj
Copy link
Collaborator

kueckelj commented Oct 4, 2024

This is weird. Although I only have the example VisiumHD data sets from 10X (working with the pancreas data set right now), the logic should apply to your data set, too, and I can not reproduce the mismatch. Neither with 16um nor with 8um. Can you share the code with which you create the Seurat object?

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

No branches or pull requests

3 participants