Skip to content

Commit

Permalink
Merge pull request #661 from Sichao25/debug_l
Browse files Browse the repository at this point in the history
Update docstr and type hints for External module
  • Loading branch information
Xiaojieqiu authored Feb 26, 2024
2 parents 9a8d22d + 54c95c1 commit 2951273
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 207 deletions.
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

0 comments on commit 2951273

Please sign in to comment.