semvec/pypi-packages huggingface dataset:
torch-pba 0.0.3
PyTorch implementation of PBA.
License: MIT
Requires Python: >3.9.0

# torch-pba

[![PyPI pyversions](https://img.shields.io/pypi/pyversions/torch-pba.svg)](https://pypi.python.org/pypi/torch-pba/)
[![PyPI version](https://badge.fury.io/py/torch-pba.svg)](https://badge.fury.io/py/torch-pba)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)


PyTorch Implementation of [PBA](https://github.com/AllonKleinLab/PBA). [AnnData](https://anndata.readthedocs.io/en/latest/)-centric.

## Installation

From [PYPI](https://pypi.org/project/torch-pba/):
```SHELL
pip install torch-pba
```

Alternatively, install the development version from GitHub:
```SHELL
git clone https://github.com/mvinyard/torch-pba.git; cd torch-pba; pip install -e .
```

## Example use:

```python
from torch_pba import PBA
from anndata import read_h5ad

pba = PBA(adata=read_h5ad("./path/to/adata.h5ad"))

pba.build_kNN()
pba.compute_Laplacian()
pba.compute_potential()
pba.compute_fate_bias()
pba.compute_mean_first_passage_time()
```

Time to calculate Mean First Passage Time for the [example hematopoiesis dataset](https://github.com/AllonKleinLab/PBA/blob/master/example_datasets.zip) is **cut from 4+ hours to <10 mins**. In this example, I used a NVIDIA T4 GPU rented from GCP.

See more: [notebook](https://github.com/mvinyard/torch-pba/blob/main/notebooks/torch_pba_hematopoiesis_example.ipynb)


## Original work:
* GitHub: [AllonKleinLab/PBA](https://github.com/AllonKleinLab/PBA)
* Paper: [Weinreb et al., PNAS. DOI: 10.1073/pnas.1714723115. (2018).](https://www.pnas.org/doi/10.1073/pnas.1714723115#executive-summary-abstract)

## Note:
I have not contributed any methodological novelty in this library. The original implementation contains the novel application of a Laplace transform to a kNN Graph to obtain a potential value, pseudotime, etc. Here, I have simply adapted the library to PyTorch/CUDA. No formal benchmarking has been performed.

## Contact / questions:
mvinyard@broadinstitute.org
tqdm-pathos 0.4
tqdm_pathos
License: MIT
Requires Python: >=3.7

# tqdm_pathos
Progress bars for multiprocessing with pathos

Wrappers based on [parmap](https://github.com/zeehio/parmap) for multiprocessing with [pathos](https://pathos.readthedocs.io/en/latest/pathos.html#module-pathos.pools) and progress bar completion with [tqdm](https://tqdm.github.io/). Following parmap, multiprocessing is extended to functions of multiple iterables, arguments, and keyword arguments.

While parmap includes these extensions and a progress bar, it is built on the default [multiprocessing](https://docs.python.org/3/library/multiprocessing.html) library. The multiprocessing/pools module in pathos includes enhanced serialization to allow multiprocessing of, e.g., lambda functions, class methods, etc.

## Installation

You can `pip install tqdm-pathos`.

## Usage

A pool with an automatically detected number of cores is set up by default. To choose the number of cores, use the `n_cpus` kwarg.
Alternatively, an existing pool can be used by passing it to the `pool` kwarg.
Extra `kwargs` can be passed to the `tqdm` progress bar using the `tqdm_kwargs` dictionary argument, e.g., `tqdm_kwargs = {'desc': 'pbar description'}`.

Function of a single iterable:
```
f = lambda x: x**2
iterable = [1, 2, 3]

# Serial
y = [f(x) for x in iterable]

# Parallel
y = tqdm_pathos.map(f, iterable)
```

Function of a single iterable, with non-iterable args and kwargs:
```
def f(x, a, b=0):
    return x**2 * a + b
iterable = [1, 2, 3]
a = 1
b = 0
    
# Serial
y = [f(x, a, b=b) for x in iterable]

# Parallel
y = tqdm_pathos.map(f, iterable, a, b=b)
```

Function of multiple iterables:
```
f = lambda x, y: x * y
iterable1 = [1, 2, 3]
iterable2 = [4, 5, 6]

# Serial
z = [f(x, y) for x, y in zip(iterable1, iterable2)]

# Parallel
z = tqdm_pathos.starmap(f, zip(iterable1, iterable2))
```

Function of multiple iterables, with non-iterable args and kwargs:
```
def f(x, y, a, b=0):
    return x * y * a + b
iterable1 = [1, 2, 3]
iterable2 = [4, 5, 6]
a = 1
b = 0

# Serial
z = [f(x, y, a, b=b) for x, y in zip(iterable1, iterable2)]

# Parallel
z = tqdm_pathos.starmap(f, zip(iterable1, iterable2), a, b=b)
```