Skip to main content

A Python implementation of the SOM training functionality of FlowSOM

Project description

Build Status Coverage Status

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.14
git push --tags

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyFlowSOM-0.1.14.tar.gz (125.1 kB view details)

Uploaded Source

Built Distributions

pyFlowSOM-0.1.14-cp38-cp38-win_amd64.whl (201.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyFlowSOM-0.1.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (623.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.28+ x86-64

pyFlowSOM-0.1.14-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl (618.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64 manylinux: glibc 2.28+ ARM64

pyFlowSOM-0.1.14-cp38-cp38-macosx_11_0_arm64.whl (205.7 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyFlowSOM-0.1.14-cp38-cp38-macosx_10_9_x86_64.whl (214.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pyFlowSOM-0.1.14-cp38-cp38-macosx_10_9_universal2.whl (293.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file pyFlowSOM-0.1.14.tar.gz.

File metadata

  • Download URL: pyFlowSOM-0.1.14.tar.gz
  • Upload date:
  • Size: 125.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for pyFlowSOM-0.1.14.tar.gz
Algorithm Hash digest
SHA256 e6e3e0b6f395457d8a1295d84b86b065ce0907adfd5f1d2be40aeb43042f6d21
MD5 5d5afc54e00a13bd4abbd780b3b65311
BLAKE2b-256 1bda91757a172c3c300e0511f3b8d39db6122d80dc07637cd655f342814bc2a2

See more details on using hashes here.

File details

Details for the file pyFlowSOM-0.1.14-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyFlowSOM-0.1.14-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 201.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for pyFlowSOM-0.1.14-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e616183cf36c22c8e959e480553910293bf4270e64debb56e50d372eeb08b770
MD5 58d8b1a013a364662c457f29182016e4
BLAKE2b-256 3bc34356aa04ae5df0a4828313eeeffd1bf223b0634772af5a75076dae9f82ba

See more details on using hashes here.

File details

Details for the file pyFlowSOM-0.1.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyFlowSOM-0.1.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c61e0920daf8f46256b6b7d99388668e7192c97f8bbf21bef4530e2bad323890
MD5 320d5284e3016c057753f4b4b62841d4
BLAKE2b-256 595abe39507b018b0362cd24c3f504ef9f8eba2df830556af193cccb4e42000d

See more details on using hashes here.

File details

Details for the file pyFlowSOM-0.1.14-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyFlowSOM-0.1.14-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e664886bfd412cb188d9f0d41ce55510193f863a325d8cdbaf925c1bdbe8c2df
MD5 200cd2b3cf8f8c80be316fa155b6fd38
BLAKE2b-256 5685e3c44e4e85e70a7a9d22de65b2cb051eb5b513c88ac9eb5f2d9b9dec7955

See more details on using hashes here.

File details

Details for the file pyFlowSOM-0.1.14-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyFlowSOM-0.1.14-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 757ca8880048b69135c944fed5c21e8e6e79f23a6b7f9ce9065fdc22c6db0400
MD5 cde2416617b7b9cdcf4c22f612a04f44
BLAKE2b-256 790c6c232f8d6095790a48c8ceebcb4e36818a5407ae96240bc8200ef1f76f55

See more details on using hashes here.

File details

Details for the file pyFlowSOM-0.1.14-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyFlowSOM-0.1.14-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 41fa8e6549bef18808858ef6a09d6db35a77b9e16b38d536826eebe8db1c3bec
MD5 50db968afe5e7be0f04963b55db9d6ad
BLAKE2b-256 604d7ba1c3b4911c624e6eef2b0a6b7c6d860d214c289808e717fbe1242486d7

See more details on using hashes here.

File details

Details for the file pyFlowSOM-0.1.14-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyFlowSOM-0.1.14-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 cfdb41eaf9991a3d92fbdea3d8cc6e2acaab36ed3d4e737841a86da28bc4d87f
MD5 bb14eca83a35bdcbb2372cf6239cc395
BLAKE2b-256 c41e7736e98255a9bd85a0a0bafca1888fd47a4b1174ebc3709862a54f380aed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page