From 3b534f1d23f36ce013b1bbd4fe8c1d30e6d98e7e Mon Sep 17 00:00:00 2001 From: <> Date: Sun, 24 Dec 2023 15:46:39 +0000 Subject: [PATCH] Deployed 1fe31d8 with MkDocs version: 1.5.3 --- .nojekyll | 0 404.html | 917 +++ api/_sdata/index.html | 1822 +++++ api/annotation/fluorescence/index.html | 1242 +++ api/annotation/tangram/index.html | 1181 +++ api/io.explorer/index.html | 3385 +++++++++ api/io.report/index.html | 2395 ++++++ api/io/index.html | 2483 ++++++ api/segmentation/aggregate/index.html | 2485 ++++++ api/segmentation/baysor/index.html | 1245 +++ api/segmentation/methods/index.html | 1187 +++ api/segmentation/patching/index.html | 2386 ++++++ api/segmentation/shapes/index.html | 1535 ++++ api/segmentation/stainings/index.html | 2238 ++++++ api/stats/index.html | 2190 ++++++ api/utils/data/index.html | 1468 ++++ api/utils/image/index.html | 1453 ++++ api/utils/polygon_crop/index.html | 1205 +++ assets/_mkdocstrings.css | 64 + assets/images/favicon.png | Bin 0 -> 1870 bytes assets/javascripts/bundle.81fa17fe.min.js | 29 + assets/javascripts/bundle.81fa17fe.min.js.map | 7 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++++++++++++++++ .../workers/search.f886a092.min.js | 42 + .../workers/search.f886a092.min.js.map | 7 + assets/overview.png | Bin 0 -> 402879 bytes assets/overview_hd.png | Bin 0 -> 1279912 bytes assets/sopa.png | Bin 0 -> 13433 bytes assets/sopa_favicon.png | Bin 0 -> 1303 bytes assets/sopa_small_blue.png | Bin 0 -> 11205 bytes assets/sopa_small_white.png | Bin 0 -> 11144 bytes assets/stylesheets/main.4b4a2bd9.min.css | 1 + assets/stylesheets/main.4b4a2bd9.min.css.map | 1 + assets/stylesheets/palette.356b1318.min.css | 1 + .../stylesheets/palette.356b1318.min.css.map | 1 + cite_us/index.html | 957 +++ cli/index.html | 1952 +++++ css/custom.css | 9 + css/termynal.css | 110 + faq/index.html | 1063 +++ getting_started/index.html | 1058 +++ index.html | 1035 +++ js/custom.js | 105 + js/mathjax.js | 17 + js/termynal.js | 264 + objects.inv | Bin 0 -> 1302 bytes pipeline/index.html | 1104 +++ search/search_index.json | 1 + sitemap.xml | 3 + sitemap.xml.gz | Bin 0 -> 127 bytes toy/index.html | 1086 +++ 84 files changed, 46935 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 api/_sdata/index.html create mode 100644 api/annotation/fluorescence/index.html create mode 100644 api/annotation/tangram/index.html create mode 100644 api/io.explorer/index.html create mode 100644 api/io.report/index.html create mode 100644 api/io/index.html create mode 100644 api/segmentation/aggregate/index.html create mode 100644 api/segmentation/baysor/index.html create mode 100644 api/segmentation/methods/index.html create mode 100644 api/segmentation/patching/index.html create mode 100644 api/segmentation/shapes/index.html create mode 100644 api/segmentation/stainings/index.html create mode 100644 api/stats/index.html create mode 100644 api/utils/data/index.html create mode 100644 api/utils/image/index.html create mode 100644 api/utils/polygon_crop/index.html create mode 100644 assets/_mkdocstrings.css create mode 100644 assets/images/favicon.png create mode 100644 assets/javascripts/bundle.81fa17fe.min.js create mode 100644 assets/javascripts/bundle.81fa17fe.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js.map create mode 100644 assets/overview.png create mode 100644 assets/overview_hd.png create mode 100644 assets/sopa.png create mode 100644 assets/sopa_favicon.png create mode 100644 assets/sopa_small_blue.png create mode 100644 assets/sopa_small_white.png create mode 100644 assets/stylesheets/main.4b4a2bd9.min.css create mode 100644 assets/stylesheets/main.4b4a2bd9.min.css.map create mode 100644 assets/stylesheets/palette.356b1318.min.css create mode 100644 assets/stylesheets/palette.356b1318.min.css.map create mode 100644 cite_us/index.html create mode 100644 cli/index.html create mode 100644 css/custom.css create mode 100644 css/termynal.css create mode 100644 faq/index.html create mode 100644 getting_started/index.html create mode 100644 index.html create mode 100644 js/custom.js create mode 100644 js/mathjax.js create mode 100644 js/termynal.js create mode 100644 objects.inv create mode 100644 pipeline/index.html create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz create mode 100644 toy/index.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/404.html b/404.html new file mode 100644 index 00000000..fa589a75 --- /dev/null +++ b/404.html @@ -0,0 +1,917 @@ + + + +
+ + + + + + + + + + + + + + +Note
+These are convenient tools that operates on SpatialData
objects
sopa._sdata.get_boundaries(sdata, return_key=False, warn=False)
+
+Gets the baysor boundaries or cellpose boundaries of a SpatialData object after running Sopa
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A SpatialData object + |
+ + required + | +
return_key |
+
+ bool
+ |
+
+
+
+ Whether to return the key of the shapes or not. + |
+
+ False
+ |
+
warn |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame | tuple[str, GeoDataFrame] | None
+ |
+
+
+
+ A |
+
sopa/_sdata.py
sopa._sdata.get_intrinsic_cs(sdata, element, name=None)
+
+Gets the name of the intrinsic coordinate system of an element
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A SpatialData object + |
+ + required + | +
element |
+
+ SpatialElement | str
+ |
+
+
+
+
|
+ + required + | +
name |
+
+ str | None
+ |
+
+
+
+ Name to provide to the intrinsic coordinate system if not existing. By default, uses the element id. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ Name of the intrinsic coordinate system + |
+
sopa/_sdata.py
sopa._sdata.to_intrinsic(sdata, element, element_cs)
+
+Transforms a SpatialElement
into the intrinsic coordinate system of another SpatialElement
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A SpatialData object + |
+ + required + | +
element |
+
+ SpatialElement | str
+ |
+
+
+
+
|
+ + required + | +
element_cs |
+
+ SpatialElement | str
+ |
+
+
+
+
|
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ | +
+
+
+ The |
+
sopa/_sdata.py
sopa._sdata.get_intensities(sdata)
+
+Gets the intensity dataframe of shape n_obs x n_channels
sopa/_sdata.py
sopa._sdata.iter_scales(image)
+
+Iterates through all the scales of a MultiscaleSpatialImage
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
image |
+
+ MultiscaleSpatialImage
+ |
+
+
+
+ a |
+ + required + | +
Yields:
+Type | +Description | +
---|---|
+ DataArray
+ |
+
+
+
+ Each scale (as a |
+
sopa/_sdata.py
sopa._sdata.get_spatial_image(sdata, key=None, return_key=False)
+
+Gets a SpatialImage from a SpatialData object (if the image has multiple scale, the scale0
is returned)
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ SpatialData object. + |
+ + required + | +
key |
+
+ str | None
+ |
+
+
+
+ Optional image key. If |
+
+ None
+ |
+
return_key |
+
+ bool
+ |
+
+
+
+ Whether to also return the key of the image. + |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialImage | tuple[str, SpatialImage]
+ |
+
+
+
+ If |
+
sopa/_sdata.py
sopa.annotation.higher_z_score(adata, marker_cell_dict, cell_type_key='cell_type')
+
+Simple channel-based segmentation using a marker-to-population dictionary
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
marker_cell_dict |
+
+ dict
+ |
+
+
+
+ Dictionary whose keys are channels, and values are the corresponding populations. + |
+ + required + | +
cell_type_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ 'cell_type'
+ |
+
sopa/annotation/fluorescence.py
sopa.annotation.preprocess_fluo(adata)
+
+Preprocess fluorescence data. For each column \(X\), we compute \(asinh(\frac{X}{5Q(0.2, X)})\) and apply standardization
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ DataFrame
+ |
+
+
+
+ A dataframe of preprocessed channels intensities + |
+
sopa/annotation/fluorescence.py
sopa.annotation.tangram.tangram_annotate(sdata, adata_sc, cell_type_key, reference_preprocessing=None, bag_size=10000, max_obs_reference=10000, **kwargs)
+
+Tangram multi-level annotation. Tangram is run on multiple bags of cells to decrease the RAM usage.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
adata_sc |
+
+ AnnData
+ |
+
+
+
+ A scRNAseq annotated reference + |
+ + required + | +
cell_type_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
reference_preprocessing |
+
+ str
+ |
+
+
+
+ Preprocessing method used on the reference. Can be |
+
+ None
+ |
+
bag_size |
+
+ int
+ |
+
+
+
+ Size of each bag on which tangram will be run. Use smaller bags to lower the RAM usage + |
+
+ 10000
+ |
+
max_obs_reference |
+
+ int
+ |
+
+
+
+ Maximum number of cells used in |
+
+ 10000
+ |
+
sopa/annotation/tangram/run.py
sopa.io.explorer.write(path, sdata, image_key=None, shapes_key=None, points_key=None, gene_column=None, layer=None, polygon_max_vertices=13, lazy=True, ram_threshold_gb=4, mode=None, save_h5ad=False)
+
+Transform a SpatialData object into inputs for the Xenium Explorer.
+After running this function, double-click on the experiment.xenium
file to open it.
Software download
+Make sure you have the latest version of the Xenium Explorer
+This function will create up to 7 files, depending on the SpatialData
object and the arguments:
experiment.xenium
contains some experiment metadata. Double-click on this file to open the Xenium Explorer. This file can also be created with write_metadata
.
morphology.ome.tif
is the primary image. This file can also be created with write_image
. Add more images with align
.
analysis.zarr.zip
contains the cells categories (or clusters), i.e. adata.obs
. This file can also be created with write_cell_categories
.
cell_feature_matrix.zarr.zip
contains the cell-by-gene counts. This file can also be created with write_gene_counts
.
cells.zarr.zip
contains the cells polygon boundaries. This file can also be created with write_polygons
.
transcripts.zarr.zip
contains transcripts locations. This file can also be created with write_transcripts
.
adata.h5ad
is the AnnData
object from the SpatialData
. This is not used by the Explorer, but only saved for convenience.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the directory where files will be saved. + |
+ + required + | +
sdata |
+
+ SpatialData
+ |
+
+
+
+ SpatialData object. + |
+ + required + | +
image_key |
+
+ str | None
+ |
+
+
+
+ Name of the image of interest (key of |
+
+ None
+ |
+
shapes_key |
+
+ str | None
+ |
+
+
+
+ Name of the cell shapes (key of |
+
+ None
+ |
+
points_key |
+
+ str | None
+ |
+
+
+
+ Name of the transcripts (key of |
+
+ None
+ |
+
gene_column |
+
+ str | None
+ |
+
+
+
+ Column name of the points dataframe containing the gene names. + |
+
+ None
+ |
+
layer |
+
+ str | None
+ |
+
+
+
+ Layer of |
+
+ None
+ |
+
polygon_max_vertices |
+
+ int
+ |
+
+
+
+ Maximum number of vertices for the cell polygons. + |
+
+ 13
+ |
+
lazy |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
ram_threshold_gb |
+
+ int | None
+ |
+
+
+
+ Threshold (in gygabytes) from which image can be loaded in memory. If |
+
+ 4
+ |
+
mode |
+
+ str
+ |
+
+
+
+ string that indicated which files should be created. "-ib" means everything except images and boundaries, while "+tocm" means only transcripts/observations/counts/metadata (each letter corresponds to one explorer file). By default, keeps everything. + |
+
+ None
+ |
+
save_h5ad |
+
+ bool
+ |
+
+
+
+ Whether to save the adata as h5ad in the explorer directory (for convenience only, since h5ad is faster to open than the original .zarr table) + |
+
+ False
+ |
+
sopa/io/explorer/converter.py
41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 |
|
sopa.io.explorer.write_image(path, image, lazy=True, tile_width=1024, n_subscales=5, pixelsize=0.2125, ram_threshold_gb=4, is_dir=True)
+
+Convert an image into a morphology.ome.tif
file that can be read by the Xenium Explorer
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the Xenium Explorer directory where the image will be written + |
+ + required + | +
image |
+
+ SpatialImage | ndarray
+ |
+
+
+
+ Image of shape |
+ + required + | +
lazy |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
tile_width |
+
+ int
+ |
+
+
+
+ Xenium tile width (do not update). + |
+
+ 1024
+ |
+
n_subscales |
+
+ int
+ |
+
+
+
+ Number of sub-scales in the pyramidal image. + |
+
+ 5
+ |
+
pixelsize |
+
+ float
+ |
+
+
+
+ Xenium pixel size (do not update). + |
+
+ 0.2125
+ |
+
ram_threshold_gb |
+
+ int | None
+ |
+
+
+
+ If an image (of any level of the pyramid) is below this threshold, it will be loaded in-memory. + |
+
+ 4
+ |
+
is_dir |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
sopa/io/explorer/images.py
sopa.io.explorer.write_cell_categories(path, adata, is_dir=True)
+
+Write a analysis.zarr.zip
file containing the cell categories/clusters (i.e., from adata.obs
)
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the Xenium Explorer directory where the cell-categories file will be written + |
+ + required + | +
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
is_dir |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
sopa/io/explorer/table.py
sopa.io.explorer.write_transcripts(path, df, gene='gene', max_levels=15, is_dir=True)
+
+Write a transcripts.zarr.zip
file containing pyramidal transcript locations
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the Xenium Explorer directory where the transcript file will be written + |
+ + required + | +
df |
+
+ DataFrame
+ |
+
+
+
+ DataFrame representing the transcripts, with |
+ + required + | +
gene |
+
+ str
+ |
+
+
+
+ Column of |
+
+ 'gene'
+ |
+
max_levels |
+
+ int
+ |
+
+
+
+ Maximum number of levels in the pyramid. + |
+
+ 15
+ |
+
is_dir |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
sopa/io/explorer/points.py
20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 |
|
sopa.io.explorer.write_gene_counts(path, adata, layer=None, is_dir=True)
+
+Write a cell_feature_matrix.zarr.zip
file containing the cell-by-gene transcript counts (i.e., from adata.X
)
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the Xenium Explorer directory where the cell-by-gene file will be written + |
+ + required + | +
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
layer |
+
+ str | None
+ |
+
+
+
+ If not |
+
+ None
+ |
+
is_dir |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
sopa/io/explorer/table.py
sopa.io.explorer.write_polygons(path, polygons, max_vertices, is_dir=True)
+
+Write a cells.zarr.zip
file containing the cell polygonal boundaries
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the Xenium Explorer directory where the transcript file will be written + |
+ + required + | +
polygons |
+
+ Iterable[Polygon]
+ |
+
+
+
+ A list of |
+ + required + | +
max_vertices |
+
+ int
+ |
+
+
+
+ The number of vertices per polygon (they will be transformed to have the right number of vertices) + |
+ + required + | +
is_dir |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
sopa/io/explorer/shapes.py
47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 |
|
sopa.io.explorer.write_metadata(path, image_key='NA', shapes_key='NA', n_obs=0, is_dir=True)
+
+Create an experiment.xenium
file that can be open by the Xenium Explorer.
This function alone is not enough to actually open an experiment. You will need at least to wrun write_image
, or create all the outputs with write
.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the Xenium Explorer directory where the metadata file will be written + |
+ + required + | +
image_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ 'NA'
+ |
+
shapes_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ 'NA'
+ |
+
n_obs |
+
+ int
+ |
+
+
+
+ Number of cells + |
+
+ 0
+ |
+
is_dir |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
sopa/io/explorer/converter.py
sopa.io.explorer.int_cell_id(explorer_cell_id)
+
+Transforms an alphabetical cell id from the Xenium Explorer to an integer ID
+E.g., int_cell_id('aaaachba-1') = 10000
+ +sopa/io/explorer/utils.py
sopa.io.explorer.str_cell_id(cell_id)
+
+Transforms an integer cell ID into an Xenium Explorer alphabetical cell id
+E.g., str_cell_id(10000) = 'aaaachba-1'
+ +sopa/io/explorer/utils.py
sopa.io.explorer.align(sdata, image, transformation_matrix_path, image_key=None, image_models_kwargs=None, overwrite=False)
+
+Add an image to the SpatialData
object after alignment with the Xenium Explorer.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
image |
+
+ SpatialImage
+ |
+
+
+
+ A |
+ + required + | +
transformation_matrix_path |
+
+ str
+ |
+
+
+
+ Path to the |
+ + required + | +
image_key |
+
+ str
+ |
+
+
+
+ Optional name of the image on which it has been aligned. Required if multiple images in the |
+
+ None
+ |
+
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs to the |
+
+ None
+ |
+
overwrite |
+
+ bool
+ |
+
+
+
+ Whether to overwrite the image, if already existing. + |
+
+ False
+ |
+
sopa/io/explorer/images.py
sopa.io.explorer.save_column_csv(path, adata, key)
+
+Save one column of the AnnData object as a CSV that can be open interactively in the explorer, under the "cell" panel.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path where to write the CSV that will be open in the Xenium Explorer + |
+ + required + | +
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
sopa/io/explorer/table.py
sopa.io.report.write_report(path, sdata)
+
+Create a HTML report (or web report) after running Sopa.
+ +This report is automatically generated based on a custom python-to-html engine
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the |
+ + required + | +
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
sopa/io/report/generate.py
sopa.io.report.engine.Renderable
+
+
+Object that can be transformed to string representing HTML
+ +sopa/io/report/engine.py
sopa.io.report.engine.Title
+
+
+
+ Bases: Renderable
Report title
+ +sopa/io/report/engine.py
sopa.io.report.engine.Paragraph
+
+
+
+ Bases: Renderable
Report paragraph
+ +sopa/io/report/engine.py
sopa.io.report.engine.Message
+
+
+
+ Bases: Renderable
Colored message
+ +sopa/io/report/engine.py
sopa.io.report.engine.Block
+
+
+
+ Bases: Renderable
Block, i.e. padded div
+ +sopa/io/report/engine.py
sopa.io.report.engine.CodeBlock
+
+
+
+ Bases: Renderable
Block of code, like in the terminal
+ +sopa/io/report/engine.py
sopa.io.report.engine.ProgressBar
+
+
+
+ Bases: Renderable
Progress bar
+ +sopa/io/report/engine.py
sopa.io.report.engine.Section
+
+
+
+ Bases: Renderable
Section of the report
+ +sopa/io/report/engine.py
sopa.io.report.engine.SubSection
+
+
+
+ Bases: Section
Sub-section of the report
+ +sopa/io/report/engine.py
sopa.io.report.engine.NavbarItem
+
+
+
+ Bases: Renderable
One item in the nav bar
+ +sopa/io/report/engine.py
sopa.io.report.engine.Navbar
+
+
+
+ Bases: Renderable
Left nav bar
+ +sopa/io/report/engine.py
sopa.io.report.engine.Columns
+
+
+
+ Bases: Renderable
Flex columns containers
+ +sopa/io/report/engine.py
sopa.io.report.engine.Image
+
+
+
+ Bases: Renderable
Image renderer
+ +sopa/io/report/engine.py
sopa.io.report.engine.Root
+
+
+
+ Bases: Renderable
Whole report generator
+ +sopa/io/report/engine.py
Notes
+Due to many updates in the data format provided by the different companies, you might have issues loading your data. In this case, consider opening an issue detailing the version of the machine you used and the error log, as well as an example of file names that you are trying to read.
+Related to spatialdata-io
A library called spatialdata-io
already contains a lot of readers. Here, we updated some readers already existing in spatialdata-io
, and added a few others. In the future, we will completely rely on spatialdata-io
.
sopa.io.xenium(path, imread_kwargs=MappingProxyType({}), image_models_kwargs=MappingProxyType({}))
+
+Read Xenium data as a SpatialData
object. For more information, refer to spatialdata-io.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to the Xenium directory containing all the experiment files + |
+ + required + | +
imread_kwargs |
+ + | +
+
+
+ See link above. + |
+
+ MappingProxyType({})
+ |
+
image_models_kwargs |
+ + | +
+
+
+ See link above. + |
+
+ MappingProxyType({})
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/transcriptomics.py
sopa.io.merscope(path, vpt_outputs=None, z_layers=3, region_name=None, slide_name=None, imread_kwargs=MappingProxyType({}), image_models_kwargs=MappingProxyType({}))
+
+Read MERSCOPE data as a SpatialData
object. For more information, refer to spatialdata-io.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to the MERSCOPE directory containing all the experiment files + |
+ + required + | +
**kwargs |
+ + | +
+
+
+ See link above. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/transcriptomics.py
84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 |
|
sopa.io.cosmx(path, **kwargs)
+
+Alias to the spatialdata-io reader.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str
+ |
+
+
+
+ Path to the CosMX data directory + |
+ + required + | +
**kwargs |
+
+ int
+ |
+
+
+
+ See link above. + |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/transcriptomics.py
sopa.io.macsima(path, image_models_kwargs=None, imread_kwargs=None)
+
+Read MACSIMA data as a SpatialData
object
For all dulicated name, their index will be added in brackets after, for instance you will often find DAPI (000)
to indicate the DAPI channel of index 000
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the directory containing the MACSIMA |
+ + required + | +
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs provided to the |
+
+ None
+ |
+
imread_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs provided to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/imaging.py
sopa.io.phenocycler(path, *args)
+
+Read phenocycler data as a SpatialData
object
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to PhenoCycler |
+ + required + | +
args |
+ + | +
+
+
+ Args provided to the |
+
+ ()
+ |
+
Returns:
+Type | +Description | +
---|---|
+ | +
+
+
+ A |
+
sopa/io/imaging.py
sopa.io.qptiff(path, channels_renaming=None, image_models_kwargs=None)
+
+Read a .qptiff
file as a SpatialData
object
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to a |
+ + required + | +
channels_renaming |
+
+ dict | None
+ |
+
+
+
+ A dictionnary whose keys correspond to channels and values to their corresponding new name + |
+
+ None
+ |
+
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs provided to the |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/imaging.py
sopa.io.hyperion(path, image_models_kwargs=None, imread_kwargs=None)
+
+Read Hyperion data as a SpatialData
object
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the directory containing the Hyperion |
+ + required + | +
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs provided to the |
+
+ None
+ |
+
imread_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs provided to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/imaging.py
sopa.io.ome_tif(path)
+
+Read an .ome.tif
image. This image should be a 2D image (with possibly multiple channels).
+Typically, this function can be used to open Xenium IF images.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ SpatialImage
+ |
+
+
+
+ A |
+
sopa/io/imaging.py
sopa.segmentation.aggregate.average_channels(sdata, image_key=None, shapes_key=None, expand_radius_ratio=0)
+
+Average channel intensities per cell.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
image_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
shapes_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
expand_radius_ratio |
+
+ float
+ |
+
+
+
+ Cells polygons will be expanded by |
+
+ 0
+ |
+
Returns:
+Type | +Description | +
---|---|
+ ndarray
+ |
+
+
+
+ A numpy |
+
sopa/segmentation/aggregate.py
sopa.segmentation.aggregate._average_channels_aligned(image, geo_df)
+
+Average channel intensities per cell. The image and cells have to be aligned, i.e. be on the same coordinate system.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
image |
+
+ SpatialImage
+ |
+
+
+
+ A |
+ + required + | +
geo_df |
+
+ GeoDataFrame | list[Polygon]
+ |
+
+
+
+ A |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ | +
+
+
+ A numpy |
+
sopa/segmentation/aggregate.py
sopa.segmentation.aggregate.count_transcripts(sdata, gene_column, shapes_key=None, points_key=None, geo_df=None)
+
+Counts transcripts per cell.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
gene_column |
+
+ str
+ |
+
+
+
+ Column of the transcript dataframe containing the gene names + |
+ + required + | +
shapes_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
points_key |
+
+ str
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
geo_df |
+
+ GeoDataFrame
+ |
+
+
+
+ If the cell boundaries are not yet in |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AnnData
+ |
+
+
+
+ An |
+
sopa/segmentation/aggregate.py
sopa.segmentation.aggregate._count_transcripts_aligned(geo_df, points, value_key)
+
+Count transcripts per cell. The cells and points have to be aligned (i.e., in the same coordinate system)
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
geo_df |
+
+ GeoDataFrame
+ |
+
+
+
+ Cells geometries + |
+ + required + | +
points |
+
+ DataFrame
+ |
+
+
+
+ Transcripts dataframe + |
+ + required + | +
value_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ AnnData
+ |
+
+
+
+ An |
+
sopa/segmentation/aggregate.py
sopa.segmentation.aggregate.Aggregator
+
+
+Perform transcript count and channel averaging over a SpatialData
object
sopa/segmentation/aggregate.py
34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 |
|
__init__(sdata, overwrite=True, image_key=None)
+
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
overwrite |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
image_key |
+
+ str | None
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
sopa/segmentation/aggregate.py
update_table(gene_column, average_intensities, expand_radius_ratio, min_transcripts, min_intensity_ratio)
+
+Perform aggregation and update the spatialdata table
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
gene_column |
+
+ str | None
+ |
+
+
+
+ Column key of the transcript dataframe containing the gene names + |
+ + required + | +
average_intensities |
+
+ bool
+ |
+
+
+
+ Whether to average the channels intensities inside cells polygons + |
+ + required + | +
expand_radius_ratio |
+
+ float
+ |
+
+
+
+ Cells polygons will be expanded by |
+ + required + | +
min_transcripts |
+
+ int
+ |
+
+
+
+ Minimum amount of transcript to keep a cell + |
+ + required + | +
min_intensity_ratio |
+
+ float
+ |
+
+
+
+ Cells whose mean channel intensity is less than |
+ + required + | +
sopa/segmentation/aggregate.py
96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 |
|
sopa.segmentation.baysor.resolve.resolve(sdata, baysor_temp_dir, gene_column, patches_dirs=None, min_area=0)
+
+Concatenate all the per-patch Baysor run and resolve the conflicts. Resulting cells boundaries are saved in the SpatialData
object.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
baysor_temp_dir |
+
+ str
+ |
+
+
+
+ Temporary directory used to store all the baysor subdirectories (one subdirectory for one patch and for one baysor run) + |
+ + required + | +
gene_column |
+
+ str
+ |
+
+
+
+ Column of the transcript dataframe containing the genes names + |
+ + required + | +
patches_dirs |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of subdirectories inside |
+
+ None
+ |
+
min_area |
+
+ float
+ |
+
+
+
+ Minimum area (in microns^2) for a cell to be kept + |
+
+ 0
+ |
+
sopa/segmentation/baysor/resolve.py
95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 |
|
sopa.segmentation.methods.cellpose_patch(diameter, channels, model_type='cyto2', **cellpose_kwargs)
+
+Creation of a callable that runs Cellpose segmentation on a patch
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
diameter |
+
+ float
+ |
+
+
+
+ Cellpose diameter parameter + |
+ + required + | +
channels |
+
+ list[str]
+ |
+
+
+
+ List of channel names + |
+ + required + | +
model_type |
+
+ str
+ |
+
+
+
+ Cellpose model type + |
+
+ 'cyto2'
+ |
+
**cellpose_kwargs |
+
+ int
+ |
+
+
+
+ Kwargs to be provided to |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Callable
+ |
+
+
+
+ A |
+
sopa/segmentation/methods.py
sopa.segmentation.patching.Patches2D
+
+
+Perform patching with overlap
+ +sopa/segmentation/patching.py
57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 |
|
polygons: list[Polygon]
+
+
+ property
+
+
+All the patches as polygons
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[Polygon]
+ |
+
+
+
+ List of |
+
__getitem__(i)
+
+One patche bounding box: (xmin, ymin, xmax, ymax)
+ +sopa/segmentation/patching.py
__init__(sdata, element_name, patch_width, patch_overlap=50)
+
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
element_name |
+
+ str
+ |
+
+
+
+ Name of the element on with patches will be made + |
+ + required + | +
patch_width |
+
+ float | int
+ |
+
+
+
+ Width of the patches (in the unit of the coordinate system of the element) + |
+ + required + | +
patch_overlap |
+
+ float | int
+ |
+
+
+
+ Overlap width between the patches + |
+
+ 50
+ |
+
sopa/segmentation/patching.py
__iter__()
+
+__len__()
+
+iloc(ix, iy)
+
+Coordinates of the rectangle bounding box of the patch at the given indices
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
ix |
+
+ int
+ |
+
+
+
+ Patch index in the x-axis + |
+ + required + | +
iy |
+
+ int
+ |
+
+
+
+ Patch indes in the y-axis + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ list[int]
+ |
+
+
+
+ A list |
+
sopa/segmentation/patching.py
pair_indices(i)
+
+Index localization of one patch
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
i |
+
+ int
+ |
+
+
+
+ The patch index + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ tuple[int, int]
+ |
+
+
+
+ A tuple |
+
sopa/segmentation/patching.py
patchify_transcripts(baysor_temp_dir, cell_key=None, unassigned_value=None, use_prior=False)
+
+Patchification of the transcripts
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
baysor_temp_dir |
+
+ str
+ |
+
+
+
+ Temporary directory where each patch will be stored. Note that each patch will have its own subdirectory. + |
+ + required + | +
cell_key |
+
+ str
+ |
+
+
+
+ Optional key of the transcript dataframe containing the cell IDs. This is useful if a prior segmentation has been run, assigning each transcript to a cell. + |
+
+ None
+ |
+
unassigned_value |
+
+ int | str
+ |
+
+
+
+ If |
+
+ None
+ |
+
use_prior |
+
+ bool
+ |
+
+
+
+ Whether to use Cellpose as a prior segmentation for Baysor. If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[int]
+ |
+
+
+
+ A list of patches indices. Each index correspond to the name of a subdirectory inside |
+
sopa/segmentation/patching.py
polygon(i)
+
+One patch as a shapely polygon. The polygon may not be just a square, if a ROI has been previously selected.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
i |
+
+ int
+ |
+
+
+
+ Patch index + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Polygon
+ |
+
+
+
+ Polygon representing the patch + |
+
sopa/segmentation/patching.py
write(overwrite=True)
+
+Save patches in sdata.shapes["sopa_patches"]
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
overwrite |
+
+ bool
+ |
+
+
+
+ Whether to overwrite patches if existing + |
+
+ True
+ |
+
sopa/segmentation/patching.py
sopa.segmentation.shapes.solve_conflicts(cells, threshold=0.5, patch_indices=None, return_indices=False)
+
+Resolve segmentation conflicts (i.e. overlap) after running segmentation on patches
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
cells |
+
+ list[Polygon]
+ |
+
+
+
+ List of cell polygons + |
+ + required + | +
threshold |
+
+ float
+ |
+
+
+
+ When two cells are overlapping, we look at the area of intersection over the area of the smallest cell. If this value is higher than the |
+
+ 0.5
+ |
+
patch_indices |
+
+ ndarray | None
+ |
+
+
+
+ Patch from which each cell belongs. + |
+
+ None
+ |
+
return_indices |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ ndarray[Polygon]
+ |
+
+
+
+ Array of resolved cells polygons + |
+
sopa/segmentation/shapes.py
sopa.segmentation.shapes.geometrize(mask, tolerance=None, smooth_radius_ratio=0.1)
+
+Convert a cells mask to multiple shapely
geometries. Inspired from https://github.com/Vizgen/vizgen-postprocessing
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mask |
+
+ ndarray
+ |
+
+
+
+ A cell mask. Non-null values correspond to cell ids + |
+ + required + | +
tolerance |
+
+ float | None
+ |
+
+
+
+ Tolerance parameter used by |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[Polygon]
+ |
+
+
+
+ List of |
+
sopa/segmentation/shapes.py
sopa.segmentation.shapes.rasterize(cell, shape, xy_min=[0, 0])
+
+Transform a cell polygon into a numpy array with value 1 where the polygon touches a pixel, else 0.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
cell |
+
+ Polygon
+ |
+
+
+
+ Cell polygon to rasterize. + |
+ + required + | +
shape |
+
+ tuple[int, int]
+ |
+
+
+
+ Image shape as a tuple (y, x). + |
+ + required + | +
xy_min |
+
+ tuple[int, int]
+ |
+
+
+
+ Tuple containing the origin of the image [x0, y0]. + |
+
+ [0, 0]
+ |
+
Returns:
+Type | +Description | +
---|---|
+ ndarray
+ |
+
+
+
+ The mask array. + |
+
sopa/segmentation/shapes.py
sopa.segmentation.stainings.StainingSegmentation
+
+
+sopa/segmentation/stainings.py
25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 |
|
__init__(sdata, method, channels, min_area=0, clip_limit=0.2, gaussian_sigma=1)
+
+Generalized staining-based segmentation
+Sequential segmentation (slower)
+from sopa.segmentation.stainings import StainingSegmentation
+
+method = ... # custom callable that runs segmentation on each patch
+
+segmentation = StainingSegmentation(sdata, method, "DAPI")
+cells = segmentation.run_patches(2000, 100)
+StainingSegmentation.add_shapes(sdata, cells, image_key, "method_name")
+
Parallel segmentation (faster)
+from sopa.segmentation.stainings import StainingSegmentation
+
+method = ... # custom callable that runs segmentation on each patch
+
+segmentation = StainingSegmentation(sdata, method, "DAPI")
+
+# Run all this in a parallel manner, e.g. on different jobs
+for i in range(len(sdata['sopa_patches'])):
+ segmentation.write_patch_cells("./temp_dir", i)
+
+cells = StainingSegmentation.read_patches_cells("./temp_dir")
+StainingSegmentation.add_shapes(sdata, cells, image_key, "method_name")
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
method |
+
+ Callable
+ |
+
+
+
+ A segmentation |
+ + required + | +
channels |
+
+ list[str] | str
+ |
+
+
+
+ One or a list of channel names used for segmentation + |
+ + required + | +
min_area |
+
+ float
+ |
+
+
+
+ Minimum area (in pixels^2) for a cell to be kept + |
+
+ 0
+ |
+
clip_limit |
+
+ float
+ |
+
+
+
+ Parameter for skimage.exposure.equalize_adapthist (applied before running cellpose) + |
+
+ 0.2
+ |
+
gaussian_sigma |
+
+ float
+ |
+
+
+
+ Parameter for scipy gaussian_filter (applied before running cellpose) + |
+
+ 1
+ |
+
sopa/segmentation/stainings.py
add_shapes(sdata, cells, image_key, shapes_key)
+
+
+ classmethod
+
+
+Adding shapely
polygon to the SpatialData
object
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
cells |
+
+ list[Polygon]
+ |
+
+
+
+ List of polygons after segmentation + |
+ + required + | +
image_key |
+
+ str
+ |
+
+
+
+ Key of the image on which segmentation has been run + |
+ + required + | +
shapes_key |
+
+ str
+ |
+
+
+
+ Name to provide to the geodataframe to be created + |
+ + required + | +
sopa/segmentation/stainings.py
read_patches_cells(patch_dir)
+
+
+ classmethod
+
+
+Read all patch segmentation results after running write_patch_cells
on all patches
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
patch_dir |
+
+ str
+ |
+
+
+
+ Directory provided when running |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ list[Polygon]
+ |
+
+
+
+ A list of cells represented as |
+
sopa/segmentation/stainings.py
run_patches(patch_width, patch_overlap)
+
+Run segmentation over all patches, in a sequential manner (this is slower than running all patches in parallel)
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
patch_width |
+
+ int
+ |
+
+
+
+ Width of the patches + |
+ + required + | +
patch_overlap |
+
+ int
+ |
+
+
+
+ Number of pixels of overlap between patches + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ list[Polygon]
+ |
+
+
+
+ A list of cells represented as |
+
sopa/segmentation/stainings.py
write_patch_cells(patch_dir, patch_index)
+
+Run segmentation on one patch, and save the result in a dedicated directory
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
patch_dir |
+
+ str
+ |
+
+
+
+ Directory inside which segmentation results will be saved + |
+ + required + | +
patch_index |
+
+ int
+ |
+
+
+
+ Index of the patch on which to run segmentation. NB: the number of patches is |
+ + required + | +
sopa/segmentation/stainings.py
sopa.stats.mean_distance(adata, group_key, target_group_key=None, ignore_zeros=False)
+
+Mean distance between two groups (typically, between cell-types, or between cell-types and domains)
+ +The distance is a number of hops, i.e. a distance of 10 between a pDC and a T cell means that there are 10 cells on the closest path from one to the other cell.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
group_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
target_group_key |
+
+ str | None
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
ignore_zeros |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ DataFrame
+ |
+
+
+
+
|
+
sopa/stats/distance.py
sopa.stats.geometrize_niches(adata, niche_key, buffer='auto', perc_area_th=0.05)
+
+Converts the niches to shapely polygons, and put into a GeoDataFrame
. Note that each niche can appear multiple times, as they can be separated by other niches ; in this case, we call them different "components" of the same niche ID.
You can show niches components with GeoPandas +
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData | SpatialData
+ |
+
+
+
+ An |
+ + required + | +
niche_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
buffer |
+
+ int | str
+ |
+
+
+
+ Expansion radius applied on components. By default, |
+
+ 'auto'
+ |
+
perc_area_th |
+
+ float
+ |
+
+
+
+ For each niche, components whose area is less than |
+
+ 0.05
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame
+ |
+
+
+
+ A |
+
sopa/stats/morpho.py
sopa.stats.niches_geometry_stats(adata, niche_key, aggregation='mean', key_added_suffix='_distance_to_niche_', **geometrize_niches_kwargs)
+
+Computes statistics over niches geometries
+ +n_components
: Number of connected component of a niche (a component is a group of neighbor cells with the same niche attribute)length
: Mean distance of the exterior/boundary of the components of a nichearea
: Mean area of the components of a nicheroundness
: Float value between 0 and 1. The higher the value, the closer to a circle. Computed via 4 * pi * area / length**2
mean_distance_to_niche_X
: mean distance to the niche (between the two closest points of the niches)Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData | SpatialData
+ |
+
+
+
+ An |
+ + required + | +
niche_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
aggregation |
+
+ str | list[str]
+ |
+
+
+
+ Aggregation mode. Either one string such as |
+
+ 'mean'
+ |
+
key_added_suffix |
+
+ str
+ |
+
+
+
+ Suffix added in the DataFrame columns. Defaults to "distance_to_niche". + |
+
+ '_distance_to_niche_'
+ |
+
geometrize_niches_kwargs |
+
+ str
+ |
+
+
+
+ Kwargs to the |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame
+ |
+
+
+
+ A |
+
sopa/stats/morpho.py
sopa.stats.cells_to_groups(adata, group_key, key_added_prefix=None, ignore_zeros=False)
+
+Compute the hop-distance between each cell and a cell category/group.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
group_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
key_added_prefix |
+
+ str | None
+ |
+
+
+
+ Prefix to the key added in |
+
+ None
+ |
+
ignore_zeros |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ DataFrame | None
+ |
+
+
+
+ A |
+
sopa/stats/distance.py
sopa.stats.spatial_neighbors(adata, radius, library_key=None, percentile=None, set_diag=False)
+
+Create a Delaunay graph from spatial coordinates. This function comes from squidpy.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData | SpatialData
+ |
+
+
+
+ AnnData object + |
+ + required + | +
radius |
+
+ tuple[float, float] | None
+ |
+
+
+
+ tuple that prunes the final graph to only contain edges in interval |
+ + required + | +
library_key |
+
+ str | None
+ |
+
+
+
+ Optional batch key in adata.obs + |
+
+ None
+ |
+
percentile |
+
+ float | None
+ |
+
+
+
+ Percentile of the distances to use as threshold. + |
+
+ None
+ |
+
set_diag |
+
+ bool
+ |
+
+
+
+ Whether to set the diagonal of the spatial connectivities to |
+
+ False
+ |
+
sopa/stats/_build.py
sopa.utils.data.uniform(*_, length=2048, cell_density=0.0001, n_points_per_cell=50, n_genes=5, c_coords=['DAPI', 'CK', 'CD3', 'CD20'], sigma_factor=0.2, seed=0, save_vertices=False, save_image=True, apply_blur=True)
+
+Generate a dummy dataset composed of cells generated uniformly in a square. It also has transcripts.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
length |
+
+ int
+ |
+
+
+
+ Size of the square, in pixels + |
+
+ 2048
+ |
+
cell_density |
+
+ float
+ |
+
+
+
+ Density of cells per pixel^2 + |
+
+ 0.0001
+ |
+
n_points_per_cell |
+
+ int
+ |
+
+
+
+ Mean number of transcripts per cell + |
+
+ 50
+ |
+
n_genes |
+
+ int
+ |
+
+
+
+ Number of gene names + |
+
+ 5
+ |
+
c_coords |
+
+ list[str]
+ |
+
+
+
+ Channel names + |
+
+ ['DAPI', 'CK', 'CD3', 'CD20']
+ |
+
sigma_factor |
+
+ float
+ |
+
+
+
+ Factor used to determine |
+
+ 0.2
+ |
+
seed |
+
+ int
+ |
+
+
+
+ Numpy random seed + |
+
+ 0
+ |
+
save_vertices |
+
+ bool
+ |
+
+
+
+ Whether to save the vertices of the cells (as points) + |
+
+ False
+ |
+
save_image |
+
+ bool
+ |
+
+
+
+ Whether to return an image + |
+
+ True
+ |
+
apply_blur |
+
+ bool
+ |
+
+
+
+ Whether to apply gaussian blur on the image (without blur, cells are just one pixel) + |
+
+ True
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A SpatialData object with a 2D image ( |
+
sopa/utils/data.py
17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 |
|
sopa.utils.data.blobs(*_, length=1024, n_points=10000, c_coords=['DAPI', 'CK', 'CD3', 'CD20'], **kwargs)
+
+Adapts the blobs dataset from SpatialData for sopa. Please refer to the SpatialData documentation
+ +sopa/utils/data.py
sopa.utils.image.scale_dtype(arr, dtype)
+
+Change the dtype of an array but keep the scale compared to the type maximum value.
+Example
+For an array of dtype uint8
being transformed to np.uint16
, the value 255
will become 65535
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
arr |
+
+ ndarray
+ |
+
+
+
+ A |
+ + required + | +
dtype |
+
+ dtype
+ |
+
+
+
+ Target |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ ndarray
+ |
+
+
+
+ A scaled |
+
sopa/utils/image.py
sopa.utils.image.resize(xarr, scale_factor)
+
+Resize a xarray image
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
xarr |
+
+ DataArray
+ |
+
+
+
+ A |
+ + required + | +
scale_factor |
+
+ float
+ |
+
+
+
+ Scale factor of resizing, e.g. |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Array
+ |
+
+
+
+ Resized dask array + |
+
sopa/utils/image.py
sopa.utils.image.resize_numpy(arr, scale_factor, dims, output_shape)
+
+Resize a numpy image
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
arr |
+
+ ndarray
+ |
+
+
+
+ a |
+ + required + | +
scale_factor |
+
+ float
+ |
+
+
+
+ Scale factor of resizing, e.g. |
+ + required + | +
dims |
+
+ list[str]
+ |
+
+
+
+ List of dimension names. Only |
+ + required + | +
output_shape |
+
+ list[int]
+ |
+
+
+
+ Size of the output array + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ ndarray
+ |
+
+
+
+ Resized array + |
+
sopa/utils/image.py
sopa.utils.polygon_crop.polygon_selection(sdata, intermediate_image=None, intermediate_polygon=None, channels=None, scale_factor=10, margin_ratio=0.1)
+
+Crop an image based on a user-defined polygon (interactive mode).
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
intermediate_image |
+
+ str | None
+ |
+
+
+
+ Path to the intermediate image, with a |
+
+ None
+ |
+
intermediate_polygon |
+
+ str | None
+ |
+
+
+
+ Path to the intermediate polygon, with a |
+
+ None
+ |
+
channels |
+
+ list[str] | None
+ |
+
+
+
+ List of channel names to be displayed. Optional if there are already only 1 or 3 channels. + |
+
+ None
+ |
+
scale_factor |
+
+ float
+ |
+
+
+
+ Resize the image by this value (high value for a lower memory usage) + |
+
+ 10
+ |
+
margin_ratio |
+
+ float
+ |
+
+
+
+ Ratio of the image margin on the display (compared to the image size) + |
+
+ 0.1
+ |
+
sopa/utils/polygon_crop.py
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var Ha=/["'&<>]/;Un.exports=$a;function $a(e){var t=""+e,r=Ha.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i