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..33eb3074 --- /dev/null +++ b/404.html @@ -0,0 +1,1086 @@ + + + +
+ + + + + + + + + + + + + + +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 | +
---|---|
+ SpatialElement
+ |
+
+
+
+ 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 DataTree
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
image |
+
+ DataTree
+ |
+
+
+
+ a |
+ + required + | +
Yields:
+Type | +Description | +
---|---|
+ DataArray
+ |
+
+
+
+ Each scale (as a |
+
sopa/_sdata.py
sopa._sdata.get_spatial_image(sdata, key=None, return_key=False, valid_attr=SopaAttrs.CELL_SEGMENTATION)
+
+Gets a DataArray 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
+ |
+
valid_attr |
+
+ str
+ |
+
+
+
+ Attribute that the image must have to be considered valid. + |
+
+ CELL_SEGMENTATION
+ |
+
Returns:
+Type | +Description | +
---|---|
+ DataArray | tuple[str, DataArray]
+ |
+
+
+
+ If |
+
sopa/_sdata.py
sopa.annotation.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.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
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, image_models_kwargs=None, imread_kwargs=None, **kwargs)
+
+Read Xenium data as a SpatialData
object. For more information, refer to spatialdata-io.
transcripts.parquet
: transcripts locations and namesexperiment.xenium
: metadata filemorphology_focus.ome.tif
: morphology image (or a directory, for recent versions of the Xenium)Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to the Xenium directory containing all the experiment files + |
+ + required + | +
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
imread_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/xenium.py
sopa.io.merscope(path, backend=None, z_layers=3, region_name=None, slide_name=None, image_models_kwargs=None, imread_kwargs=None, **kwargs)
+
+Read MERSCOPE data as a SpatialData
object. For more information, refer to spatialdata-io.
detected_transcripts.csv
: transcripts locations and namesimages
directoryimages/micron_to_mosaic_pixel_transform.csv
: affine transformationParameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to the MERSCOPE directory containing all the experiment files + |
+ + required + | +
backend |
+
+ Literal['dask_image', 'rioxarray'] | None
+ |
+
+
+
+ Either |
+
+ None
+ |
+
z_layers |
+
+ int | list[int] | None
+ |
+
+
+
+ Indices of the z-layers to consider. Either one |
+
+ 3
+ |
+
region_name |
+
+ str | None
+ |
+
+
+
+ Name of the region of interest, e.g., |
+
+ None
+ |
+
slide_name |
+
+ str | None
+ |
+
+
+
+ Name of the slide/run. If |
+
+ None
+ |
+
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
imread_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/merscope.py
sopa.io.cosmx(path, dataset_id=None, fov=None, read_proteins=False, image_models_kwargs=None, imread_kwargs=None)
+
+Read Cosmx Nanostring data. The fields of view are stitched together, except if fov
is provided.
*_fov_positions_file.csv
or *_fov_positions_file.csv.gz
: FOV locationsMorphology2D
directory: all the FOVs morphology imagesMorphology_ChannelID_Dictionary.txt
: Morphology channels names*_tx_file.csv.gz
or *_tx_file.csv
: Transcripts location and namesread_proteins
is True
, all the images under the nested ProteinImages
directories will be readParameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to the root directory containing Nanostring files. + |
+ + required + | +
dataset_id |
+
+ Optional[str]
+ |
+
+
+
+ Optional name of the dataset (needs to be provided if not infered). + |
+
+ None
+ |
+
fov |
+
+ int | str | None
+ |
+
+
+
+ Name or number of one single field of view to be read. If a string is provided, an example of correct syntax is "F008". By default, reads all FOVs. + |
+
+ None
+ |
+
read_proteins |
+
+ bool
+ |
+
+
+
+ Whether to read the proteins or the transcripts. + |
+
+ False
+ |
+
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
imread_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/cosmx.py
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 |
|
sopa.io.macsima(path, **kwargs)
+
+Read MACSIMA data as a SpatialData
object
For all dulicated name, their index will be added in brackets after, for instance you may find DAPI (1)
.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the directory containing the MACSIMA |
+ + required + | +
kwargs |
+
+ int
+ |
+
+
+
+ Kwargs for the |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/macsima.py
sopa.io.phenocycler(path, channels_renaming=None, image_models_kwargs=None)
+
+Read Phenocycler data as a SpatialData
object
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to a |
+ + required + | +
channels_renaming |
+
+ dict | None
+ |
+
+
+
+ A dictionnary whose keys correspond to channels and values to their corresponding new name. Not all channels need to be renamed. + |
+
+ None
+ |
+
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/phenocycler.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
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
imread_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/hyperion.py
sopa.io.aicsimageio(path, z_stack=0, image_models_kwargs=None, aics_kwargs=None)
+
+Read an image using AICSImageIO. It supports special formats such as ND2
, CZI
, LIF
, or DV
.
Extra dependencies
+To use this reader, you'll need the aicsimageio
dependency (pip install aicsimageio
). To read .czi
images, you'll also need to install aicspylibczi
(for instance pip install aicspylibczi
).
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ Path
+ |
+
+
+
+ Path to the image file + |
+ + required + | +
z_stack |
+
+ int
+ |
+
+
+
+ (Only for 3D images) Index of the stack in the z-axis to use. + |
+
+ 0
+ |
+
image_models_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
aics_kwargs |
+
+ dict | None
+ |
+
+
+
+ Keyword arguments passed to |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/aics.py
sopa.io.ome_tif(path, as_image=False)
+
+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 + | +
as_image |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ DataArray | SpatialData
+ |
+
+
+
+ A |
+
sopa/io/reader/utils.py
sopa.io.wsi(path, chunks=(3, 256, 256), as_image=False, backend='tiffslide')
+
+Read a WSI into a SpatialData
object
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
path |
+
+ str | Path
+ |
+
+
+
+ Path to the WSI + |
+ + required + | +
chunks |
+
+ tuple[int, int, int]
+ |
+
+
+
+ Tuple representing the chunksize for the dimensions |
+
+ (3, 256, 256)
+ |
+
as_image |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
backend |
+
+ str
+ |
+
+
+
+ The library to use as a backend in order to load the WSI. One of: |
+
+ 'tiffslide'
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData | DataTree
+ |
+
+
+
+ A |
+
sopa/io/reader/wsi.py
sopa.io.uniform(*_, length=2048, cell_density=0.0001, n_points_per_cell=100, c_coords=['DAPI', 'CK', 'CD3', 'CD20'], genes=['EPCAM', 'CD3E', 'CD20', 'CXCL4', 'CXCL10'], sigma_factor=0.05, pixel_size=0.1, seed=0, include_vertices=False, include_image=True, apply_blur=True, as_output=False, transcript_cell_id_as_merscope=False)
+
+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 + |
+
+ 100
+ |
+
c_coords |
+
+ list[str]
+ |
+
+
+
+ Channel names + |
+
+ ['DAPI', 'CK', 'CD3', 'CD20']
+ |
+
genes |
+
+ int | list[str]
+ |
+
+
+
+ Number of different genes, or list of gene names + |
+
+ ['EPCAM', 'CD3E', 'CD20', 'CXCL4', 'CXCL10']
+ |
+
sigma_factor |
+
+ float
+ |
+
+
+
+ Factor used to determine |
+
+ 0.05
+ |
+
pixel_size |
+
+ float
+ |
+
+
+
+ Number of microns in one pixel. + |
+
+ 0.1
+ |
+
seed |
+
+ int
+ |
+
+
+
+ Numpy random seed + |
+
+ 0
+ |
+
include_vertices |
+
+ bool
+ |
+
+
+
+ Whether to include the vertices of the cells (as points) in the spatialdata object + |
+
+ False
+ |
+
include_image |
+
+ bool
+ |
+
+
+
+ Whether to include the image in the spatialdata object + |
+
+ True
+ |
+
apply_blur |
+
+ bool
+ |
+
+
+
+ Whether to apply gaussian blur on the image (without blur, cells are just one pixel) + |
+
+ True
+ |
+
as_output |
+
+ bool
+ |
+
+
+
+ If |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ SpatialData
+ |
+
+
+
+ A SpatialData object with a 2D image ( |
+
sopa/utils/data.py
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 |
|
sopa.io.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.io.write(path, sdata, image_key=None, shapes_key=None, points_key=None, gene_column=None, pixel_size=0.2125, 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
+ |
+
pixel_size |
+
+ float
+ |
+
+
+
+ Number of microns in a pixel. Invalid value can lead to inconsistent scales in the Explorer. + |
+
+ 0.2125
+ |
+
layer |
+
+ str | None
+ |
+
+
+
+ Layer of the AnnData table where the gene counts are saved. If |
+
+ 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
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 |
|
sopa.io.align(sdata, image, transformation_matrix_path, image_key=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 |
+
+ DataArray
+ |
+
+
+
+ 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
+ |
+
overwrite |
+
+ bool
+ |
+
+
+
+ Whether to overwrite the image, if already existing. + |
+
+ False
+ |
+
sopa/io/explorer/images.py
sopa.io.add_explorer_selection(sdata, path, shapes_key, image_key=None, pixel_size=0.2125)
+
+After saving a selection on the Xenium Explorer, it will add all polygons inside sdata.shapes[shapes_key]
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
path |
+
+ str
+ |
+
+
+
+ The path to the |
+ + required + | +
shapes_key |
+
+ str
+ |
+
+
+
+ The name to provide to the shapes + |
+ + required + | +
image_key |
+
+ str | None
+ |
+
+
+
+ The original image name + |
+
+ None
+ |
+
pixel_size |
+
+ float
+ |
+
+
+
+ Number of microns in a pixel. It must be the same value as the one used in |
+
+ 0.2125
+ |
+
sopa/io/explorer/utils.py
sopa.io.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.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.write_image(path, image, lazy=True, tile_width=TILE_SIZE, n_subscales=5, pixel_size=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 |
+
+ DataTree | DataArray | ndarray
+ |
+
+
+
+ Image of shape |
+ + required + | +
lazy |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
tile_width |
+
+ int
+ |
+
+
+
+ Xenium tile width (do not update). + |
+
+ TILE_SIZE
+ |
+
n_subscales |
+
+ int
+ |
+
+
+
+ Number of sub-scales in the pyramidal image. + |
+
+ 5
+ |
+
pixel_size |
+
+ 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.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.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.patches.Patches2D
+
+
+Compute 2D-patches with overlaps. This can be done on an image or a DataFrame.
+ + + +Attributes:
+Name | +Type | +Description | +
---|---|---|
polygons |
+
+ list[Polygon]
+ |
+
+
+
+ List of |
+
bboxes |
+
+ ndarray
+ |
+
+
+
+ Array of shape |
+
ilocs |
+
+ ndarray
+ |
+
+
+
+ Array of shape |
+
sopa/patches/patches.py
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 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 |
|
__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 (image or points) + |
+ + 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/patches/patches.py
__len__()
+
+patchify_transcripts(temp_dir, cell_key=None, unassigned_value=None, use_prior=False, config={}, config_path=None, config_name=SopaFiles.TOML_CONFIG_FILE, csv_name=SopaFiles.TRANSCRIPTS_FILE, min_transcripts_per_patch=4000, shapes_key=SopaKeys.CELLPOSE_BOUNDARIES)
+
+Creation of patches for the transcripts.
+Prior segmentation usage
+To save assign a prior segmentation to each transcript, you can either use cell_key
or use_prior
:
cell_key
to denote the column of the transcript dataframe containing the cell IDs (and optionaly unassigned_value
).use_prior
(no need to provide cell_key
and unassigned_value
).Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
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. If |
+
+ False
+ |
+
config |
+
+ dict
+ |
+
+
+
+ Dictionnary of segmentation parameters + |
+
+ {}
+ |
+
config_path |
+
+ str | None
+ |
+
+
+
+ Path to the segmentation config file (you can also directly provide the argument via the |
+
+ None
+ |
+
config_name |
+
+ str
+ |
+
+
+
+ Name of the config file to be saved in each patch subdirectory + |
+
+ TOML_CONFIG_FILE
+ |
+
csv_name |
+
+ str
+ |
+
+
+
+ Name of the CSV file to be saved in each patch subdirectory + |
+
+ TRANSCRIPTS_FILE
+ |
+
min_transcripts_per_patch |
+
+ int
+ |
+
+
+
+ Minimum number of transcripts for a patch to be considered for segmentation + |
+
+ 4000
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[int]
+ |
+
+
+
+ A list of patches indices. Each index correspond to the name of a subdirectory inside |
+
sopa/patches/patches.py
write(overwrite=True, shapes_key=None)
+
+Save patches in sdata.shapes["sopa_patches"]
(or by the key specified)
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
overwrite |
+
+ bool
+ |
+
+
+
+ Whether to overwrite patches if existing + |
+
+ True
+ |
+
shapes_key |
+
+ str | None
+ |
+
+
+
+ Optional name of the shapes to be saved. By default, uses "sopa_patches". + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame
+ |
+
+
+
+ The saved GeoDataFrame + |
+
sopa/patches/patches.py
sopa.patches.infer.infer_wsi_patches(sdata, model, patch_width, patch_overlap=0, level=0, magnification=None, image_key=None, batch_size=32, device=None)
+
+Create an image made of patch based predictions of a WSI image.
+Info
+The image will be saved into the SpatialData
object with the key sopa_{model_name}
(see the argument below).
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
model |
+
+ Callable | str
+ |
+
+
+
+ Callable that takes as an input a tensor of size (batch_size, channels, x, y) and returns a vector for each tile (batch_size, emb_dim), or a string with the name of one of the available models ( |
+ + required + | +
patch_width |
+
+ int
+ |
+
+
+
+ Width (pixels) of the patches. + |
+ + required + | +
patch_overlap |
+
+ int
+ |
+
+
+
+ Width (pixels) of the overlap between the patches. + |
+
+ 0
+ |
+
level |
+
+ int | None
+ |
+
+
+
+ Image level on which the processing is performed. Either |
+
+ 0
+ |
+
magnification |
+
+ int | None
+ |
+
+
+
+ The target magnification on which the processing is performed. If |
+
+ None
+ |
+
image_key |
+
+ str | None
+ |
+
+
+
+ Optional image key of the WSI image, unecessary if there is only one image. + |
+
+ None
+ |
+
batch_size |
+
+ int
+ |
+
+
+
+ Mini-batch size used during inference. + |
+
+ 32
+ |
+
device |
+
+ str
+ |
+
+
+
+ Device used for the computer vision model. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ DataArray | bool
+ |
+
+
+
+ If the processing was successful, returns the |
+
sopa/patches/infer.py
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 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 |
|
sopa.patches.cluster.cluster_embeddings(sdata, element, method='leiden', key_added='cluster', **method_kwargs)
+
+Cluster the patches embeddings using a clustering method
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
element |
+
+ DataArray | str
+ |
+
+
+
+ The |
+ + required + | +
method |
+
+ Callable | str
+ |
+
+
+
+ Callable that takes as an input an array of size |
+
+ 'leiden'
+ |
+
key_added |
+
+ str
+ |
+
+
+
+ The key containing the clusters to be added to the patches |
+
+ 'cluster'
+ |
+
method_kwargs |
+
+ str
+ |
+
+
+
+ kwargs provided to the method callable + |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame
+ |
+
+
+
+ The patches |
+
sopa/patches/cluster.py
sopa.segmentation.aggregation.overlay_segmentation(sdata, shapes_key, gene_column=None, area_ratio_threshold=0.25, image_key=None, save_table=False)
+
+Overlay a segmentation on top of an existing segmentation
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
shapes_key |
+
+ str
+ |
+
+
+
+ The key of the new shapes to be added + |
+ + required + | +
gene_column |
+
+ str | None
+ |
+
+
+
+ Key of the points dataframe containing the genes names + |
+
+ None
+ |
+
area_ratio_threshold |
+
+ float
+ |
+
+
+
+ Threshold between 0 and 1. For each original cell overlapping with a new cell, we compute the overlap-area/cell-area, if above the threshold the cell is removed. + |
+
+ 0.25
+ |
+
image_key |
+
+ str | None
+ |
+
+
+
+ Optional key of the original image + |
+
+ None
+ |
+
save_table |
+
+ bool
+ |
+
+
+
+ Whether to save the new table on-disk or not + |
+
+ False
+ |
+
sopa/segmentation/aggregation.py
sopa.segmentation.aggregation.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/aggregation.py
sopa.segmentation.aggregation._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 |
+
+ DataArray
+ |
+
+
+
+ A |
+ + required + | +
geo_df |
+
+ GeoDataFrame | list[Polygon]
+ |
+
+
+
+ A |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ ndarray
+ |
+
+
+
+ A numpy |
+
sopa/segmentation/aggregation.py
sopa.segmentation.aggregation.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 | None
+ |
+
+
+
+ If the cell boundaries are not yet in |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ AnnData
+ |
+
+
+
+ An |
+
sopa/segmentation/aggregation.py
sopa.segmentation.aggregation._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/aggregation.py
sopa.segmentation.aggregation.Aggregator
+
+
+Perform transcript count and channel averaging over a SpatialData
object
sopa/segmentation/aggregation.py
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 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 |
|
__init__(sdata, overwrite=True, image_key=None, shapes_key=None)
+
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
overwrite |
+
+ bool
+ |
+
+
+
+ If |
+
+ True
+ |
+
image_key |
+
+ str | None
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
shapes_key |
+
+ str | None
+ |
+
+
+
+ Key of |
+
+ None
+ |
+
sopa/segmentation/aggregation.py
compute_table(gene_column=None, average_intensities=True, expand_radius_ratio=0, min_transcripts=0, min_intensity_ratio=0, save_table=True)
+
+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 + |
+
+ None
+ |
+
average_intensities |
+
+ bool
+ |
+
+
+
+ Whether to average the channels intensities inside cells polygons + |
+
+ True
+ |
+
expand_radius_ratio |
+
+ float
+ |
+
+
+
+ Cells polygons will be expanded by |
+
+ 0
+ |
+
min_transcripts |
+
+ int
+ |
+
+
+
+ Minimum amount of transcript to keep a cell + |
+
+ 0
+ |
+
min_intensity_ratio |
+
+ float
+ |
+
+
+
+ Cells whose mean channel intensity is less than |
+
+ 0
+ |
+
save_table |
+
+ bool
+ |
+
+
+
+ Whether the table should be saved on disk or not + |
+
+ True
+ |
+
sopa/segmentation/aggregation.py
221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 |
|
sopa.segmentation.methods.cellpose_patch(diameter, channels, model_type='cyto3', pretrained_model=False, cellpose_model_kwargs=None, **cellpose_eval_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 + |
+
+ 'cyto3'
+ |
+
pretrained_model |
+
+ str | bool
+ |
+
+
+
+ Path to the pretrained model to be loaded + |
+
+ False
+ |
+
cellpose_model_kwargs |
+
+ dict | None
+ |
+
+
+
+ Kwargs to be provided to the |
+
+ None
+ |
+
**cellpose_eval_kwargs |
+
+ int
+ |
+
+
+
+ Kwargs to be provided to |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ Callable
+ |
+
+
+
+ A |
+
sopa/segmentation/methods.py
sopa.segmentation.Patches2D
+
+
+Compute 2D-patches with overlaps. This can be done on an image or a DataFrame.
+ + + +Attributes:
+Name | +Type | +Description | +
---|---|---|
polygons |
+
+ list[Polygon]
+ |
+
+
+
+ List of |
+
bboxes |
+
+ ndarray
+ |
+
+
+
+ Array of shape |
+
ilocs |
+
+ ndarray
+ |
+
+
+
+ Array of shape |
+
sopa/patches/patches.py
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 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 |
|
__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 (image or points) + |
+ + 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/patches/patches.py
__len__()
+
+patchify_transcripts(temp_dir, cell_key=None, unassigned_value=None, use_prior=False, config={}, config_path=None, config_name=SopaFiles.TOML_CONFIG_FILE, csv_name=SopaFiles.TRANSCRIPTS_FILE, min_transcripts_per_patch=4000, shapes_key=SopaKeys.CELLPOSE_BOUNDARIES)
+
+Creation of patches for the transcripts.
+Prior segmentation usage
+To save assign a prior segmentation to each transcript, you can either use cell_key
or use_prior
:
cell_key
to denote the column of the transcript dataframe containing the cell IDs (and optionaly unassigned_value
).use_prior
(no need to provide cell_key
and unassigned_value
).Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
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. If |
+
+ False
+ |
+
config |
+
+ dict
+ |
+
+
+
+ Dictionnary of segmentation parameters + |
+
+ {}
+ |
+
config_path |
+
+ str | None
+ |
+
+
+
+ Path to the segmentation config file (you can also directly provide the argument via the |
+
+ None
+ |
+
config_name |
+
+ str
+ |
+
+
+
+ Name of the config file to be saved in each patch subdirectory + |
+
+ TOML_CONFIG_FILE
+ |
+
csv_name |
+
+ str
+ |
+
+
+
+ Name of the CSV file to be saved in each patch subdirectory + |
+
+ TRANSCRIPTS_FILE
+ |
+
min_transcripts_per_patch |
+
+ int
+ |
+
+
+
+ Minimum number of transcripts for a patch to be considered for segmentation + |
+
+ 4000
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[int]
+ |
+
+
+
+ A list of patches indices. Each index correspond to the name of a subdirectory inside |
+
sopa/patches/patches.py
write(overwrite=True, shapes_key=None)
+
+Save patches in sdata.shapes["sopa_patches"]
(or by the key specified)
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
overwrite |
+
+ bool
+ |
+
+
+
+ Whether to overwrite patches if existing + |
+
+ True
+ |
+
shapes_key |
+
+ str | None
+ |
+
+
+
+ Optional name of the shapes to be saved. By default, uses "sopa_patches". + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame
+ |
+
+
+
+ The saved GeoDataFrame + |
+
sopa/patches/patches.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] | tuple[ndarray[Polygon], ndarray]
+ |
+
+
+
+ Array of resolved cells polygons. If |
+
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 | MultiPolygon
+ |
+
+
+
+ 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 +200 +201 +202 +203 +204 |
|
__init__(sdata, method, channels, image_key=None, min_area=0, clip_limit=0.2, clahe_kernel_size=None, 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")
+segmentation.write_patches_cells("./temp_dir")
+
+cells = StainingSegmentation.read_patches_cells("./temp_dir")
+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. If only one channel is provided, the image given to the |
+ + required + | +
image_key |
+
+ str | None
+ |
+
+
+
+ Optional key of |
+
+ None
+ |
+
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
+ |
+
clahe_kernel_size |
+
+ int | Iterable[int] | None
+ |
+
+
+
+ Parameter for skimage.exposure.equalize_adapthist (applied before running cellpose) + |
+
+ None
+ |
+
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 | list[str]
+ |
+
+
+
+ Directory provided when running |
+ + 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.segmentation.tissue.hsv_otsu(*args, **kwargs)
+
+sopa/segmentation/tissue.py
sopa.segmentation.transcripts.resolve(sdata, temp_dir, gene_column, patches_dirs=None, min_area=0, shapes_key=SopaKeys.BAYSOR_BOUNDARIES)
+
+Concatenate all the per-patch segmentation runs and resolve the conflicts. Resulting cells boundaries are saved in the SpatialData
object.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
temp_dir |
+
+ str
+ |
+
+
+
+ Temporary directory used to store all the patches subdirectories (one subdirectory for one patch and for one segmentation 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/transcripts.py
sopa.spatial.sjoin(sdata, left_element, right_element, how='left', target_coordinate_system=None, **kwargs)
+
+Spatial join of two shapes
GeoDataFrames, as in geopandas.sjoin.
Shapes are automatically aligned on the same coordinate system (which can be chosen using the target_coordinate_system
argument).
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sdata |
+
+ SpatialData
+ |
+
+
+
+ A |
+ + required + | +
left_element |
+
+ str | GeoDataFrame
+ |
+
+
+
+ The name of a GeoDataFrame in |
+ + required + | +
right_element |
+
+ str | GeoDataFrame
+ |
+
+
+
+ The name of a GeoDataFrame in |
+ + required + | +
how |
+
+ str
+ |
+
+
+
+ The GeoPandas type of join. By default, left geometries are retained. + |
+
+ 'left'
+ |
+
target_coordinate_system |
+
+ str | None
+ |
+
+
+
+ The name of the coordinate system on which the shapes will be transformed. By default, uses the intrinsic coordinate system of the |
+
+ None
+ |
+
**kwargs |
+
+ int
+ |
+
+
+
+ Kwargs provided to the geopandas.sjoin function + |
+
+ {}
+ |
+
Returns:
+Type | +Description | +
---|---|
+ GeoDataFrame
+ |
+
+
+
+ The joined |
+
sopa/spatial/utils.py
sopa.spatial.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/spatial/distance.py
sopa.spatial.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/spatial/morpho.py
sopa.spatial.niches_geometry_stats(adata, niche_key, aggregation='min', 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 |
+
+ 'min'
+ |
+
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/spatial/morpho.py
sopa.spatial.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/spatial/distance.py
sopa.spatial.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/spatial/_build.py
sopa.spatial.prepare_network(adata, cell_type_key, niche_key, clip_weight=3, node_colors=('#5c7dc4', '#f05541'), node_sizes=(1.3, 5))
+
+Create a dataframe representing weights between cell-types and/or niches. +This can be later use to plot a cell-type/niche represention of a whole slide +using the netgraph library.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
adata |
+
+ AnnData
+ |
+
+
+
+ An |
+ + required + | +
cell_type_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
niche_key |
+
+ str
+ |
+
+
+
+ Key of |
+ + required + | +
clip_weight |
+
+ float
+ |
+
+
+
+ Maximum weight + |
+
+ 3
+ |
+
node_colors |
+
+ tuple[str]
+ |
+
+
+
+ Tuple of (cell-type color, niche color) + |
+
+ ('#5c7dc4', '#f05541')
+ |
+
node_sizes |
+
+ float
+ |
+
+
+
+ Tuple of (cell-type size, niche size) + |
+
+ (1.3, 5)
+ |
+
Returns:
+Type | +Description | +
---|---|
+ tuple[DataFrame, dict, dict, dict]
+ |
+
+
+
+ A DataFrame of weights between cell-types and/or niches, and three dict for netgraph display + |
+
sopa/spatial/distance.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