A Python Ramanome Analysis Toolkit for ML/DL-friendly analysis
Project description
PyRamEx
A Python Ramanome Analysis Toolkit for Machine Learning and Deep Learning
๐ฏ Overview
PyRamEx is a Python reimplementation of RamEx (R package), specifically optimized for machine learning and deep learning workflows. It provides comprehensive tools for Raman spectroscopic data analysis with seamless integration with modern ML/DL frameworks.
Key Features
โ
ML/DL-Native Design - NumPy/Pandas data structures, Scikit-learn/PyTorch/TensorFlow integration
โ
Method Chaining - Fluent API for preprocessing pipelines
โ
Modern Python - Type hints, async support, comprehensive testing
โ
GPU Acceleration - Optional CUDA support (replaces OpenCL)
โ
Interactive Visualization - Plotly/Matplotlib support
โ
Jupyter Friendly - Designed for notebook-based exploration
๐ Quick Start
Installation
# Basic installation
pip install pyramex
# With ML/DL dependencies
pip install pyramex[ml]
# With GPU support
pip install pyramex[gpu]
Basic Usage
from pyramex import Ramanome, load_spectra
# Load data
data = load_spectra('path/to/spectra/')
# Preprocess with method chaining
data = data.smooth(window_size=5) \
.remove_baseline(method='polyfit') \
.normalize(method='minmax')
# Quality control
qc = data.quality_control(method='icod', threshold=0.05)
data_clean = data[qc.good_samples]
# Dimensionality reduction
data_clean.reduce(method='pca', n_components=2)
data_clean.plot_reduction(method='pca')
# Machine Learning integration
from sklearn.ensemble import RandomForestClassifier
X_train, X_test, y_train, y_test = data_clean.to_sklearn_format()
model = RandomForestClassifier()
model.fit(X_train, y_train)
print(f"Accuracy: {model.score(X_test, y_test):.2%}")
๐ Documentation
- Installation Guide: docs/installation.md
- Quick Start Tutorial: docs/tutorial.md
- API Reference: docs/api.md
- User Guide: docs/user_guide.md
- Developer Guide: docs/developer_guide.md
๐ Comparison with RamEx (R)
| Feature | RamEx (R) | PyRamEx (Python) |
|---|---|---|
| Language | R | Python 3.8+ |
| ML Integration | Limited | Native (sklearn, PyTorch, TF) |
| GPU Support | OpenCL | CUDA (optional) |
| Data Format | S4 objects | NumPy/Pandas |
| Visualization | ggplot2 | Plotly/Matplotlib |
| Interactivity | Shiny | Jupyter + Streamlit |
| API Style | R functions | Python method chaining |
๐ Project Structure
pyramex/
โโโ pyramex/
โ โโโ __init__.py # Package entry point
โ โโโ core/ # Core data structures
โ โโโ io/ # Data loading
โ โโโ preprocessing/ # Spectral preprocessing
โ โโโ qc/ # Quality control
โ โโโ features/ # Feature engineering
โ โโโ ml/ # ML/DL integration
โ โโโ visualization/ # Plotting tools
โโโ tests/ # Unit tests
โโโ examples/ # Jupyter notebooks
โโโ docs/ # Documentation
โโโ setup.py # Package configuration
โโโ requirements.txt # Dependencies
โโโ LICENSE # MIT License
โโโ README.md # This file
โโโ .github/workflows/ # CI/CD
๐ฌ Features
Data Loading
- Support for multiple Raman file formats
- Automatic format detection
- Batch loading from directories
Preprocessing
- Smoothing (Savitzky-Golay)
- Baseline removal (polyfit, ALS, airPLS)
- Normalization (minmax, zscore, area, max, vecnorm)
- Spectral cutoff and derivatives
Quality Control
- ICOD (Inverse Covariance-based Outlier Detection)
- MCD (Minimum Covariance Determinant)
- T2 (Hotelling's T-squared)
- SNR (Signal-to-Noise Ratio)
- Dis (Distance-based)
Dimensionality Reduction
- PCA (Principal Component Analysis)
- UMAP (Uniform Manifold Approximation and Projection)
- t-SNE (t-Distributed Stochastic Neighbor Embedding)
- PCoA (Principal Coordinate Analysis)
Machine Learning Integration
- Scikit-learn format conversion
- PyTorch Dataset creation
- TensorFlow Dataset creation
- Pre-defined model architectures (CNN, MLP)
Visualization
- Static plots (Matplotlib)
- Interactive plots (Plotly)
- Spectral plots, reduction plots, QC plots
๐ Example: Complete Workflow
from pyramex import Ramanome, load_spectra
from sklearn.ensemble import RandomForestClassifier
# 1. Load data
data = load_spectra('data/spectra/')
# 2. Preprocess
data = data.smooth() \
.remove_baseline() \
.normalize()
# 3. Quality control
qc = data.quality_control(method='icod')
data = data[qc.good_samples]
# 4. Dimensionality reduction
data.reduce(method='pca', n_components=50)
# 5. Train ML model
X_train, X_test, y_train, y_test = data.to_sklearn_format()
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
# 6. Evaluate
accuracy = model.score(X_test, y_test)
print(f"Test Accuracy: {accuracy:.2%}")
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
git clone https://github.com/openclaw/pyramex.git
cd pyramex
# Install development dependencies
pip install -e .[dev]
# Run tests
pytest
# Run linting
black pyramex/
flake8 pyramex/
mypy pyramex/
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Note: PyRamEx is derived from RamEx (R package), which is licensed under GPL. The original RamEx license and attribution are preserved in the NOTICE file.
๐ Acknowledgments
- Original RamEx team
- RamEx Paper: https://doi.org/10.1101/2025.03.10.642505
- Zhang Y., Jing G., et al. for the excellent work on RamEx
๐ Contact
- Project Homepage: https://github.com/openclaw/pyramex
- Issues: https://github.com/openclaw/pyramex/issues
- Discussions: https://github.com/openclaw/pyramex/discussions
๐ Roadmap
v0.1.0-alpha (Current)
- โ Core functionality
- โ Basic preprocessing
- โ Quality control
- โ ML/DL integration
v0.2.0-beta (Planned: March 2026)
- Complete unit tests
- Example datasets
- Streamlit web app
- GPU acceleration
v0.3.0-rc (Planned: April 2026)
- Marker analysis
- IRCA analysis
- Phenotype analysis
- Spectral decomposition
v1.0.0-stable (Planned: June 2026)
- Complete feature set
- Pre-trained models
- Plugin system
- Academic paper
Developer: ๅฐ้พ่พ1ๅท ๐ฆ
Status: ๐ข Active Development
Made with โค๏ธ for the Raman spectroscopy community
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
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 pyramex-0.1.0.tar.gz.
File metadata
- Download URL: pyramex-0.1.0.tar.gz
- Upload date:
- Size: 51.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec7a0c3182c0d6137802bc84e11f5d903e1f84c71fbf462a441d85f68c22f0b1
|
|
| MD5 |
31ba3edfe0c143ad3d68571bf4042aed
|
|
| BLAKE2b-256 |
09fedf8becef6f1c494ece4753216766dd75ed571b52f9034f8979924077053d
|
File details
Details for the file pyramex-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyramex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a1a81860d02c031f00e3f3ee77b060a3006cc20aed78ae6f9fc1b790f3b0917
|
|
| MD5 |
adfc8e59816099df441d7221c1df3e23
|
|
| BLAKE2b-256 |
bd88681166eb1b834edbf7d1af4da7b6b51cc2b0d3901e28781710cd8fa6070e
|