semvec/pypi-packages huggingface dataset:
ann-nmf 0.0.1
ann_nmf - AnnData wrapper of the ARD-NMF module from SignatureAnalyzer
License: MIT
Requires Python: >3.6.0

# ![ann_nmf.logo](docs/imgs/ann_nmf.logo.svg)

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

AnnData wrapper of the [**ARD-NMF module**](https://github.com/broadinstitute/SignatureAnalyzer-GPU/blob/master/ARD_NMF.py) from [**SignatureAnalyzer-GPU**](https://github.com/broadinstitute/SignatureAnalyzer-GPU).

## Installation

Install using [pip](https://pypi.org/project/ann-nmf/)
```BASH
pip install ann_nmf
```

Alternatively, install the development version:
```BASH
git clone https://github.com/mvinyard/ann_nmf.git; cd ann_nmf;
pip install -e .
```

## API overview

#### Import libraries and get some data
```python
import ann_nmf
import scanpy as sc

adata = sc.datasets.pbmc3k()
ann_nmf.ut.preprocess_raw_counts(adata)
```

#### Key class:
```python
nmf = ann_nmf.NMF(adata, outdir="nmf_results/pbmc3k") # saves .h5 file
nmf.run(n_runs=10, K0=20, max_iter=2000)
```

#### SignatureAnalyzer visualization:
```python
nmf.cluster()
nmf.signatures()
```

## Conceptual background and foundational work

* ARD-NMF theory [Arxiv](https://arxiv.org/pdf/1111.6085.pdf)
* SignatureAnalyzer ([GitHub](https://github.com/getzlab/getzlab-SignatureAnalyzer))
* SignatureAnalyzer-GPU ([GitHub](https://github.com/broadinstitute/SignatureAnalyzer-GPU))

## Acknowledgements

* Most of the code to wrap SignatureAnalyzer in an AnnData-friendly API was borrowed directly (and shamelessly) from Shankara Anand ([@shankara-a](https://github.com/shankara-a)) with only slight refactoring for more flexibility with fewer dependencies on install.
serverwamp 1.1.2
Components that add Web Application Messaging Protocol features to WebSocket servers.
License: MIT
Requires Python: >=3.6
Keywords: WAMP,WebSockets,aiohttp,RPC,pubsub,broker,dealer,ASGI

# serverwamp
Adds [Web Application Messaging Protocol](https://wamp-proto.org/) features to
WebSocket servers. _serverwamp_ makes it easy to both serve requests from
clients and push events to clients over a single connection. Currently supports
ASGI servers using asyncio or Trio and aiohttp servers.

[Documentation](https://serverwamp.readthedocs.io/)

### Usage Example
```python
import asyncio

from aiohttp import web
import serverwamp

docs_api = serverwamp.RPCRouteSet()
docs_events = serverwamp.TopicRouteSet()

@docs_api.route('docs.getDoc')
async def get_doc(document_id):
    record = await my_db.retrieve(document_id)
    return {'status': 'SUCCESS', 'doc': record}

@docs_api.route('docs.deleteDoc')
async def delete_doc(document_id):
    succeeded = await my_db.delete(document_id)
    if succeeded:
        return {'status': 'SUCCESS'}

    return serverwamp.RPCErrorResult(
        'wamp.error.delete_failed',
        kwargs={'status': 'FAILURE'}
    )

@docs_events.route('docs.changes')
async def subscribe_to_doc_changes(session, changes_subscribers):
    changes_subscribers.add(session)
    session.send_event(args=('Thanks for subscribing!',))
    yield
    changes_subscribers.remove(session)


async def server_context(app):

    async def watch_for_docs_changes():
        async for event in my_db.watch_changes():
            for session in app['changes_subscribers']:
                await session.send_event(f'Document changed: {event}')

    watcher = asyncio.create_task(watch_for_docs_changes())
    try:
        yield
    finally:
        watcher.cancel()


if __name__ == '__main__':
    changes_subscribers = set()

    app = serverwamp.Application()
    app.add_rpc_routes(docs_api)
    app.add_topic_routes(docs_events)
    app.set_default_arg('changes_subscribers', changes_subscribers)

    http_app = web.Application()
    http_app['changes_subscribers'] = changes_subscribers
    http_app.add_routes((
        web.get('/', app.aiohttp_websocket_handler()),
    ))
    http_app.cleanup_ctx.append(server_context)

    web.run_app(http_app)
```


## Development
Unit tests can be run with:

    pip install -e .
    pytest