Tong LI
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # PAn-Spatial Transcriptomics Analysis (PaSTa) pipeline (workshop #56) PaSTa is a nextflow-based end-to-end image analysis pipeline for decoding image-based spatial transcriptomics data. It performs imaging cycle registration, cell segmentation and transcripts peak decoding. It is currently supports analysis of three types of ST technology: - _in-situ_ sequencing-like encoding - MERFISH-like encoding - RNAScope-like labelling ![Screenshot 2024-10-22 at 13.30.45](https://hackmd.io/_uploads/rkG-iMrxkl.png) ## Dataset explanation: ![Screenshot 2024-10-16 at 22.39.57](https://hackmd.io/_uploads/SkTRMh6Jkl.png) We're working on a 7-cycle, 5-channel dataset. Image data from each cycle is a z-projected 5-channel hyperstack ome.tif. Due to the constraint of running time and resources we have, we will be working on a small crop (yellow, ~ 2500\*800 pixels) from this whole mouse brain section. # RUNNING THE PIPELINE ## Prerequisites: - Internet access - A Gitpod account _*Or*_ Unix system + Nextflow + docker/singularity + 50Gb of storage + 16 Gb of RAM. - (Optional) Jupyter notebook + Napari-spatialdata on your local computer for visualization ### I. Run the pipeline - Go to https://gitpod.io/new/#https://github.com/nextflow-io/training - Log in using your GitHub credentials - For the workspace chose next options: ![Screenshot 2024-10-22 at 13.41.43](https://hackmd.io/_uploads/SyDcTGSx1e.png) - (i) Training, (ii) VS code - browser, (iii) Large - Create an empty folder, e.g. i2k_demo: `mkdir i2k_demo` `cd i2k_demo` - Download two configuration files for the pipeline: ``` wget https://spatial_demo_datasets.cog.sanger.ac.uk/ISS/params/params_tiny_only.yaml wget https://spatial_demo_datasets.cog.sanger.ac.uk/ISS/run.config ``` - Run Nextflow pipeline (if you need to rerun the pipeline add flag `-resume` to save time): ``` nextflow run bioinfotongli/Image-ST -r v0.1.1 \ -profile local,docker -c run.config \ -params-file params_tiny_only.yaml \ -with-report report_tiny_only.html ``` ### Step-by-step pipeline explanation The nextflow pipeline is here: https://github.com/BioinfoTongLI/Image-ST/tree/main Which is composed by the following modules. https://github.com/BioinfoTongLI/modules and the corresponding container used in each of the modules are in: https://github.com/BioinfoTongLI/containers ![Screenshot 2024-10-22 at 13.53.28](https://hackmd.io/_uploads/H1BUx7Bgyg.png) _Credits to Konrad Rokicki_: https://github.com/BioImageTools/containers #### Configuration files The minimum parameters required to run the pipeline is specified with [Parameter file](https://spatial_demo_datasets.cog.sanger.ac.uk/ISS/params/params_tiny_only.yaml) The [run.config](https://spatial_demo_datasets.cog.sanger.ac.uk/ISS/run.config) takes extra settings for specific runs. ![image](https://hackmd.io/_uploads/ryT_UCUgJg.png) #### Step 1. Whole-slide registration A pip-installable image alignment tools using ome-tiffs https://github.com/VasylVaskivskyi/microaligner #### Step 2. Tiled CellPose segmentation A tiled version of cellpose segmentation to bypass RAM issue. Save outputs as polygons (wkt/geojson) (https://github.com/BioinfoTongLI/containers/tree/main/tiled-cellpose/3.0.10-py10) #### Step 3. Tiled Spotiflow peak-calling A deep-learning based RNA spot peak-calling. Similarily written in a tiled version to avoid RAM limitation. (https://github.com/BioinfoTongLI/containers/tree/main/spotiflow/0.4.2-py11) #### Step 4. PoSTcode decoding A probabilistic RNA spot barcode decoding algorithm (https://github.com/gerstung-lab/postcode). #### Step 5. SpatialData object construction Construct a spatialdata (https://spatialdata.scverse.org/en/stable/) object using the compoenent previously generated above. ### II. Checking output Go to output folder: `ls output` Short explanation of output folders: - `spatialdata` - object (folder) which contains all main outputs of the pipeline in _spatialdata_ format. It contains DAPI images, segmentation masks and decoded spots, - `cellpose_segmentation_merged_wkt` - contains polygons of segmented cells for whole image - `naive_cellpose_segmentation` - contains polygons and downscaled mask images of segmented cells for image slices - `peak_profiles` - contains files with peak positions and peak profiles used for decoding step (this information is not stored in spatialdata) - `PoSTcode_decoding_output` - contains table with all peaks decoded, their positions and probability of decoding results - `registered_stacks` - outputs of registration process, contains registered stacks of images - `registration_configs` - configuration files that were used for registration process - `slice_jsons` - csv with boundaries of image slices - `spotiflow_peaks` - spot peaks called with spotiflow ### III. Visualization - Zip spatial data folder (from the `output` folder) `zip -r demo.sdata.zip spatialdata/ISS_demo_tiny.sdata` - Download the `demo.sdata.zip` file in the left panel of VS code with right click - > Download to your local computer. - Unzip it - Download Jupyter notebook and environment yaml file from https://github.com/cellgeni/SNP_tools/tree/main/visualisation_tools - Open Jupyter Notebook - Install *spatialdata* and *napari-spatialdata* packages (first cell) - In case this doesn't work - install Jupyter kernel based on *environment.yml* file - Open Anaconda Prompt and navigate to the folder with both files - Install environment using yml file: `conda env create --file=napari_spatialdata_environment.yml` - Activate environment: `conda activate napari_spatialdata` - Install Jupyter Notebook kernel `ipython kernel install --user --name=napari_spatialdata` - Go to Jupyter Notebook, and open downloaded notebook, chose kernel “napari_spatialdata” - If the kernel isn't available or doesn't work try to restart kernel or restart jupyter notebook or restart Anaconda - In Jupyter Notebook import libraries (cell 3) and add path to unzipped spatialdata folder (cell 4) - Run cells 4-6 in Notebook and explore dataset with Napari - If you want to highlight specific cell number run last cell () # FAQ 1. My HOME dir is full when running Singularity image conversion on HPC. Quick and dirty solution is to manually specify singularity dir by setting: ``` singularity cache clean export SINGULARITY_CACHEDIR=./singularity_image_dir export NXF_SINGULARITY_CACHEDIR=./singularity_image_dir ``` 2. How do I modify parameters to specific process/step? By following nf-core standard, it is possible to add any parameters to the main script using `ext.args=”--[key] [value]”` in the run.config file. An example is ``` withName: POSTCODE { ext.args = "--channel_names 'DAPI,Cy5,AF488,Cy3,AF750'" } ``` 3. Cannot download pretrained model for the deep-learning tools (Spotiflow/CellPose) Spotiflows ``` Exception: URL fetch failure on https://drive.switch.ch/index.php/s/6AoTEgpIAeQMRvX/download: None -- [Errno -3] Temporary failure in name resolution Or CellPose urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> ``` Mostly likely you've reached max download (?), wait a bit and try later OR manually download those models and update the configuration file. 4. Where are the demo datasets? They are pre uploaded to Wellcome Sanger Institute’s S3 buckets, specifically the https://spatial_demo_datasets.cog.sanger.ac.uk/ Nextflow is able to download the files as long as these configurations are included in the run.config file. ``` aws { client { endpoint="https://cog.sanger.ac.uk" signerOverride = "S3SignerType" } } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully