Calculate dysbiosis scores using Python
Project description
Dyspyosis
Python package that can be used to compute dysbiosis scores. The package leverages autoencoders based anomaly detection. Further details on this method are available here.
Installation
Make sure you have CUDA Toolkit 11.2 and the matching cuDNN (8.1.1) installed on your system (required for Tensorflow).
pip install dyspyosis
Usage
Below you can find an example how to use the dyspyosis package. Note that this is for testing purposes and parameters
have been set to complete the script quickly. For real data you'll want to increase the rarefication_count
(the
number of times samples will be rarefied) to a large number (the number of samples x rarefication_count should be > 10k)
and increase the number of epochs
to 4000.
import pandas as pd
from dyspyosis import Dyspyosis
if __name__ == "__main__":
df = pd.read_table("./data/test.tsv", index_col=0)
dyspyosis = Dyspyosis(
df.values,
labels=df.index.tolist(),
rarefication_depth=5000,
rarefication_count=10,
)
dyspyosis.run_training(epochs=5)
loss = dyspyosis.compute_loss()
loss.to_csv("./data/loss_out.tsv", sep=",", index=None)
Benchmarks
There are two benchmark scripts included in the repository: benchmark_cpu.py
and benchmark_gpu.py
. When
running the CPU benchmark it is important to set two environmental variables before running the code, CUDA_VISIBLE_DEVICES
needs to be "-1"
and CUDA_DEVICE_ORDER
needs to be "PCI_BUS_ID". This ensures that the CPU benchmark actually runs on the CPU in case a GPU is available.
Here are some results running dyspyosis on hardware we have access too.
Type | Hardware | Epochs | Time (s) |
---|---|---|---|
CPU | Intel i5-7500 @ 3.4Ghz | 100 | 185.0017 |
GPU | NVIDIA GeForce GTX 1060 6GB | 100 | 691.4091 |
For developers
To create the same environment the main devs are using, use requirements.txt to install the exact versions off all packages.
Clone the repository, create a virtual environment and install all requirements first. Additionally, ensure you have CUDA Toolkit 11.2 and the matching cuDNN (8.1.1) installed on your system (required for Tensorflow).
git clone https://github.com/raeslab/dyspyosis
cd dyspyosis
python -m venv venv
source venv/activate
pip install -r requirements.txt
To run tests, use the command below. There are a number of Deprecation Warnings (due to tensorflow) that can be
suppressed by --disable-warnings
.
pytest tests/ --disable-warnings --cov=dyspyosis --cov-report=term-missing --cov-report=xml
Contributing
Any contributions you make are greatly appreciated.
- Found a bug or have some suggestions? Open an issue.
- Pull requests are welcome! Though open an issue first to discuss which features/changes you wish to implement.
Contact and License
dyspyosis was developed by Sebastian Proost at the RaesLab (part of VIB and KULeuven). dyspyosis is available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.
For commercial access inquiries, please contact Jeroen Raes.
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 Distribution
Hashes for dyspyosis-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b569207ad5fa6eb58468b85d7545050f47ac8d170e8c318c82f354c1e60dced |
|
MD5 | 328f5c7859566604d3004609f846d3a4 |
|
BLAKE2b-256 | f7dadbc62fa6124d5cd9cdc82a48f37174cdba60c8df858431c35445d58436fe |