Breath analysis in python
Project description
BreathPy
Process breath samples of Multi-Capillary-Column Ion-Mobility-Spectrometry files
Now with experimental support for GC/MS + LC/MS data
Usage MCC/IMS
First prepare the example dataset by creating a subdirectory data and then linking the example files there.
from pathlib import Path
from urllib.request import urlretrieve
from zipfile import ZipFile
# download example zip-archive
url = 'https://github.com/philmaweb/BreathAnalysis.github.io/raw/master/data/small_candy_anon.zip'
zip_dst = Path("data/small_candy_anon.zip")
dst_dir = Path("data/small_candy_anon/")
dst_dir.mkdir(parents=True, exist_ok=True)
urlretrieve(url, zip_dst)
# unzip archive into data subdirectory
with ZipFile(zip_dst, "r") as archive_handle:
archive_handle.extractall(Path(dst_dir))
Then run the example analysis like so:
# import required functions
from breathpy.model.BreathCore import construct_default_parameters, construct_default_processing_evaluation_steps
from breathpy.model.CoreTest import test_start_to_end_pipeline
# define file prefix and default parameters
file_prefix = 'small_candy_anon'; folder_name = "small_candy_anon"
# assuming the data directory is in the current directory
plot_parameters, file_parameters = construct_default_parameters(file_prefix, folder_name, make_plots=True)
# create default parameters for preprocessing and evaluation
preprocessing_steps, evaluation_params_dict = construct_default_processing_evaluation_steps()
# call start
test_start_to_end_pipeline(plot_parameters, file_parameters, preprocessing_steps, evaluation_params_dict)
For more complete examples see model/CoreTest.py test_start_to_end_pipeline and test_resume_analysis.
The small_candy_anon example is included in the package under data/small_candy_anon/, more coming soon.
Usage GC/MS
Download and extract the example datasets into the current data subdirectory:
wget "https://github.com/bioinformatics-ca/bioinformatics-ca.github.io/raw/master/data_sets/Example_Jul0914_mzXML.zip"
wget "https://github.com/bioinformatics-ca/bioinformatics-ca.github.io/raw/master/data_sets/Example_Jul1114_mzXML.zip"
mkdir -p "data/eoe"
unzip Example_Jul1114_mzXML.zip -d data/eoe/
# overwrite the blank and alkstdt
unzip -o Example_Jul0914_mzXML.zip -d data/eoe/
# download class_labels.csv file
wget -O data/eoe/eoe_class_labels.csv "https://github.com/philmaweb/BreathAnalysis.github.io/raw/master/data/eoe_class_labels.csv"
from pathlib import Path
import os
from breathpy.model.BreathCore import construct_default_parameters,construct_default_processing_evaluation_steps
from breathpy.model.ProcessingMethods import GCMSPeakDetectionMethod, PerformanceMeasure
from breathpy.model.GCMSTest import run_gcms_platform_multicore
from breathpy.generate_sample_data import generate_train_test_set_helper
"""
Runs analysis of Eosinophilic Esophagitis (EoE) sample set with 40 samples - gcms measurements
Dataset from https://bioinformaticsdotca.github.io/metabolomics_2018_mod2lab
:param cross_val_num:
:return:
"""
cross_val_num=5
# or use your local path to a dataset here
source_dir = Path(os.getcwd())/"data/eoe"
target_dir = Path(os.getcwd())/"data/eoe_out"
# will delete previous split and rewrite data
train_df, test_df = generate_train_test_set_helper(source_dir, target_dir, cross_val_num=5)
train_dir = Path(target_dir)/"train_eoe"
# prepare analysis
set_name = "train_eoe"
make_plots = True
# generate parameters
# if executing from breathpy directory use execution_dir_level='project',
plot_parameters, file_parameters = construct_default_parameters(set_name, set_name, make_plots=make_plots,
execution_dir_level='project')
preprocessing_params_dict = {GCMSPeakDetectionMethod.ISOTOPEWAVELET: {"hr_data": True}}
_, evaluation_params_dict = construct_default_processing_evaluation_steps(cross_val_num)
run_gcms_platform_multicore(sample_dir=train_dir, preprocessing_params=preprocessing_params_dict, evaluation_parms=evaluation_params_dict)
Also see model/GCMSTest.py for reference.
License
BreathPy is licensed under GPLv3, but contains binaries for PEAX, which is a free software for academic use only.
See
Contact
If you run into difficulties using BreathPy, please open an issue at our GitHub repository. Alternatively you can write an email to Philipp Weber.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file breathpy-0.8.5-py3-none-any.whl.
File metadata
- Download URL: breathpy-0.8.5-py3-none-any.whl
- Upload date:
- Size: 9.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d91528032e909cc2bb78b30aa0652a6de36d4a7b277ed415aaada8dc84756bd5
|
|
| MD5 |
7a1da2fbcbda649865fd1026990a7d07
|
|
| BLAKE2b-256 |
986403896dc76e8265a572e0d29071e7221256f12c9ace890f9bc7d74a7c488b
|