Metadata-Version: 2.4
Name: cellarium-ml
Version: 0.0.8
Summary: Machine learning library for single-cell data analysis
Author-email: Yerdos Ordabayev <yordabay@broadinstitute.org>, Mehrtash Babadi <mehrtash@broadinstitute.org>
License: Copyright (c) 2023, Broad Institute
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://cellarium-ai.github.io/cellarium-ml
Project-URL: Source Code, https://github.com/cellarium-ai/cellarium-ml
Project-URL: Bug Tracker, https://github.com/cellarium-ai/cellarium-ml/issues
Project-URL: Discussion Forum, https://github.com/cellarium-ai/cellarium-ml/discussions
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE.md
Requires-Dist: anndata
Requires-Dist: boltons
Requires-Dist: braceexpand
Requires-Dist: crick>=0.0.4
Requires-Dist: google-cloud-storage
Requires-Dist: jsonargparse[signatures]==4.27.7
Requires-Dist: lightning<=2.5.2,>=2.2.0
Requires-Dist: numpy<=1.26.4
Requires-Dist: pyro-ppl>=1.9.1
Requires-Dist: pytest
Requires-Dist: scikit-misc==0.5.1
Requires-Dist: torch>=2.2.0
Requires-Dist: transformers
Provides-Extra: lint
Requires-Dist: ruff; extra == "lint"
Provides-Extra: mypy
Requires-Dist: mypy; extra == "mypy"
Requires-Dist: types-PyYAML; extra == "mypy"
Provides-Extra: test
Requires-Dist: pytest-xdist; extra == "test"
Requires-Dist: scanpy; extra == "test"
Requires-Dist: tenacity; extra == "test"
Requires-Dist: tensorboard; extra == "test"
Requires-Dist: torchvision; extra == "test"
Provides-Extra: docs
Requires-Dist: nbsphinx; extra == "docs"
Requires-Dist: Pillow; extra == "docs"
Requires-Dist: seaborn>=0.13.0; extra == "docs"
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx_rtd_theme; extra == "docs"
Requires-Dist: sphinx-copybutton; extra == "docs"
Provides-Extra: dev
Requires-Dist: cellarium-ml[docs,lint,mypy,test]; extra == "dev"
Dynamic: license-file

.. image:: https://cellarium.ai/wp-content/uploads/2024/07/cellarium-logo-medium.png
   :alt: Cellarium Logo
   :width: 180
   :align: center

**Cellarium ML: a machine learning framework for single-cell biology**
======================================================================

Cellarium ML is a PyTorch Lightning-based library for distributed single-cell data analysis.
It provides tools for training deep learning models on large-scale single-cell datasets,
including distributed data loading, model training, and evaluation. Designed to be modular
and extensible, Cellarium ML allows users to easily define custom models, data transformations,
and training pipelines.

-------------------------------------------------------------------------------

**Code Organization**
----------------------

The code is organized as follows:

.. code-block:: text

   cellarium/
   └── ml/
       ├── "callbacks"        # Custom PyTorch Lightning callbacks
       ├── "core"             # Essential components
       │   ├── "CellariumModule"              # PyTorch Lightning Module for model, training step, and optimizer
       │   ├── "CellariumAnnDataDataModule"   # DataModule for multi-GPU DataLoader for AnnData objects
       │   └── "CellariumPipeline"            # Pipeline for data transformations and model inference
       ├── "data"             # Distributed AnnData Collection and multi-GPU Iterable Datasets
       ├── "lr_schedulers"    # Custom learning rate schedulers
       ├── "models"           # Cellarium ML models
       ├── "preprocessing"    # Pre-processing functions
       ├── "transforms"       # Data transformation modules
       ├── "utilities"        # Utility functions for various submodules
       └── "cli.py"           # Implements the "cellarium-ml" CLI. Models must be registered here

Important Notes
~~~~~~~~~~~~~~~

``cellarium/ml/models/*``  
~~~~~~~~~~~~~~~~~~~~~~~~~

- Models must subclass ``CellariumModel`` and implement the following:  
- ``reset_parameters``: Initializes model parameters.  
- ``forward``: Returns a dictionary containing the computed loss under the ``loss`` key.  

Optional hooks for training include:  

- ``on_train_start``: Called at the start of training.  
- ``on_train_epoch_end``: Triggered at the end of each epoch.  
- ``on_train_batch_end``: Triggered at the end of each batch.  

``cellarium/ml/transforms/*``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- All transforms must subclass ``torch.nn.Module``.
- The ``forward`` method must output a dictionary where keys correspond to the input arguments for subsequent transforms or the model.  

``cellarium/ml/cli.py``
~~~~~~~~~~~~~~~~~~~~~~~
- Models must be registered here to be accessible via the command-line interface (``cellarium-ml`` CLI).



-------------------------------------------------------------------------------

**Installation**
-----------------

To install via pip:

.. code-block:: bash

   pip install cellarium-ml

To install the developer version from source:

.. code-block:: bash

   git clone https://github.com/cellarium-ai/cellarium-ml.git
   cd cellarium-ml
   make install  # runs pip install -e .[dev]

**API Documentation and Tutorials**
-----------------------------------

For detailed API documentation and tutorials, visit:  
`Cellarium ML Documentation <https://cellarium-ai.github.io/cellarium-ml/>`_

-------------------------------------------------------------------------------

**For Developers**
-------------------

To run the tests:

.. code-block:: bash

   make test-examples                   # runs single-device cli example tests
   make test-dataloader                 # runs single-device dataloader related tests
   TEST_DEVICES=2 make test-dataloader  # runs multi-device dataloader related test
   make test                            # runs single-device (all other) tests
   TEST_DEVICES=2 make test             # runs multi-device (all other) tests

To format the code automatically:

.. code-block:: bash

   make format                # runs ruff formatter and fixes linter errors

To run the linters:

.. code-block:: bash

   make lint                  # runs ruff linter and checks for formatter errors

To build the documentation:

.. code-block:: bash

   make docs                  # builds the documentation at docs/build/html
