Skip to content

Commit

Permalink
Merge pull request #72 from gustaveroussy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinblampey authored May 25, 2024
2 parents 39c435c + c5dd6c0 commit d1de55d
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 101 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.0.14] - 2024-04-22

### Changed
- Renamed `embed_wsi_patches` to `infer_wsi_patches`
- `infer_wsi_patches` now accepts also callables
- Improves tile gathering speed and decreases overall computation of tile-wise inference

## [1.0.13] - 2024-04-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion docs/api/patches.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
::: sopa.patches.Patches2D

::: sopa.patches.infer.embed_wsi_patches
::: sopa.patches.infer.infer_wsi_patches

::: sopa.patches.cluster.cluster_embeddings
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In this documentation, `data_path` denotes the path to your raw data. Select the
- a `Morphology_ChannelID_Dictionary.txt` file containing channel names
- a `Morphology2D` directory containing the images, end in `_F*.TIF`.

These files must be exported as flat files in AtomX. In brief, you should have this file structure:
These files must be exported as flat files in AtomX. That is: within a study, click on "Export" and then select files from the "Flat CSV Files" section (transcripts flat and FOV position flat). You should have this file structure:

```txt
.
Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/he.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"metadata": {},
"outputs": [],
"source": [
"from sopa.patches.infer import embed_wsi_patches\n",
"from sopa.patches.infer import infer_wsi_patches\n",
"from sopa.patches.cluster import cluster_embeddings"
]
},
Expand All @@ -191,7 +191,7 @@
}
],
"source": [
"embedding = embed_wsi_patches(\n",
"embedding = infer_wsi_patches(\n",
" sdata, \"Resnet50Features\", patch_width=250, level=1, image_key=he_image_key\n",
")"
]
Expand All @@ -200,7 +200,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Then, clustering can be run on the patches embeddings. This will generate a `GeoDataFrame` under `sdata[\"sopa_embedding_patches\"]`, as below. Note the `\"cluster\"` column that has been added."
"Then, clustering can be run on the patches embeddings. This will generate a `GeoDataFrame` under `sdata[\"sopa_patches_inference\"]`, as below. Note the `\"cluster\"` column that has been added."
]
},
{
Expand Down Expand Up @@ -364,7 +364,7 @@
"source": [
"cluster_embeddings(sdata, 'sopa_Resnet50Features')\n",
"\n",
"sdata[\"sopa_embedding_patches\"]"
"sdata[\"sopa_patches_inference\"]"
]
},
{
Expand Down Expand Up @@ -403,7 +403,7 @@
"source": [
"sdata\\\n",
" .pl.render_shapes(\"region_of_interest\", outline=True, fill_alpha=0, outline_color=\"#333\")\\\n",
" .pl.render_shapes(\"sopa_embedding_patches\", color=\"cluster\")\\\n",
" .pl.render_shapes(\"sopa_patches_inference\", color=\"cluster\")\\\n",
" .pl.show(\"global\")"
]
},
Expand Down Expand Up @@ -431,7 +431,7 @@
"metadata": {},
"outputs": [],
"source": [
"res_gdf = sopa.spatial.sjoin(sdata, \"cell_boundaries\", \"sopa_embedding_patches\", target_coordinate_system=\"global\")"
"res_gdf = sopa.spatial.sjoin(sdata, \"cell_boundaries\", \"sopa_patches_inference\", target_coordinate_system=\"global\")"
]
},
{
Expand Down Expand Up @@ -504,7 +504,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sopa"
version = "1.0.13"
version = "1.0.14"
description = "Spatial-omics pipeline and analysis"
documentation = "https://gustaveroussy.github.io/sopa"
homepage = "https://gustaveroussy.github.io/sopa"
Expand Down
2 changes: 1 addition & 1 deletion sopa/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SopaKeys:

BOUNDS = "bboxes"
PATCHES_ILOCS = "ilocs"
EMBEDDINGS_PATCHES_KEY = "sopa_embedding_patches"
PATCHES_INFERENCE_KEY = "sopa_patches_inference"

UNS_KEY = "sopa_attrs"
UNS_HAS_TRANSCRIPTS = "transcripts"
Expand Down
2 changes: 1 addition & 1 deletion sopa/patches/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def cluster_embeddings(
), f"Method {method} is not available. Use one of: {', '.join(METHODS_DICT.keys())}"
method = METHODS_DICT[method]

gdf_patches = sdata[SopaKeys.EMBEDDINGS_PATCHES_KEY]
gdf_patches = sdata[SopaKeys.PATCHES_INFERENCE_KEY]

ilocs = np.array(list(gdf_patches.ilocs))
embeddings = element.compute().data[:, ilocs[:, 1], ilocs[:, 0]].T
Expand Down
Loading

0 comments on commit d1de55d

Please sign in to comment.