A Python implementation of the SOM training functionality of FlowSOM
Project description
pyFlowSOM
Python runner for the FlowSOM library.
Basic usage:
import numpy as np
import pandas as pd
from pyFlowSOM import map_data_to_nodes, som
# generate example input data, rows are observations (e.g. cells), columns are features (e.g. proteins)
df = pd.DataFrame(np.random.rand(500, 16))
# alternatively, specify path to your own input data
df = pd.read_csv('path/to/som/input.csv')
example_som_input_arr = df.to_numpy()
# train the SOM
node_output = som(example_som_input_arr, xdim=10, ydim=10, rlen=10)
# use trained SOM to assign clusters to each observation in your data
clusters, dists = map_data_to_nodes(node_output, example_som_input_arr)
To put the data back into dataframes:
eno = pd.DataFrame(data=node_output, columns=df.columns)
eco = pd.DataFrame(data=clusters, columns=["cluster"])
To export to csv:
eno.to_csv('examples/example_node_output.csv', index=False)
eco.to_csv('examples/example_clusters_output.csv', index=False)
To plot the output as a heatmap:
import seaborn as sns
# Append results to the input data
df['cluster'] = clusters
# Find mean of each cluster
df_mean = df.groupby(['cluster']).mean()
# Make heatmap
sns_plot = sns.clustermap(df_mean, z_score=1, cmap="vlag", center=0, yticklabels=True)
sns_plot.figure.savefig(f"example_cluster_heatmap.png")
Develop
The C code (pyFlowSOM/flowsom.c
) is wrapped using Cython (pyFlowSOM/cyFlowSOM.cyx
).
Tests do an exact comparison to cluster id ground truth and an approximate comparison to node values only because of floating point differences. Randomness works in tandem to the seed
flag to the som
function.
To run the tests, use the following command:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pyFlowSOM-0.1.15.tar.gz
.
File metadata
- Download URL: pyFlowSOM-0.1.15.tar.gz
- Upload date:
- Size: 155.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f91a136192f628ce6bab8d6d76888a5d0764f4fcb834c5369356d1f242f19fc7 |
|
MD5 | 97e515f750ef58dea9c6165947c49b1e |
|
BLAKE2b-256 | cd4ee893d8fa71b84c39389c71234d0b05c841cf860f5f237cb7ee4397d44b38 |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-win_arm64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-win_arm64.whl
- Upload date:
- Size: 72.6 kB
- Tags: CPython 3.11, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3352727af9d3c8729e1482ed48940abb2c0846369ba848b3e6d644a4f6754bf0 |
|
MD5 | 6625571af319b3dd3c469f788233ce32 |
|
BLAKE2b-256 | d6c14cf3e8596a1b2f6aefcda111291e930805e6f4cb557bea95f3669f0a8628 |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 88.3 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36055bcc436d75477d28c28576d8fb04cae0d480de867f0263f1c19840810e3e |
|
MD5 | 87728712c036f34e28256faaddb6ae64 |
|
BLAKE2b-256 | 57a72b913c190c00fa1414f0ed5acb7fa3710349a874eea61a2a5207e85f5218 |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 680.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd5e3d59c92c970ecc4a9dee39a05ba3d9784e73a3848ff0ee8a756a6b5f551a |
|
MD5 | acb1578f3773723d96e88c216695bd1b |
|
BLAKE2b-256 | 10c2c1f6c88f1ef73e05a25f7a2df1f0a0b6f0a709a21e2f22b302d739996c0d |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 667.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0c5ed13e7c8b999a376eb4886f25808b7218d35b327734fc354f98350acfae2 |
|
MD5 | d137ad876b332643a328efb400b7ca69 |
|
BLAKE2b-256 | d4e2cd97bd661ca79359f8de785e6799d9157723600f669748c0f13f9fb796ed |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 221.6 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1953354fea0544805cb6061d3e09869a473a0fbe6e8a6383ac6bb40efc4e46d4 |
|
MD5 | eb97e2293a955a5b37603e86de62feec |
|
BLAKE2b-256 | 8ab64e13e121c0717a37cf1869957d7b94c4cfe378354cf28ba266c58ce7f190 |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 232.1 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 403abfe25051624486ed4ac7ba8e07d58b9dc01bb6f80f009d1b6ec692598add |
|
MD5 | b7a7ff52fe98624e323917b1d39d6e77 |
|
BLAKE2b-256 | c26ea3affc7af2c153e4a01c020099c7d289f32338999b176297c8cb77e0daa3 |
File details
Details for the file pyFlowSOM-0.1.15-cp311-cp311-macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 317.2 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96252e0ff117738ab026f56f4b50c0f1c1177d5720e5e9d044ad51678706787e |
|
MD5 | 1434980a6cd52890959d77baa73a3649 |
|
BLAKE2b-256 | d3f64a7957670bfea0200c4a08ec80a9133bc31ebe19e8ed07b38b960884bac2 |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-win_arm64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-win_arm64.whl
- Upload date:
- Size: 72.7 kB
- Tags: CPython 3.10, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d81c1eb7a50b729b891fc4375a75819b57754e90c64e198aa7e4a0b75a84fc42 |
|
MD5 | ad04f5f6df19e3744744fd4c0bb74ca5 |
|
BLAKE2b-256 | 80d54bcbe8cc6cc94567fe2b7cd55d8611965bf8c4b63e9c6c4e9bc7538b6317 |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 89.3 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 803a6f085335b274df7b5b3aa18f5fae9724d398c3ce6d6fc125d4ede5551208 |
|
MD5 | 557889f40ce8f0e8bbf2d6d00952611d |
|
BLAKE2b-256 | 12c14ff98b5ed476596b32245abfd78c20d784642d49794257ba10228477253b |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 649.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8ab72a4ecfe3953d579f512abb4403df8c470bb29971e4d988803e97dca922c |
|
MD5 | 45c45a99b6f065f79d9e6916141565af |
|
BLAKE2b-256 | a6285b7e523d49451f880d9ab129768084d9d77867695c6c08e3b0c60cb60782 |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 639.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cd2afc7caf885aacd930730306221ff0c97623563e4cd95a9144963ac0c0151 |
|
MD5 | f418405f6ddaa6c79b2480126a9c65e6 |
|
BLAKE2b-256 | 65ca36906e50c52d2e0846343ce8fc90cc29f2c2018d2ce0361b273adb870df1 |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 224.6 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b2970fdc67ab7a72098adf31d27ad9744ee66bef3951f8243979d6b4b20d073 |
|
MD5 | 0451c2fa5fa544ece71e7e0c750136c0 |
|
BLAKE2b-256 | 573d2b230836b66d4d65eccddb67b9af66df4321d5bfc43b765d9f18f9ee67e1 |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 234.7 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f02a7ff90a2963dca84468f59dbb05bb6707b0e8631fc216b42fd8745ac65fd |
|
MD5 | f1ef66cfddaabdccfec740bae630831b |
|
BLAKE2b-256 | 03c5ca7c07a2aa71c5cdf80ba8e40d867be67900e2f79d18939570c9dac9242e |
File details
Details for the file pyFlowSOM-0.1.15-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 323.1 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 439a647d80f047c67d7a21a1e1b8c11e255c625ff43ee954b7b967f71f36a721 |
|
MD5 | e80d8b4f94e9e5b740d487b5530042f0 |
|
BLAKE2b-256 | ae5308941c13d13262ca87dc07e6fb6e34e571c99da1327834c3c91950076f88 |
File details
Details for the file pyFlowSOM-0.1.15-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 91.1 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e218464e62a49ed58a57be6d967c97d9cec6b01cf0fa187c2cffe1e80a52d734 |
|
MD5 | 854b91fecf47e1f4aa33d32fa95a53b3 |
|
BLAKE2b-256 | 433fa7c685bc89099eb3a9c35f6b9d325ca4d3ae1ecf97336eed61cf3a3d01a1 |
File details
Details for the file pyFlowSOM-0.1.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 655.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2a9aa2d6a3b3d105292f944569436546ca038e48667b336a411fb1507ba93a4 |
|
MD5 | f5eb9c4fbe47f30ac076e9f8d4370395 |
|
BLAKE2b-256 | 36be7c76e732b0eca0c68112151568946e22810ba18a1216681bed8fb4904b8d |
File details
Details for the file pyFlowSOM-0.1.15-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 650.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9af0108d4224dabe910461910a10c5bae3282a571df95bae966bb592dac75d2 |
|
MD5 | d8e6c60977e016408485ea740bb4902a |
|
BLAKE2b-256 | 751f2c6ec559f5199723502108e6a18d2caf8fce17012c43377d63436e1cdcbb |
File details
Details for the file pyFlowSOM-0.1.15-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 224.2 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea48913ed9eb94cf1151c8381928ef36f4806f9f66b703bc250dc5d203c7316e |
|
MD5 | a7a133b0b1ac46108710fef3b4eadfe2 |
|
BLAKE2b-256 | 4fb5e6be8bde2b41117bab4ad7e5e0c15891fbb97ae32ad73ce216446a4111fa |
File details
Details for the file pyFlowSOM-0.1.15-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 234.2 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c6f978a0c07438a0b876461c054e3953a323f5c63dee6236a70b3cafd517f45 |
|
MD5 | 856191b95951c1602e7ea40eefc428c6 |
|
BLAKE2b-256 | 32c4f07e4e93b4ff0f6fecc7f97bb03e6457fc4b6a371fd1ee1e53b3d4cabed4 |
File details
Details for the file pyFlowSOM-0.1.15-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.15-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 322.3 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0563ef018d6f7ea342052546ae729bad8dcddc6a0c48aab09b58c9fbf85b424c |
|
MD5 | a7c230a981e816ba4cee34c92bdb219e |
|
BLAKE2b-256 | c5e3eb0e1a6c4375530369d9d286dce8928e6d383f60e6b42e6698a954c3e2cc |