muxsim


Namemuxsim JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA tool to simulate cell/guide matrices
upload_time2024-10-09 17:27:14
maintainerNone
docs_urlNone
authorNoam Teyssier
requires_python>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# muxsim

a python module for generate cell / guide matrices for demultiplex testing.

## Installation

```bash
pip install muxsim
```

## Usage

Muxsim is expected to be used as a python module. It has reasonable defaults for most use cases, but can be configured to your liking.

Here is a simple example of how to use muxsim:

```python
from muxsim import MuxSim

ms = MuxSim()
matrix = ms.sample()
```

The sampling scheme can be fully parameterized like so:

```python
from muxsim import MuxSim

ms = MuxSim(
    num_cells=10000,
    num_guides=100,
    n=10.0,
    p=0.1,
    λ=0.8,
    random_state=42,
)
matrix = ms.sample()
```

## Methods

The simulator, `muxsim`, is based on a Multinomial distribution, where the number of draws $(\mathcal{S})$ of cell $(i)$ is drawn from a Negative Binomial distribution representing the number of observed UMIs of that cell.

$$
\begin{align}
\mathbb{U}_i &\sim \text{Multinomial}(\mathbb{S}_i,\ f_i) \\
\mathbb{S}_i &\sim \text{NegativeBinomial}(n,\ p) \\
\end{align}
$$

The frequencies of the multinomial distribution are cell specific and sum to 1:

$$
\sum_{j=1}^{M}{f_{ij}} = 1
$$

The background frequencies are assumed to be equiprobable (where $`(\forall u,v \in M)(f_{iu} = f_{iv})`$ ), except for signal guides - which would be a scaled by some value $(r)$. The number of signal guides is chosen using a Poisson prior to simulate situations where the expected multiplicity of infection (MOI) can change:

$$
\mathbb{I}_i \sim \text{Poisson}(\lambda)
$$


The signal guides are chosen randomly from the guide set where the number of choices is equal to the MOI of that cell:

$$
\mathbb{C}_i \sim \text{Uniform}(M, \mathbb{I}_i)
$$

This allows us to then set the the signal guides at a rate $(r)$ above the background with the following expression:

$$
t_{ij} = 
\begin{cases}
r,& \text{if } j \in \mathbb{C}_i \\
1,& \text{if } j \not\in \mathbb{C}_i
\end{cases}
$$

Which can then be turned into the frequency matrix:

$$
f_i = \frac{t_{i}}{\sum_{j=1}^{M}t_{ij}}
$$

Which forces $f_{ij}$ to sum to 1. 
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "muxsim",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Noam Teyssier",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8a/fb/b9c4d1632a76bdf04693dd014d64c1a91abe646f05b0402f003ea50b20ed/muxsim-0.1.1.tar.gz",
    "platform": null,
    "description": "\n# muxsim\n\na python module for generate cell / guide matrices for demultiplex testing.\n\n## Installation\n\n```bash\npip install muxsim\n```\n\n## Usage\n\nMuxsim is expected to be used as a python module. It has reasonable defaults for most use cases, but can be configured to your liking.\n\nHere is a simple example of how to use muxsim:\n\n```python\nfrom muxsim import MuxSim\n\nms = MuxSim()\nmatrix = ms.sample()\n```\n\nThe sampling scheme can be fully parameterized like so:\n\n```python\nfrom muxsim import MuxSim\n\nms = MuxSim(\n    num_cells=10000,\n    num_guides=100,\n    n=10.0,\n    p=0.1,\n    \u03bb=0.8,\n    random_state=42,\n)\nmatrix = ms.sample()\n```\n\n## Methods\n\nThe simulator, `muxsim`, is based on a Multinomial distribution, where the number of draws $(\\mathcal{S})$ of cell $(i)$ is drawn from a Negative Binomial distribution representing the number of observed UMIs of that cell.\n\n$$\n\\begin{align}\n\\mathbb{U}_i &\\sim \\text{Multinomial}(\\mathbb{S}_i,\\ f_i) \\\\\n\\mathbb{S}_i &\\sim \\text{NegativeBinomial}(n,\\ p) \\\\\n\\end{align}\n$$\n\nThe frequencies of the multinomial distribution are cell specific and sum to 1:\n\n$$\n\\sum_{j=1}^{M}{f_{ij}} = 1\n$$\n\nThe background frequencies are assumed to be equiprobable (where $`(\\forall u,v \\in M)(f_{iu} = f_{iv})`$ ), except for signal guides - which would be a scaled by some value $(r)$. The number of signal guides is chosen using a Poisson prior to simulate situations where the expected multiplicity of infection (MOI) can change:\n\n$$\n\\mathbb{I}_i \\sim \\text{Poisson}(\\lambda)\n$$\n\n\nThe signal guides are chosen randomly from the guide set where the number of choices is equal to the MOI of that cell:\n\n$$\n\\mathbb{C}_i \\sim \\text{Uniform}(M, \\mathbb{I}_i)\n$$\n\nThis allows us to then set the the signal guides at a rate $(r)$ above the background with the following expression:\n\n$$\nt_{ij} = \n\\begin{cases}\nr,& \\text{if } j \\in \\mathbb{C}_i \\\\\n1,& \\text{if } j \\not\\in \\mathbb{C}_i\n\\end{cases}\n$$\n\nWhich can then be turned into the frequency matrix:\n\n$$\nf_i = \\frac{t_{i}}{\\sum_{j=1}^{M}t_{ij}}\n$$\n\nWhich forces $f_{ij}$ to sum to 1. ",
    "bugtrack_url": null,
    "license": null,
    "summary": "A tool to simulate cell/guide matrices",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fccd08563e4605876c7b967b4c06dda5ff0fc57f6404c2d40fa320b1d5506ced",
                "md5": "3ff810ce375508773a18a663205d0d5a",
                "sha256": "e82c4649f1c6c69d0bc8d3f3227da12f7363aa80d63e37b416d141002a73c6ac"
            },
            "downloads": -1,
            "filename": "muxsim-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ff810ce375508773a18a663205d0d5a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 3683,
            "upload_time": "2024-10-09T17:27:13",
            "upload_time_iso_8601": "2024-10-09T17:27:13.152899Z",
            "url": "https://files.pythonhosted.org/packages/fc/cd/08563e4605876c7b967b4c06dda5ff0fc57f6404c2d40fa320b1d5506ced/muxsim-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8afbb9c4d1632a76bdf04693dd014d64c1a91abe646f05b0402f003ea50b20ed",
                "md5": "753425bbd67262cc9611f95123ba1fe9",
                "sha256": "e7b1429577c135d1caf30c43df3c20f31f7359e13f572f30dae6372c1f297485"
            },
            "downloads": -1,
            "filename": "muxsim-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "753425bbd67262cc9611f95123ba1fe9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 34851,
            "upload_time": "2024-10-09T17:27:14",
            "upload_time_iso_8601": "2024-10-09T17:27:14.301289Z",
            "url": "https://files.pythonhosted.org/packages/8a/fb/b9c4d1632a76bdf04693dd014d64c1a91abe646f05b0402f003ea50b20ed/muxsim-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-09 17:27:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "muxsim"
}
        
Elapsed time: 0.55759s