speakeasy2


Namespeakeasy2 JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/SpeakEasy-2/python-speakeasy2
SummarySpeakEasy2 community detection algorithm
upload_time2024-08-19 19:52:51
maintainerNone
docs_urlNone
authorDavid R Connell
requires_python>=3.10
licenseGPLv3+
keywords network community detection cluster graph
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python SpeakEasy2 package

![PyPI - Version](https://img.shields.io/pypi/v/speakeasy2)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/speakeasy2)


Provides the SpeakEasy2 community detection algorithm to cluster graph's stored as igraph's data type. The algorithm is described in the [Genome Biology article](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-023-03062-0).

Example:

```python
 import igraph as ig
 import speakeasy2 as se2

 g = ig.Graph.Famous("Zachary")
 memb = se2.cluster(g)
```

From the results, a node ordering can be computed to group nodes in a community together. This can be used as an index and works to display the community structure using a heatmap to view the adjacency matrix.

```python
ordering = se2.order_nodes(g, memb)
```

SpeakEasy 2 can work with weighted graphs by either passing weights as a list with length equal to the number of edges or by using the igraph attribute table.

```python
g.es["weight"] = [1 for _ in range(g.ecount())]
memb = se2.cluster(g)
```

By default, SpeakEasy 2 will check if there is an edge attribute associated with the graph named `weight` and use those as weights. If you want to use a different edge attribute, pass the name of the attribute.

```python
memb = se2.cluster(g, weights="tie_strength")
```

Or if a graph has a weight edge attribute but you don't want to use them, explicitly pass `None` to the `weights` keyword argument.

Subclustering can be used to detect hierarchical community structure.

```python
memb = se2.cluster(g, subcluster=2)
```

The number determines how many levels to perform community detection at. The default 1 means only to perform community detection at the top level (i.e. no subclustering). When subclustering, membership will be a list of `igraph.VertexClustering` objects, the top level membership will be the object at index 0.

A few other useful keywords arguments are `max_threads`, `verbose`, and `seed`. The `max_thread` keyword determines how many processors SpeakEasy 2 is allowed to use. By default the value returned by OpenMP is used. To prevent parallel processing, explicitly pass `max_threads = 1` to the method.

The `verbose` option will cause the algorithm to print out some information about the process.

For reproducible results, the `seed` option sets the seed of the random number generator. Note: this is a random number generator managed by the underlying C library and is independent of other random number generators that might have been set in python.

## Installation

speakeasy2 is available from pypi so it can be installed with `pip` or other package managers.

```bash
pip install --user speakeasy2
```

## Building from source

This package can be built using `CMake`. It requires the `flex`, `bison`, and `libxml2` dependencies for building `igraph` and `poetry` for managing python dependencies.

Since the `igraph` package is supplied by the vendored SE2 C library, after cloning the source directory, submodules most be recursively initialized.

```bash
git clone "https://github.com/SpeakEasy-2/python-speakeasy2"
cd python-speakeasy2
git submodule update --init --recursive
```

Then build the package using `cmake`:

```bash
cmake -B build
camke --build build
```

Since the compiled python shared libraries are built in the `build` directory, to use the local python package, link the shared libs to the python package:

```bash
cd speakeasy2
ln -s ../build/_speakeasy2.so
cd ..
```

Use `poetry` to install dependencies in a virtual env:

```bash
poetry install
```

It should now be possible to run scripts through `poetry`:

```bash
poetry run ipython path/to/script.py
```

Or enter a python repository with the private environment activate in the same way.

```bash
poetry run ipython
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SpeakEasy-2/python-speakeasy2",
    "name": "speakeasy2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "network, community detection, cluster, graph",
    "author": "David R Connell",
    "author_email": "davidconnell12@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/57/d7d4604babecab847cd243f461033377d31d1588391908e4da2c7a474003/speakeasy2-0.1.1.tar.gz",
    "platform": null,
    "description": "# Python SpeakEasy2 package\n\n![PyPI - Version](https://img.shields.io/pypi/v/speakeasy2)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/speakeasy2)\n\n\nProvides the SpeakEasy2 community detection algorithm to cluster graph's stored as igraph's data type. The algorithm is described in the [Genome Biology article](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-023-03062-0).\n\nExample:\n\n```python\n import igraph as ig\n import speakeasy2 as se2\n\n g = ig.Graph.Famous(\"Zachary\")\n memb = se2.cluster(g)\n```\n\nFrom the results, a node ordering can be computed to group nodes in a community together. This can be used as an index and works to display the community structure using a heatmap to view the adjacency matrix.\n\n```python\nordering = se2.order_nodes(g, memb)\n```\n\nSpeakEasy 2 can work with weighted graphs by either passing weights as a list with length equal to the number of edges or by using the igraph attribute table.\n\n```python\ng.es[\"weight\"] = [1 for _ in range(g.ecount())]\nmemb = se2.cluster(g)\n```\n\nBy default, SpeakEasy 2 will check if there is an edge attribute associated with the graph named `weight` and use those as weights. If you want to use a different edge attribute, pass the name of the attribute.\n\n```python\nmemb = se2.cluster(g, weights=\"tie_strength\")\n```\n\nOr if a graph has a weight edge attribute but you don't want to use them, explicitly pass `None` to the `weights` keyword argument.\n\nSubclustering can be used to detect hierarchical community structure.\n\n```python\nmemb = se2.cluster(g, subcluster=2)\n```\n\nThe number determines how many levels to perform community detection at. The default 1 means only to perform community detection at the top level (i.e. no subclustering). When subclustering, membership will be a list of `igraph.VertexClustering` objects, the top level membership will be the object at index 0.\n\nA few other useful keywords arguments are `max_threads`, `verbose`, and `seed`. The `max_thread` keyword determines how many processors SpeakEasy 2 is allowed to use. By default the value returned by OpenMP is used. To prevent parallel processing, explicitly pass `max_threads = 1` to the method.\n\nThe `verbose` option will cause the algorithm to print out some information about the process.\n\nFor reproducible results, the `seed` option sets the seed of the random number generator. Note: this is a random number generator managed by the underlying C library and is independent of other random number generators that might have been set in python.\n\n## Installation\n\nspeakeasy2 is available from pypi so it can be installed with `pip` or other package managers.\n\n```bash\npip install --user speakeasy2\n```\n\n## Building from source\n\nThis package can be built using `CMake`. It requires the `flex`, `bison`, and `libxml2` dependencies for building `igraph` and `poetry` for managing python dependencies.\n\nSince the `igraph` package is supplied by the vendored SE2 C library, after cloning the source directory, submodules most be recursively initialized.\n\n```bash\ngit clone \"https://github.com/SpeakEasy-2/python-speakeasy2\"\ncd python-speakeasy2\ngit submodule update --init --recursive\n```\n\nThen build the package using `cmake`:\n\n```bash\ncmake -B build\ncamke --build build\n```\n\nSince the compiled python shared libraries are built in the `build` directory, to use the local python package, link the shared libs to the python package:\n\n```bash\ncd speakeasy2\nln -s ../build/_speakeasy2.so\ncd ..\n```\n\nUse `poetry` to install dependencies in a virtual env:\n\n```bash\npoetry install\n```\n\nIt should now be possible to run scripts through `poetry`:\n\n```bash\npoetry run ipython path/to/script.py\n```\n\nOr enter a python repository with the private environment activate in the same way.\n\n```bash\npoetry run ipython\n```\n\n",
    "bugtrack_url": null,
    "license": "GPLv3+",
    "summary": "SpeakEasy2 community detection algorithm",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/SpeakEasy-2/python-speakeasy2",
        "Repository": "https://github.com/SpeakEasy-2/python-speakeasy2"
    },
    "split_keywords": [
        "network",
        " community detection",
        " cluster",
        " graph"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "569bbf903b6d6103c48e467d8fa8d62e62b9b523ea86fc9d92fcf1a09cc97885",
                "md5": "d5b46d2613c7dd8dd9f876b5cd966546",
                "sha256": "f4dfb2e4987d6228854de7de7e3a4b767fe9a680e42f58656e07e6141a3f863e"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp310-cp310-macosx_14_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "d5b46d2613c7dd8dd9f876b5cd966546",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 294739,
            "upload_time": "2024-08-19T19:52:38",
            "upload_time_iso_8601": "2024-08-19T19:52:38.201436Z",
            "url": "https://files.pythonhosted.org/packages/56/9b/bf903b6d6103c48e467d8fa8d62e62b9b523ea86fc9d92fcf1a09cc97885/speakeasy2-0.1.1-cp310-cp310-macosx_14_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9f307048397971d8f3f87313bd637e3c8d85970a0b7819eb3cb0c98e8316bbd",
                "md5": "f2f31ce2bdbcd1ca04f0e8415e95d9f8",
                "sha256": "63d70de13dd03d7b76ab4d55582879cf42768b4838e9d1a37e4059684ef8179a"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp310-cp310-manylinux_2_31_x86_64.whl",
            "has_sig": false,
            "md5_digest": "f2f31ce2bdbcd1ca04f0e8415e95d9f8",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 320326,
            "upload_time": "2024-08-19T19:52:39",
            "upload_time_iso_8601": "2024-08-19T19:52:39.806300Z",
            "url": "https://files.pythonhosted.org/packages/c9/f3/07048397971d8f3f87313bd637e3c8d85970a0b7819eb3cb0c98e8316bbd/speakeasy2-0.1.1-cp310-cp310-manylinux_2_31_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0dfd756ae4211756da76f11899787a9bd51fb9ec07150be4d191adafd51fb5eb",
                "md5": "27e7062f292c6f31363052923b1ed372",
                "sha256": "b990804b40814eab34aeeae4aa5e2e0b5db5986ba4861a7e37d39795138f6b3f"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "27e7062f292c6f31363052923b1ed372",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 331915,
            "upload_time": "2024-08-19T19:52:41",
            "upload_time_iso_8601": "2024-08-19T19:52:41.287212Z",
            "url": "https://files.pythonhosted.org/packages/0d/fd/756ae4211756da76f11899787a9bd51fb9ec07150be4d191adafd51fb5eb/speakeasy2-0.1.1-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95e168f83d93609e1a4b0cb10331d00a408a37867f72013f95a3499480d9f916",
                "md5": "29e7b029466248f7ec874401c93e55ab",
                "sha256": "f233d2dd326a0549c7d9ab6f8a6c6e9bce5434cb359cdadf80ef007081c8b742"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp311-cp311-macosx_14_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "29e7b029466248f7ec874401c93e55ab",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 294771,
            "upload_time": "2024-08-19T19:52:42",
            "upload_time_iso_8601": "2024-08-19T19:52:42.463316Z",
            "url": "https://files.pythonhosted.org/packages/95/e1/68f83d93609e1a4b0cb10331d00a408a37867f72013f95a3499480d9f916/speakeasy2-0.1.1-cp311-cp311-macosx_14_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6aa27d939190538fe92c51a020bd8e61b6eba17875c714e6200e20c82e66a63a",
                "md5": "6fcec7724563c2dac9bc3120ed7ad2b2",
                "sha256": "93cbc07fcc6cf3c787dd4dbbf9b1060b2e9ef7edb6da32fdd25080312e8c1d64"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp311-cp311-manylinux_2_31_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6fcec7724563c2dac9bc3120ed7ad2b2",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 320264,
            "upload_time": "2024-08-19T19:52:43",
            "upload_time_iso_8601": "2024-08-19T19:52:43.764641Z",
            "url": "https://files.pythonhosted.org/packages/6a/a2/7d939190538fe92c51a020bd8e61b6eba17875c714e6200e20c82e66a63a/speakeasy2-0.1.1-cp311-cp311-manylinux_2_31_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "126811145e500afc077eaa5acf0292a294e1338ea2d5d86d19055809deba93b0",
                "md5": "8052785a2d9a92fcd0bc4f82ed30b374",
                "sha256": "fbe061fb06f9603e4eec49462f3fceb32c48df12da65ea492e36ed6362b7b27b"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp311-cp311-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "8052785a2d9a92fcd0bc4f82ed30b374",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 331976,
            "upload_time": "2024-08-19T19:52:44",
            "upload_time_iso_8601": "2024-08-19T19:52:44.842382Z",
            "url": "https://files.pythonhosted.org/packages/12/68/11145e500afc077eaa5acf0292a294e1338ea2d5d86d19055809deba93b0/speakeasy2-0.1.1-cp311-cp311-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3fab665ef87bf40f1fc20a2181f20c8e1661d48104607a93c493a00b19fa8002",
                "md5": "36e80c26e8e7fc181901dcc9940d56aa",
                "sha256": "91801a864347e32e4646f10918c0fa5a86a854d2b3877c3940577d29ecd02ca7"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp312-cp312-macosx_14_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "36e80c26e8e7fc181901dcc9940d56aa",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 294772,
            "upload_time": "2024-08-19T19:52:46",
            "upload_time_iso_8601": "2024-08-19T19:52:46.351418Z",
            "url": "https://files.pythonhosted.org/packages/3f/ab/665ef87bf40f1fc20a2181f20c8e1661d48104607a93c493a00b19fa8002/speakeasy2-0.1.1-cp312-cp312-macosx_14_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec027626ecda78b61af398e9b5d1b4abebf7d7013b576c00978fefb3f8df3b33",
                "md5": "1a62861789c17689551f8e72a25b203d",
                "sha256": "c2e193df0a1cc7fe8ad79e1ccd4c75d8d2f3757c878198de52a8e9d58f600e94"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp312-cp312-manylinux_2_31_x86_64.whl",
            "has_sig": false,
            "md5_digest": "1a62861789c17689551f8e72a25b203d",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 320262,
            "upload_time": "2024-08-19T19:52:48",
            "upload_time_iso_8601": "2024-08-19T19:52:48.906264Z",
            "url": "https://files.pythonhosted.org/packages/ec/02/7626ecda78b61af398e9b5d1b4abebf7d7013b576c00978fefb3f8df3b33/speakeasy2-0.1.1-cp312-cp312-manylinux_2_31_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ca4ff0110375a5c0f43b7d9fbbdd1d9a2a5e5aa7071008de7d9349aa8d696ce",
                "md5": "cee83fc7a45ec54038a76064766bfcc4",
                "sha256": "088128ae8eec24cb369d075a54940fe272152059637c439096b113d615ec486a"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1-cp312-cp312-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "cee83fc7a45ec54038a76064766bfcc4",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 331974,
            "upload_time": "2024-08-19T19:52:50",
            "upload_time_iso_8601": "2024-08-19T19:52:50.297343Z",
            "url": "https://files.pythonhosted.org/packages/3c/a4/ff0110375a5c0f43b7d9fbbdd1d9a2a5e5aa7071008de7d9349aa8d696ce/speakeasy2-0.1.1-cp312-cp312-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd57d7d4604babecab847cd243f461033377d31d1588391908e4da2c7a474003",
                "md5": "a325385b02ee5c2dd4770190b74a73e2",
                "sha256": "ebc5520b378b31c0d796fd343217af69cb54b31f1c67bbf0944dc4284aebbe7a"
            },
            "downloads": -1,
            "filename": "speakeasy2-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a325385b02ee5c2dd4770190b74a73e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 19963,
            "upload_time": "2024-08-19T19:52:51",
            "upload_time_iso_8601": "2024-08-19T19:52:51.789011Z",
            "url": "https://files.pythonhosted.org/packages/dd/57/d7d4604babecab847cd243f461033377d31d1588391908e4da2c7a474003/speakeasy2-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-19 19:52:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SpeakEasy-2",
    "github_project": "python-speakeasy2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "speakeasy2"
}
        
Elapsed time: 2.42860s