Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docstr and type hints for External module #661

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions dynamo/external/gseapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,17 @@ def enrichr(
):
"""Perform gene list enrichment with gseapy.

Parameters
----------
genes:
Flat file with list of genes, one gene id per row, or a python list object.
organism:
Enrichr supported organism. Select from (human, mouse, yeast, fly, fish, worm).
Args:
genes: Flat file with list of genes, one gene id per row, or a python list object.
organism: Enrichr supported organism. Select from (human, mouse, yeast, fly, fish, worm).
see here for details: https://amp.pharm.mssm.edu/modEnrichr
:param gene_sets:
gene_sets:
str, list, tuple of Enrichr Library name(s).
description:
name of analysis. optional.
outdir:
Output file directory
cutoff:
Show enriched terms which Adjusted P-value < cutoff. Only affects the output figure. Default: 0.05
kwargs:
additional arguments passed to the `gp.enrichr` function.
gene_sets: str, list, tuple of Enrichr Library name(s).
description: Name of analysis. optional.
outdir: Output file directory.
cutoff: Show enriched terms which Adjusted P-value < cutoff. Only affects the output figure. Default: 0.05
kwargs: Additional arguments passed to the `gp.enrichr` function.

Returns
-------
Returns:
An Enrichr object, which obj.res2d stores your last query, obj.results stores your all queries.

>>> import dynamo as dyn
Expand Down
68 changes: 27 additions & 41 deletions dynamo/external/hodge.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,41 @@ def ddhodge(
enforce: bool = False,
cores: int = 1,
**kwargs,
):
) -> None:
"""Modeling Latent Flow Structure using Hodge Decomposition based on the creation of sparse diffusion graph from the
reconstructed vector field function. This method is relevant to the curl-free/divergence-free vector field
reconstruction.

Parameters
----------
adata: :class:`~anndata.AnnData`
an Annodata object.
X_data:
The user supplied expression (embedding) data that will be used for graph hodege decomposition directly.
layer:
Which layer of the data will be used for graph Hodge decomposition.
basis:
Which basis of the data will be used for graph Hodge decomposition.
n:
Number of nearest neighbors when the nearest neighbor graph is not included.
VecFld:
The reconstructed vector field function.
adjmethod:
The method to build the ajacency matrix that will be used to create the sparse diffusion graph, can be
Args:
adata: An Anndata object.
X_data: The user supplied expression (embedding) data that will be used for graph hodege decomposition directly.
layer: Which layer of the data will be used for graph Hodge decomposition.
basis: Which basis of the data will be used for graph Hodge decomposition.
n: Number of nearest neighbors when the nearest neighbor graph is not included.
VecFld: The reconstructed vector field function.
adjmethod: The method to build the ajacency matrix that will be used to create the sparse diffusion graph, can be
either "naive" or "graphize_vecfld". If "naive" used, the transition_matrix that created during vector field
projection will be used; if "graphize_vecfld" used, a method that guarantees the preservance of divergence
will be used.
n_downsamples:
Number of cells to downsample to if the cell number is large than this value. Three downsampling methods are
available, see `sampling_method`.
up_sampling:
Whether to assign calculated potential, curl and divergence to cells not sampled based on values from their
nearest sampled cells.
sampling_method:
Methods to downsample datasets to facilitate calculation. Can be one of {`random`, `velocity`, `trn`}, each
corresponds to random sampling, velocity magnitude based and topology representing network based sampling.
seed:
Seed for RandomState. Must be convertible to 32 bit unsigned integers. Used in sampling control points.
n_downsamples: Number of cells to downsample to if the cell number is large than this value. Three downsampling
methods are available, see `sampling_method`.
up_sampling: Whether to assign calculated potential, curl and divergence to cells not sampled based on values
from their nearest sampled cells.
sampling_method: Methods to downsample datasets to facilitate calculation. Can be one of {`random`, `velocity`,
`trn`}, each corresponds to random sampling, velocity magnitude based and topology representing network
based sampling.
seed: Seed for RandomState. Must be convertible to 32 bit unsigned integers. Used in sampling control points.
Default is to be 0 for ensure consistency between different runs.
enforce:
Whether to enforce the calculation of adjacency matrix for estimating potential, curl, divergence for each
cell.
cores:
Number of cores to run the graphize_vecfld function. If cores is set to be > 1, multiprocessing will be used
to parallel the graphize_vecfld calculation.

Returns
-------
adata: :class:`~anndata.AnnData`
`AnnData` object that is updated with the `ddhodge` key in the `obsp` attribute which to adjacency matrix
that corresponds to the sparse diffusion graph. Two columns `potential` and `divergence` corresponds to the
potential and divergence for each cell will also be added."""
enforce: Whether to enforce the calculation of adjacency matrix for estimating potential, curl, divergence for
each cell.
cores: Number of cores to run the graphize_vecfld function. If cores is set to be > 1, multiprocessing will be
used to parallel the graphize_vecfld calculation.

Returns:
`AnnData` object wil be updated with the `ddhodge` key in the `obsp` attribute which to adjacency matrix
that corresponds to the sparse diffusion graph. Two columns `potential` and `divergence` corresponds to the
potential and divergence for each cell will also be added.
"""

main_log_time()
prefix = "" if basis is None else basis + "_"
Expand Down
Loading
Loading