Skip to content

Commit

Permalink
docs: fix typo in transcript_assign
Browse files Browse the repository at this point in the history
  • Loading branch information
danilexn committed Apr 22, 2024
1 parent 0c7e5ac commit 212f786
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 105 deletions.
4 changes: 2 additions & 2 deletions docs/computational/generate_expression_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Then, you can create a single file containing the transcriptomic information agg
--sample-id openst_demo_sample \
transcript_assign \
--spatial-key obsm/spatial_pairwise_aligned_fine \
--image-key uns/spatial_pairwise_aligned/staining_image_transformed
--mask-in uns/spatial_pairwise_aligned/staining_image_transformed
```

=== "From semiautomatic alignment"
Expand All @@ -122,7 +122,7 @@ Then, you can create a single file containing the transcriptomic information agg
--sample-id openst_demo_sample \
transcript_assign \
--spatial-key obsm/spatial_manual_fine \
--image-key uns/spatial_pairwise_aligned/staining_image_transformed
--mask-in uns/spatial_pairwise_aligned/staining_image_transformed
```

=== "From manual alignment"
Expand Down
29 changes: 0 additions & 29 deletions examples/example_from_spacemake.sh

This file was deleted.

95 changes: 21 additions & 74 deletions examples/example_workflow.sh
Original file line number Diff line number Diff line change
@@ -1,82 +1,29 @@
#!/bin/bash
# 0. cd into a root spacemake folder (i.e., containing project_df.csv and config.yaml)
# cd ...

# author: Daniel Leon-Perinan (Rajewsky Lab, 2023)
# this file uses openst to preprocess STS and imaging data,
# yields a single-cell h5ad file (UMI aggregated by segmentation mask)
# 1. stitching of the spatial dge
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 spatial_stitch --tile-coordinates fc_2_coordinate_system.csv

# placeholders:
# <path> = path where results from this script will be saved
# <path_image> = path to the folder containing the corresponding staining image
# <path_spacemake_dge> = spacemake-generated path to the dge files of this sample
# <id> = the sample id, as in spacemake
# 2. copy images into raw directory

### STEP 0 ###
# activate the openst environment
# e.g., conda activate openst
# 3. stitching of the images
# TODO: write tutorial for how to download ImageJ
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 image_stitch --imagej-bin ~/Fiji.app/ImageJ-linux64 --microscope keyence

### STEP 1 ###
# stitching of the individual tiles with a coordinate system
openst spatial_stitch \
--tiles <path_spacemake_dge>/dge.all.polyA_adapter_trimmed.mm_included.spatial_beads_*.h5ad \
--tile-coordinates <path>/novaseq_S4_coordinate_system_FC_010.csv \
--output <path>/<id>_stitched_spots.h5ad \
--join-output 'outer' \
--tile-id-regex '(L[1-4]_tile_[1-2][0-7][0-9][0-9])'
# 4. merge modalities
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 merge_modalities

### STEP 2 ###
# pairwise alignment of the coordinates
# we only run coarse alignment
# this will integrate the staining image into the file (nice for segmentation)
openst pairwise_aligner \
--image-in <path_image>/Image_Stitched_Composite.tif \
--h5-in <path>/<id>_stitched_spots.h5ad \
--h5-out <path>/<id>_stitched_spots_aligned.h5ad \
--save-image-in-h5 \
--feature-matcher 'LoFTR' \
--ransac-coarse-max-trials 1000 \
--ransac-fine-max-trials 1000 \
--n-threads 8 \
--ransac-coarse-residual-threshold 2 \
--ransac-coarse-min-samples 2 \
--only-coarse \
--device cuda \
--metadata-out <path>/<id>_alignment_metadata.json \
--threshold-counts-coarse 2
# 5.A pairwise alignment, automatic
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 pairwise_aligner --device cuda --mask-tissue --only-coarse

### STEP 3 ###
# requires manual input from the user!
# we run the refinement with the gui
# if a display is not set from ssh session, run ssh -X <host>, then e.g.,
# export DISPLAY=localhost:10.0
openst manual_pairwise_aligner_gui
# 5.B pairwise alignment, manual
# we load the GUI, then select points for coarse and fine registration. Do not forget to save the keypoints.json file!
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 manual_pairwise_aligner --spatial-key obsm/spatial --image-key uns/spatial/staining_image
# we apply the transform to the data, per tile (cannot be done in GUI)
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 apply_transform --keypoints keypoints.json --spatial-key-in obsm/spatial_pairwise_aligned_coarse --spatial-key-out obsm/spatial_pairwise_aligned_fine --per-tile

### STEP 4 ###
# transfer the refined keypoints to the fine aligned data
openst manual_pairwise_aligner \
--keypoints-json <path>/<id>_keypoints.json \
--h5-in <path>/<id>_stitched_spots_aligned.h5ad \
--fine
# 6. segmentation
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 segment --device cuda --model HE_cellpose_rajewsky

### STEP 5 ###
# calculate a segmentation mask for the aligned staining image
# optionally, we apply a dilation of 10px (increases UMIs, but might increase background signal)
openst segment \
--adata <path>/<id>_stitched_spots_aligned.h5ad \
--image-in uns/spatial_pairwise_aligned/staining_image_transformed \
--output-mask uns/spatial_pairwise_aligned/mask_transformed_10px \
--model <path>/HE_cellpose_rajewsky \
--cellprob-threshold -1 \
--flow-threshold 2 \
--chunked \
--gpu \
--num-workers 32 \
--dilate-px 10

### STEP 6 ###
# assign the individual barcoded spots (0.5 micron) into the segmentation mask
openst transcript_assign \
--adata <path>/<id>_stitched_spots_aligned.h5ad \
--spatial-key spatial_pairwise_aligned_fine \
--mask-in-adata \
--mask uns/spatial_pairwise_aligned/mask_transformed_10px \
--output <path>/<id>_segmented_cells_fine.h5ad
# 7. create dge
openst from_spacemake --project-id fc_sts_76 --sample-id fc_sts_76_3 transcript_assign --spatial-key obsm/spatial_pairwise_aligned_fine

0 comments on commit 212f786

Please sign in to comment.