Skip to content

Commit

Permalink
update some documents.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanliwei-genomics-cn committed Oct 20, 2023
1 parent 8a58b88 commit 876c2e6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions docs/source/Tutorials/Cell_Segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"\n",
"All processes of cell segmentation will perform tissue segmentation beforehand. You could specify the method by `tissue_seg_method` and the path to tissue segmentation model file by `tissue_seg_model_path`. We strongly recommend setting `tissue_seg_method=1` which is based on deep learning and is more effective, while 0 is based on OpenCV.\n",
"\n",
"Download the [Tissue Segmentation Model](https://pan.genomics.cn/ucdisk/s/ai22e2).\n",
"Download the [Tissue Segmentation Model](http://116.6.21.110:8090/share/dd965cba-7c1f-40b2-a275-0150890e005f).\n",
"\n",
"More detail about [Tissue Segmentation](https://stereopy.readthedocs.io/en/latest/Tutorials/Tissue_Segmentation.html)."
]
Expand Down Expand Up @@ -372,7 +372,7 @@
"metadata": {},
"outputs": [],
"source": [
"from stereo.algorithm import Cellpose as cp \n",
"from stereo.algorithm import cell_pose as cp \n",
"\n",
"image=\"./Cellpose_DemoImage.tif\"\n",
"output=\"./Cellpose_DemoImage_mask.tif\"\n",
Expand Down
5 changes: 5 additions & 0 deletions docs/source/content/032_API_StPipeline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ which is compromised of basic preprocessing, embedding, clustering, and so on.
core.StPipeline.gaussian_smooth
core.StPipeline.annotation
algorithm.single_r.SingleR.main
algorithm.batch_qc.BatchQc.main
algorithm.spatial_alignment.SpatialAlignment.main
algorithm.spatial_alignment.pairwise_align
algorithm.spatial_alignment.center_align
algorithm.get_niche.GetNiche.main
algorithm.gen_ccc_micro_envs.GenCccMicroEnvs.main
algorithm.cell_cell_communication.CellCellCommunication.main
algorithm.regulatory_network_inference.RegulatoryNetworkInference.main
algorithm.co_occurrence.CoOccurrence.main
algorithm.community_detection.CommunityDetection.main
algorithm.time_series_analysis.TimeSeriesAnalysis.main
algorithm.dendrogram.Dendrogram.main
1 change: 1 addition & 0 deletions stereo/algorithm/spatial_alignment/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# flake8: noqa
from .spatial_alignment import SpatialAlignment
from .methods import pairwise_align, center_align
78 changes: 36 additions & 42 deletions stereo/algorithm/spatial_alignment/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,23 @@ def pairwise_align(
"""
Calculates and returns optimal alignment of two slices.
Args:
sliceA: Slice A to align.
sliceB: Slice B to align.
alpha: Alignment tuning parameter. Note: 0 <= alpha <= 1.
dissimilarity: Expression dissimilarity measure: ``'kl'`` or ``'euclidean'``.
use_rep: If ``None``, uses ``slice.X`` to calculate dissimilarity between spots, otherwise uses the representation given by ``slice.obsm[use_rep]``.
G_init (array-like, optional): Initial mapping to be used in FGW-OT, otherwise default is uniform mapping.
a_distribution (array-like, optional): Distribution of sliceA spots, otherwise default is uniform.
b_distribution (array-like, optional): Distribution of sliceB spots, otherwise default is uniform.
numItermax: Max number of iterations during FGW-OT.
norm: If ``True``, scales spatial distances such that neighboring spots are at distance 1. Otherwise, spatial distances remain unchanged.
backend: Type of backend to run calculations. For list of backends available on system: ``ot.backend.get_backend_list()``.
use_gpu: If ``True``, use gpu. Otherwise, use cpu. Currently we only have gpu support for Pytorch.
return_obj: If ``True``, additionally returns objective function output of FGW-OT.
verbose: If ``True``, FGW-OT is verbose.
gpu_verbose: If ``True``, print whether gpu is being used to user.
Returns:
- Alignment of spots.
If ``return_obj = True``, additionally returns:
- Objective function output of FGW-OT.
:param sliceA: Slice A to align.
:param sliceB: Slice B to align.
:param alpha: Alignment tuning parameter. Note: 0 <= alpha <= 1.
:param dissimilarity: Expression dissimilarity measure: ``'kl'`` or ``'euclidean'``.
:param use_rep: If ``None``, uses ``slice.X`` to calculate dissimilarity between spots, otherwise uses the representation given by ``slice.obsm[use_rep]``.
:param G_init (array-like, optional): Initial mapping to be used in FGW-OT, otherwise default is uniform mapping.
:param a_distribution (array-like, optional): Distribution of sliceA spots, otherwise default is uniform.
:param b_distribution (array-like, optional): Distribution of sliceB spots, otherwise default is uniform.
:param numItermax: Max number of iterations during FGW-OT.
:param norm: If ``True``, scales spatial distances such that neighboring spots are at distance 1. Otherwise, spatial distances remain unchanged.
:param backend: Type of backend to run calculations. For list of backends available on system: ``ot.backend.get_backend_list()``.
:param use_gpu: If ``True``, use gpu. Otherwise, use cpu. Currently we only have gpu support for Pytorch.
:param return_obj: If ``True``, additionally returns objective function output of FGW-OT.
:param verbose: If ``True``, FGW-OT is verbose.
:param gpu_verbose: If ``True``, print whether gpu is being used to user.
:return: Alignment of spots. If ``return_obj = True``, additionally returns objective function output of FGW-OT.
""" # noqa

# Determine if gpu or cpu is being used
Expand Down Expand Up @@ -203,26 +197,26 @@ def center_align(
"""
Computes center alignment of slices.
Args:
initial_slice: Slice to use as the initialization for center alignment; Make sure to include gene expression and spatial information.
slices: List of slices to use in the center alignment.
lmbda (array-like, optional): List of probability weights assigned to each slice; If ``None``, use uniform weights.
alpha: Alignment tuning parameter. Note: 0 <= alpha <= 1.
n_components: Number of components in NMF decomposition.
threshold: Threshold for convergence of W and H during NMF decomposition.
max_iter: Maximum number of iterations for our center alignment algorithm.
dissimilarity: Expression dissimilarity measure: ``'kl'`` or ``'euclidean'``.
norm: If ``True``, scales spatial distances such that neighboring spots are at distance 1. Otherwise, spatial distances remain unchanged.
random_seed: Set random seed for reproducibility.
pis_init: Initial list of mappings between 'A' and 'slices' to solver. Otherwise, default will automatically calculate mappings.
distributions (List[array-like], optional): Distributions of spots for each slice. Otherwise, default is uniform.
backend: Type of backend to run calculations. For list of backends available on system: ``ot.backend.get_backend_list()``.
use_gpu: If ``True``, use gpu. Otherwise, use cpu. Currently we only have gpu support for Pytorch.
verbose: If ``True``, FGW-OT is verbose.
gpu_verbose: If ``True``, print whether gpu is being used to user.
Returns:
:param initial_slice: Slice to use as the initialization for center alignment; Make sure to include gene expression and spatial information.
:param slices: List of slices to use in the center alignment.
:param lmbda (array-like, optional): List of probability weights assigned to each slice; If ``None``, use uniform weights.
:param alpha: Alignment tuning parameter. Note: 0 <= alpha <= 1.
:param n_components: Number of components in NMF decomposition.
:param threshold: Threshold for convergence of W and H during NMF decomposition.
:param max_iter: Maximum number of iterations for our center alignment algorithm.
:param dissimilarity: Expression dissimilarity measure: ``'kl'`` or ``'euclidean'``.
:param norm: If ``True``, scales spatial distances such that neighboring spots are at distance 1. Otherwise, spatial distances remain unchanged.
:param random_seed: Set random seed for reproducibility.
:param pis_init: Initial list of mappings between 'A' and 'slices' to solver. Otherwise, default will automatically calculate mappings.
:param distributions (List[array-like], optional): Distributions of spots for each slice. Otherwise, default is uniform.
:param backend: Type of backend to run calculations. For list of backends available on system: ``ot.backend.get_backend_list()``.
:param use_gpu: If ``True``, use gpu. Otherwise, use cpu. Currently we only have gpu support for Pytorch.
:param verbose: If ``True``, FGW-OT is verbose.
:param gpu_verbose: If ``True``, print whether gpu is being used to user.
:return:
- Inferred center slice with full and low dimensional representations (W, H) of the gene expression matrix.
- List of pairwise alignment mappings of the center slice (rows) to each input slice (columns).
""" # noqa

Expand Down
2 changes: 2 additions & 0 deletions stereo/algorithm/spatial_alignment/spatial_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def main(
:param method: pairwise or center, defaults to 'pairwise'
:param initial_slice: slice to use as the initialization for center alignment, defaults to None
:param slices: list of slices to align, defaults to None
Other parameters refer to `algorithm.paste.pairwise_align` and `algorithm.paste.center_align`
"""
if method not in ('pairwise', 'center'):
raise ValueError(f'Error method({method}), it must be one of pairwise and center')
Expand Down

0 comments on commit 876c2e6

Please sign in to comment.