qnorm


Nameqnorm JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/Maarten-vd-Sande/qnorm
SummaryQuantile normalization
upload_time2020-09-28 11:36:44
maintainer
docs_urlNone
author['Maarten van der Sande <maartenvandersande@hotmail.com>']
requires_python>3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # qnorm
[![PyPI version](https://badge.fury.io/py/qnorm.svg)](https://badge.fury.io/py/qnorm)
[![Anaconda version](https://anaconda.org/conda-forge/qnorm/badges/version.svg)](https://anaconda.org/conda-forge/qnorm)
![tests](https://github.com/Maarten-vd-Sande/qnorm/workflows/tests/badge.svg)

quantile normalization made easy.

## Code example

We recreate the example of [Wikipedia](https://en.wikipedia.org/wiki/Quantile_normalization):

```python
import pandas as pd
import qnorm

df = pd.DataFrame({'C1': {'A': 5, 'B': 2, 'C': 3, 'D': 4},
                   'C2': {'A': 4, 'B': 1, 'C': 4, 'D': 2},
                   'C3': {'A': 3, 'B': 4, 'C': 6, 'D': 8}})

print(qnorm.quantile_normalize(df))
```

which is what we expect:

```
         C1        C2        C3
A  5.666667  5.166667  2.000000
B  2.000000  2.000000  3.000000
C  3.000000  5.166667  4.666667
D  4.666667  3.000000  5.666667
```

**NOTE**: The function quantile_normalize also accepts numpy arrays. 

### Multicore support

To accelerate the computation you can pass a ncpus argument to the function call and qnorm will be run in parallel:

```python
qnorm.quantile_normalize(df, ncpus=8)  
```

### Normalize onto distribution

You can also use the `quantile_normalize` function to normalize "onto" a distribution, by passing a target along to the function call. 

```python
import pandas as pd
import qnorm

df = pd.DataFrame({'C1': {'A': 4, 'B': 3, 'C': 2, 'D': 1},
                   'C2': {'A': 1, 'B': 2, 'C': 3, 'D': 4}})

print(qnorm.quantile_normalize(df, target=[8, 9, 10, 11]))
```

With our values now transformed onto the target:

```
     C1    C2
A  11.0   8.0
B  10.0   9.0
C   9.0  10.0
D   8.0  11.0
```


## Command Line Interface (CLI) example

Qnorm also contains a CLI for converting csv/tsv files. The CLI depends on pandas, but this is an optional dependency of qnorm. To make use of the CLI make sure to install pandas in your current environment as well!


```console
user@comp:~$ qnorm --help

usage: qnorm [-h] [-v] table

Quantile normalize your table

positional arguments:
  table          input csv/tsv file which will be quantile normalized

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit
```

And again the example of [Wikipedia](https://en.wikipedia.org/wiki/Quantile_normalization):

```console
user@comp:~$ cat table.tsv
        C1      C2      C3
A       5       4       3
B       2       1       4
C       3       4       6
D       4       2       8

user@comp:~$ qnorm table.tsv
        C1      C2      C3
A       5.666666666666666       5.166666666666666       2.0
B       2.0     2.0     3.0
C       3.0     5.166666666666666       4.666666666666666
D       4.666666666666666       3.0     5.666666666666666
```

**NOTE:** the qnorm cli assumes that the first column and the first row are used as descriptors, and are "ignored" in the quantile normalization process. Lines starting with a hashtag "#" are treated as comments and ignored.

## Installation

### pip

```console
user@comp:~$ pip install qnorm
```

### conda

Installing qnorm from the conda-forge channel can be achieved by adding conda-forge to your channels with:

```console
user@comp:~$ conda config --add channels conda-forge
```

Once the conda-forge channel has been enabled, qnorm can be installed with:

```console
user@comp:~$ conda install qnorm
```

### local

clone the repository

```console
user@comp:~$ git clone https://github.com/Maarten-vd-Sande/qnorm
```

And install it

```console
user@comp:~$ cd qnorm
user@comp:~$ pip install .
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Maarten-vd-Sande/qnorm",
    "name": "qnorm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "['Maarten van der Sande <maartenvandersande@hotmail.com>']",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f1/1a/eb06c52dcb2c5f50433367e563c18de58d4ec181c5eefc1e819c52b4e9ed/qnorm-0.4.0.tar.gz",
    "platform": "",
    "description": "# qnorm\n[![PyPI version](https://badge.fury.io/py/qnorm.svg)](https://badge.fury.io/py/qnorm)\n[![Anaconda version](https://anaconda.org/conda-forge/qnorm/badges/version.svg)](https://anaconda.org/conda-forge/qnorm)\n![tests](https://github.com/Maarten-vd-Sande/qnorm/workflows/tests/badge.svg)\n\nquantile normalization made easy.\n\n## Code example\n\nWe recreate the example of [Wikipedia](https://en.wikipedia.org/wiki/Quantile_normalization):\n\n```python\nimport pandas as pd\nimport qnorm\n\ndf = pd.DataFrame({'C1': {'A': 5, 'B': 2, 'C': 3, 'D': 4},\n                   'C2': {'A': 4, 'B': 1, 'C': 4, 'D': 2},\n                   'C3': {'A': 3, 'B': 4, 'C': 6, 'D': 8}})\n\nprint(qnorm.quantile_normalize(df))\n```\n\nwhich is what we expect:\n\n```\n         C1        C2        C3\nA  5.666667  5.166667  2.000000\nB  2.000000  2.000000  3.000000\nC  3.000000  5.166667  4.666667\nD  4.666667  3.000000  5.666667\n```\n\n**NOTE**: The function quantile_normalize also accepts numpy arrays. \n\n### Multicore support\n\nTo accelerate the computation you can pass a ncpus argument to the function call and qnorm will be run in parallel:\n\n```python\nqnorm.quantile_normalize(df, ncpus=8)  \n```\n\n### Normalize onto distribution\n\nYou can also use the `quantile_normalize` function to normalize \"onto\" a distribution, by passing a target along to the function call. \n\n```python\nimport pandas as pd\nimport qnorm\n\ndf = pd.DataFrame({'C1': {'A': 4, 'B': 3, 'C': 2, 'D': 1},\n                   'C2': {'A': 1, 'B': 2, 'C': 3, 'D': 4}})\n\nprint(qnorm.quantile_normalize(df, target=[8, 9, 10, 11]))\n```\n\nWith our values now transformed onto the target:\n\n```\n     C1    C2\nA  11.0   8.0\nB  10.0   9.0\nC   9.0  10.0\nD   8.0  11.0\n```\n\n\n## Command Line Interface (CLI) example\n\nQnorm also contains a CLI for converting csv/tsv files. The CLI depends on pandas, but this is an optional dependency of qnorm. To make use of the CLI make sure to install pandas in your current environment as well!\n\n\n```console\nuser@comp:~$ qnorm --help\n\nusage: qnorm [-h] [-v] table\n\nQuantile normalize your table\n\npositional arguments:\n  table          input csv/tsv file which will be quantile normalized\n\noptional arguments:\n  -h, --help     show this help message and exit\n  -v, --version  show program's version number and exit\n```\n\nAnd again the example of [Wikipedia](https://en.wikipedia.org/wiki/Quantile_normalization):\n\n```console\nuser@comp:~$ cat table.tsv\n        C1      C2      C3\nA       5       4       3\nB       2       1       4\nC       3       4       6\nD       4       2       8\n\nuser@comp:~$ qnorm table.tsv\n        C1      C2      C3\nA       5.666666666666666       5.166666666666666       2.0\nB       2.0     2.0     3.0\nC       3.0     5.166666666666666       4.666666666666666\nD       4.666666666666666       3.0     5.666666666666666\n```\n\n**NOTE:** the qnorm cli assumes that the first column and the first row are used as descriptors, and are \"ignored\" in the quantile normalization process. Lines starting with a hashtag \"#\" are treated as comments and ignored.\n\n## Installation\n\n### pip\n\n```console\nuser@comp:~$ pip install qnorm\n```\n\n### conda\n\nInstalling qnorm from the conda-forge channel can be achieved by adding conda-forge to your channels with:\n\n```console\nuser@comp:~$ conda config --add channels conda-forge\n```\n\nOnce the conda-forge channel has been enabled, qnorm can be installed with:\n\n```console\nuser@comp:~$ conda install qnorm\n```\n\n### local\n\nclone the repository\n\n```console\nuser@comp:~$ git clone https://github.com/Maarten-vd-Sande/qnorm\n```\n\nAnd install it\n\n```console\nuser@comp:~$ cd qnorm\nuser@comp:~$ pip install .\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Quantile normalization",
    "version": "0.4.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "883006bf652de30d92fa28a064202410",
                "sha256": "76b2630456baf06d4008defda05136d22b3b6ecae9ab92944187718666c47849"
            },
            "downloads": -1,
            "filename": "qnorm-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "883006bf652de30d92fa28a064202410",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">3.6",
            "size": 8427,
            "upload_time": "2020-09-28T11:36:43",
            "upload_time_iso_8601": "2020-09-28T11:36:43.481003Z",
            "url": "https://files.pythonhosted.org/packages/fb/7a/6eb9d263379d614fbdf779b399eee4c0f59271473a1d967a09f6c0c4d52d/qnorm-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "ef067bd309f93996c94dd4b2e704f17a",
                "sha256": "d0df6fcdf9a35fe95c735494495864e1dfbef63af5d515a05c88d189cfa46670"
            },
            "downloads": -1,
            "filename": "qnorm-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ef067bd309f93996c94dd4b2e704f17a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">3.6",
            "size": 7376,
            "upload_time": "2020-09-28T11:36:44",
            "upload_time_iso_8601": "2020-09-28T11:36:44.593673Z",
            "url": "https://files.pythonhosted.org/packages/f1/1a/eb06c52dcb2c5f50433367e563c18de58d4ec181c5eefc1e819c52b4e9ed/qnorm-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-09-28 11:36:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "Maarten-vd-Sande",
    "error": "Could not fetch GitHub repository",
    "lcname": "qnorm"
}
        
Elapsed time: 0.15345s