Skip to content

Commit

Permalink
update some api comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanliwei-coder committed Jan 14, 2025
1 parent c7c1728 commit 3985f46
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
2 changes: 1 addition & 1 deletion stereo/algorithm/st_gears/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main(
:param start_i: The index of first sample to calulate, defaults to 0
:param end_i: The index of last sample to calulate, defaults to None.
By default, it is the last of all samples.
:param tune_alpha_li: List of regularization factor in Fused Gromov Wasserstin (FGW) OT problem formulation, to be
:param tune_alpha_li: List of regularization factor in Fused Gromov Wasserstein (FGW) OT problem formulation, to be
automatically tunned. Refer to this paper for the FGW formulation:
Optimal transport for structured data with application on graphs. T Vayer, L Chapel, R Flamary,
R Tavenard… - arXiv preprint arXiv …, 2018 - arxiv.org
Expand Down
12 changes: 6 additions & 6 deletions stereo/core/st_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def log1p(
inplace
whether to replace the data.exp_matrix or save the result in `data.layers`.
add_layer
whether to save the result in `data.layers` simultaneously when `inplace` is False.
whether to save the result in `data.layers` simultaneously when `inplace` is True.
res_key
the key to save the result in `data.layers` when `inplace` is False or `add_layer` is True.
Expand Down Expand Up @@ -535,7 +535,7 @@ def normalize_total(
inplace
whether to replace the data.exp_matrix or save the result in `data.layers`.
add_layer
whether to save the result in `data.layers` simultaneously when `inplace` is False.
whether to save the result in `data.layers` simultaneously when `inplace` is True.
res_key
the key to save the result in `data.layers` when `inplace` is False or `add_layer` is True.
Expand Down Expand Up @@ -576,7 +576,7 @@ def scale(
inplace
whether to replace the data.exp_matrix or save the result in `data.layers`.
add_layer
whether to save the result in `data.layers` simultaneously when `inplace` is False.
whether to save the result in `data.layers` simultaneously when `inplace` is True.
res_key
the key to save the result in `data.layers` when `inplace` is False or `add_layer` is True.
Expand Down Expand Up @@ -612,7 +612,7 @@ def quantile(
inplace
whether to replace the data.exp_matrix or save the result in `data.layers`.
add_layer
whether to save the result in `data.layers` simultaneously when `inplace` is False.
whether to save the result in `data.layers` simultaneously when `inplace` is True.
res_key
the key to save the result in `data.layers` when `inplace` is False or `add_layer` is True.
Expand Down Expand Up @@ -653,7 +653,7 @@ def disksmooth_zscore(
inplace
whether to replace the data.exp_matrix or save the result in `data.layers`.
add_layer
whether to save the result in `data.layers` simultaneously when `inplace` is False.
whether to save the result in `data.layers` simultaneously when `inplace` is True.
res_key
the key to save the result in `data.layers` when `inplace` is False or `add_layer` is True.
Expand Down Expand Up @@ -714,7 +714,7 @@ def sctransform(
layer
the key of layer to be used instead of the data.exp_matrix.
add_layer
whether to save the result in `data.layers` simultaneously when `inplace` is False.
whether to save the result in `data.layers` simultaneously when `inplace` is True.
Returns
-----------
Expand Down
34 changes: 31 additions & 3 deletions stereo/io/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def read_gem(
"""
Read the Stereo-seq GEM file, and generate the StereoExpData object.
.. seealso::
`st.io.read_gef <stereo.io.read_gef.html>`_
Parameters
-------------
file_path
Expand Down Expand Up @@ -475,6 +479,10 @@ def read_h5ms(file_path, use_raw=True, use_result=True):
"""
Load a h5ms file as an object of MSData
.. seealso::
`st.io.write_h5ms <stereo.io.write_h5ms.html>`_
:param file_path: The path of h5ms file to be loaded.
:param use_raw: Whether to load the raw data of each StereoExpData in MSData, defaults to True.
:param use_result: Whether to load the analysis results which had been saved in h5ms file, defaults to True.
Expand Down Expand Up @@ -754,7 +762,13 @@ def read_h5ad(
**kwargs
) -> Union[StereoExpData, AnnBasedStereoExpData]:
"""
Read a h5ad file or load a AnnData object
Read a h5 file or load an AnnData object.
.. seealso::
`st.io.write_h5ad <stereo.io.write_h5ad.html>`_
`st.io.stereo_to_anndata <stereo.io.stereo_to_anndata.html>`_
Parameters
------------------
Expand All @@ -765,8 +779,8 @@ def read_h5ad(
`file_path` and `anndata` only can input one of them.
flavor
the format of the h5ad file, defaults to `'scanpy'`.
`scanpy`: AnnData format of scanpy
`stereopy`: h5 format of stereo
`scanpy`: h5 format of AnnData
`stereopy`: h5 format of StereoExpData
bin_type
the bin type includes `'bins'` and `'cell_bins'`.
bin_size
Expand Down Expand Up @@ -870,6 +884,12 @@ def stereo_to_anndata(
"""
Transform the StereoExpData object into Anndata format.
.. seealso::
`st.io.read_h5ad <stereo.io.read_h5ad.html>`_
`st.io.write_h5ad <stereo.io.write_h5ad.html>`_
Parameters
-----------------------
data
Expand Down Expand Up @@ -1270,6 +1290,10 @@ def read_gef(
"""
Read the GEF (.h5) file, and generate the StereoExpData object.
.. seealso::
`st.io.read_gem <stereo.io.read_gem.html>`_
Parameters
---------------
file_path
Expand Down Expand Up @@ -1560,6 +1584,10 @@ def mudata_to_msdata(
"""
Read a h5mu file and convert it to a MSData object.
.. seealso::
`st.io.write_h5mu <stereo.io.write_h5mu.html>`_
:param file_path: The path of the MuData file, defaults to None
:param sample_names: The names of single samples that are saved in the MuData object, defaults to None,
if None, the names starting with 'sample_' will be used.
Expand Down
22 changes: 21 additions & 1 deletion stereo/io/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,19 @@ def write_h5ad(
output: str = None,
split_batches: bool = True):
"""
Write the StereoExpData into a H5ad file.
Write the **StereoExpData** object into a h5 file, we recommend you to set the suffix of the file as **.h5st**.
This is a specific format for **StereoExpData** object, not the format of **AnnData** which is suffixed with **.h5ad**.
When reading it back using `st.io.read_h5ad`, the parameter `flavor` should be set to **'stereopy'**.
If you want to save the **StereoExpData** object into a **.h5ad** file, you can use `st.io.stereo_to_anndata`.
.. seealso::
`st.io.read_h5ad <stereo.io.read_h5ad.html>`_
`st.io.stereo_to_anndata <stereo.io.stereo_to_anndata.html>`_
Parameters
---------------------
Expand Down Expand Up @@ -333,6 +345,10 @@ def write_h5ms(ms_data, output: str, anndata_as_anndata: bool = True):
"""
Save an object of MSData into a h5 file whose suffix is 'h5ms'.
.. seealso::
`st.io.read_h5ms <stereo.io.read_h5ms.html>`_
:param ms_data: The object of MSData to be saved.
:param output: The path of file into which MSData is saved.
"""
Expand Down Expand Up @@ -538,6 +554,10 @@ def write_h5mu(ms_data: MSData, output: str = None, compression: Optional[Litera
"""
Convert the MSData to a MuData and save it as a h5mu file.
.. seealso::
`st.io.mudata_to_msdata <stereo.io.mudata_to_msdata.html>`_
The single samples saved in MSData.data_list are named as 'sample_{i}'.
The scope data merged from some samples are named starting with 'scope_[{i0,i1,i2...}]'.
Expand Down

0 comments on commit 3985f46

Please sign in to comment.