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

Make progress bar optional #1234

Merged
merged 2 commits into from
Apr 12, 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
5 changes: 4 additions & 1 deletion scvelo/tools/_em_model_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ def recover_dynamics(
copy=False,
n_jobs=None,
backend="loky",
show_progress_bar: bool = True,
**kwargs,
):
"""Recovers the full splicing kinetics of specified genes.
Expand Down Expand Up @@ -476,6 +477,8 @@ def recover_dynamics(
backend: `str` (default: "loky")
Backend used for multiprocessing. See :class:`joblib.Parallel` for valid
options.
show_progress_bar
Whether to show a progress bar.

Returns
-------
Expand Down Expand Up @@ -557,7 +560,7 @@ def recover_dynamics(
unit="gene",
as_array=False,
backend=backend,
show_progress_bar=len(var_names) > 9,
show_progress_bar=show_progress_bar,
)(
adata=adata,
use_raw=use_raw,
Expand Down
12 changes: 10 additions & 2 deletions scvelo/tools/velocity_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def __init__(
self.adata = adata

# TODO: Add docstrings
def compute_cosines(self, n_jobs=None, backend="loky"):
def compute_cosines(
self, n_jobs=None, backend="loky", show_progress_bar: bool = True
):
"""TODO."""
n_jobs = get_n_jobs(n_jobs=n_jobs)

Expand All @@ -189,6 +191,7 @@ def compute_cosines(self, n_jobs=None, backend="loky"):
unit="cells",
backend=backend,
as_array=False,
show_progress_bar=show_progress_bar,
)()
uncertainties, vals, rows, cols = map(_flatten, zip(*res))

Expand Down Expand Up @@ -277,6 +280,7 @@ def velocity_graph(
copy=False,
n_jobs=None,
backend="loky",
show_progress_bar: bool = True,
):
r"""Computes velocity graph based on cosine similarities.

Expand Down Expand Up @@ -329,6 +333,8 @@ def velocity_graph(
backend: `str` (default: "loky")
Backend used for multiprocessing. See :class:`joblib.Parallel` for valid
options.
show_progress_bar
Whether to show a progress bar.

Returns
-------
Expand Down Expand Up @@ -370,7 +376,9 @@ def velocity_graph(
logg.info(
f"computing velocity graph (using {n_jobs}/{os.cpu_count()} cores)", r=True
)
vgraph.compute_cosines(n_jobs=n_jobs, backend=backend)
vgraph.compute_cosines(
n_jobs=n_jobs, backend=backend, show_progress_bar=show_progress_bar
)

adata.uns[f"{vkey}_graph"] = vgraph.graph
adata.uns[f"{vkey}_graph_neg"] = vgraph.graph_neg
Expand Down
Loading