A Python implementation of the SOM training functionality of FlowSOM
Project description
pyFlowSOM
Python runner for the FlowSOM library.
Basic usage:
import pandas as pd
from pyFlowSOM import map_data_to_nodes, som
df = pd.read_csv('examples/example_som_input.csv')
example_som_input_arr = df.to_numpy()
node_output = som(example_som_input_arr, xdim=10, ydim=10, rlen=10)
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
example_som_input_df['cluster'] = clusters
# Find mean of each cluster
df_mean = example_som_input_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
Continually build and test while developing. This will automatically create your virtual env
./build.sh && ./test.sh
The C code (pyFlowSOM/flosom.c
) is wrapped using Cython (pyFlowSOM/cyFlowSOM.c
).
Tests do an approximate exact comparison to cluster id groundtruth and an approximate comparison to node values only because of floating point differences. All randomness has stubbed out in in the y2kbugger/FlowSOM fork and works in tandem to the deterministic
flag to the som
function.
To regenerate test data, which may be required if you changed any sources of randomness:
python -m pyFlowSOM.generate_test_outputs
To generate heatmaps for manual comparison:
python -m pyFlowSOM.generate_test_heatmaps
To bump the version and deploy to pypi:
Just add the tag which matches the version you want to deploy:
git tag v0.1.4
git push --tags
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.13.tar.gz
.
File metadata
- Download URL: pyFlowSOM-0.1.13.tar.gz
- Upload date:
- Size: 124.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cc2c80749fb50c881a62540dbff5fe5fabd37f2ba4ad64ce0d9c19afe44fc50 |
|
MD5 | 1d5d3555aeae51c913bd198a6981e761 |
|
BLAKE2b-256 | 28a0c697d73270621b54d650335b129bb13018afc662726ec2b550483cea53ce |
File details
Details for the file pyFlowSOM-0.1.13-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.13-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 200.6 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25f354cb004e49ddc1965ecbc052cb12084ac9be219ac51ce802b5cc403e4845 |
|
MD5 | af172c3c177d977476436199b5307503 |
|
BLAKE2b-256 | b9ec61f4662da017174c83f4559375345be89eab3b32e2570a938cb29c53deb4 |
File details
Details for the file pyFlowSOM-0.1.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 619.5 kB
- Tags: CPython 3.8, 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.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 024dae4fd5d43e54680a2d54bb7ad9cc84d0ab2e87792022e060880241915c83 |
|
MD5 | aca3d3718f10aac327091268c7674dc6 |
|
BLAKE2b-256 | 3c7b5c3819f3feabdd7e888a9b80f170e29286a93677ac00252295f538da6831 |
File details
Details for the file pyFlowSOM-0.1.13-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.13-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 614.8 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ebf385bb57c27ec63c47f19f10818e37a6ec6962f4588677742aac40257c67c |
|
MD5 | d637286769835cf8617b4785452ffa4b |
|
BLAKE2b-256 | 9f93cb8d6fa3077d8f93215fd70784c6d3d10074a04c9a2d4620d62659ac9048 |
File details
Details for the file pyFlowSOM-0.1.13-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.13-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 204.4 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a528fc9d9f3ee1cbe33dc230c96e3460e72d0449430ef97424840ef1ac12b719 |
|
MD5 | bbff559d1b39e698b4dac3944f755ec5 |
|
BLAKE2b-256 | eeb16c3c7e9a99f92b02715e9957c1bcc59c936e4e06609f83fb0fb34331218b |
File details
Details for the file pyFlowSOM-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 212.7 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50c3750c9a9732324e0444c0f981ce13e163d4a869ce54610f4c43f6c6e75877 |
|
MD5 | 33457e8b437c77ff85b96d6e7a0a775e |
|
BLAKE2b-256 | d61cc558820b87c646a666bebba6134d9345fe9f1d09d78413d3469d30a0182a |
File details
Details for the file pyFlowSOM-0.1.13-cp38-cp38-macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyFlowSOM-0.1.13-cp38-cp38-macosx_10_9_universal2.whl
- Upload date:
- Size: 291.6 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88ffe8b21f0064da0287017e1b15aea108517ed4255009484245254eb251a7a0 |
|
MD5 | 3e84fe1a7659f76bd729e9b2baf0981d |
|
BLAKE2b-256 | dc4b3d2ccef52c22e2a196a726083bfcfe5877e2f9868a344d408711caaff352 |