Skip to content

Add images to StereoSeq/Stomics spatial data and generate an RDS(Seurat) and h5ad (Scanpy).

License

Notifications You must be signed in to change notification settings

limin321/addImg2annData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

addImg2annData

Seurat and Scanpy are two popular spatail data analysis tool, which mainly developed based on the 10X Visium platform. Spatial data from Stereo-Seq platform has different format, which can be read-in by either Seurat or Scanpy. Though Stereopy provides code to convert the Stereo-Seq data to be seurat and Scanpy compatible ann data, the important image layer is lost after conversion. To solve this problem, I created a docker image called addImg2annData. This tool allows you to add the iamge to both seurat RDS and annData for scanpy. The final annData struture is the same as those you read-in 10X Visium data.

Installation

Where to download?

The docker image is available here

Docker

docker pull limin321/addimg2anndata

Singularity

singularity pull addimg2anndata.sif docker:https://limin321/addimg2anndata:0.0.0

Tutorials

Convert Stereo-Seq data to Seurat RDS and Scanpy h5ad file

Prepare inputs

Required inputs:

  1. regist.tif. This file is the output of SAW pipeline, normally located in the 03.register/ssDNA_SS200000135TL_D1_regist.tif.
  2. seurat_out.h5ad. This file is generated by this tutorial in Stereopy.
  3. bin_size. Default is bin=200. This is from previous step, but won't really affect this tool running.
  4. hires. Default is 4, which means scaling the original tif image to 4%.
  5. lowres. Default is 1, which means scaling the original tif image to 1%.
  6. library_id. Default is "S123". Set your read library ID value.
Example of running

Docker Use default value, assuming you have the input tif and h5ad in the local_input_dir

docker run --rm -v <local_input_dir>:/home/test limin321/addimg2anndata:0.0.0 bash addImage.sh -t /home/test/ssDNA_SS200000135TL_D1_regist.tif -i /home/test/S135TL_D1.tissue_seurat.h5ad

Set your own value, assuming you have the input tif and h5ad in the local_input_dir

docker run --rm -v /stomics_data/formatConvertion:/home/test limin321/addimg2anndata:0.0.0 bash addImage.sh -t /home/test/seurat/ssDNA_SS200000135TL_D1_regist.tif -i /home/test/seurat/S135TL_D1.tissue_seurat.h5ad -H 6 -l 2 -d SS200000135TL -o /home/test/seurat

Singularity

Here I have ssDNA_SS200000135TL_D1_regist.tif and S135TL_D1.tissue_seurat.h5ad inputs files in the /stomics_data/formatConvertion/seurat folder.

# use default values
singularity run -B /stomics_data/formatConvertion:/home/anndata addimg2anndata.sif bash addImage.sh -t ./seurat/ssDNA_SS200000135TL_D1_regist.tif -i ./seurat/S135TL_D1.tissue_seurat.h5ad

# specify your values
singularity run -B /stomics_data/formatConvertion:/home/anndata addimg2anndata.sif bash addImage.sh -t ./seurat/ssDNA_SS200000135TL_D1_regist.tif -i ./seurat/S135TL_D1.tissue_seurat.h5ad -H 6 -l 2 -b 100 -d SS200000135TL -o ./seurat

# replace the <place_holder> with your data path
singularity run -B </stomics_data/formatConvertion>:/home/anndata addimg2anndata.sif bash addImage.sh -t <./seurat/ssDNA_SS200000135TL_D1_regist.tif> -i <./seurat/S135TL_D1.tissue_seurat.h5ad> -H 6 -l 2 -b 100 -d SS200000135TL -o <./seurat>

Outputs

For successful run, you expect to have following outputs in the output path you specified (Default is the workding dir).

(base) [len@localhost formatConvertion]$ tree seurat/addimage/
seurat/addimage/
├── S135TL_D1.tissue_seurat.RDS
├── spatial
│   ├── scalefactors_json.json
│   ├── tissue_hires_image.png
│   ├── tissue_lowres_image.png
│   └── tissue_positions_list.csv
├── spatialFeature_QC.png
└── tissue_sc.h5ad

2 directories, 7 files

You should see the folder addimage, containing 3 files and 1 folder, named spatial.
The 3 files are:

S135TL_D1.tissue_seurat.RDS -- the seurat RDS data with image. It can be loaded to R by readRDS() function.
tissue_sc.h5ad -- the scanpy h5ad data with images. It can be read in scanpy by sc.read_h5ad() function.
spatialFeature_QC.png -- this is QC plot to show the image is added to RDS successfully. The region withot tissue should be black, the image should be the background.
spatial -- the folder contains images related files, which mimic files from Visium Spaceranger output spatial folder.

Credits and Acknowledgements

Great thanks and give credits to the Seurat team and Scanpy. This tool borrows codes from their achievements.

About

Add images to StereoSeq/Stomics spatial data and generate an RDS(Seurat) and h5ad (Scanpy).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages