Skip to main content

MLMarker

MLMarker is a Python package for tissue-specific proteomics prediction using machine learning, with integrated SHAP-based explainability features.

Key Features

  • Dual Model Support: Binary and quantitative tissue prediction models
  • SHAP-Based Predictions: Uses SHAP values for more interpretable predictions
  • Feature Penalty System: Adjustable penalty for absent features using penalty_factor
  • Visualization Tools: Force plots, radar charts, and custom visualizations
  • Protein Analysis: Integrated tools for NSAF calculation and protein information retrieval
  • Data Validation: Automatic handling of missing features

Installation

pip install mlmarker

Quick Start

import pandas as pd
from mlmarker import MLMarker

# Load your data
df = pd.read_csv("your_sample.csv")

# Initialize model (binary=False for quantitative model)
model = MLMarker(binary=False, penalty_factor=1)

# Load and validate your sample
model.load_sample(df)

# Get predictions
predictions = model.predict_top_tissues_shap(n_preds=5)

Core Features

1. Model Initialization

# Binary model
binary_model = MLMarker(binary=True)

# Quantitative model with penalty for absent features
quant_model = MLMarker(binary=False, penalty_factor=1)

2. SHAP-Based Predictions

# Get predictions with SHAP explanations
predictions = model.predict_top_tissues_shap(n_preds=5)

# Visualize SHAP force plot
model.shap_force_plot(n_preds=3)

# Generate radar chart of predictions
model.radar_chart()

3. SHAP Value Analysis

# Get raw SHAP values
shap_values = model.explainability.calculate_shap()

# Get processed SHAP values with optional penalty
shap_df = model.explainability.get_shap_values(n_preds=5)

4. Feature Handling

# Get model features
features = model.get_model_features()

# Load sample with feature validation
added_features = model.load_sample(df, output_added_features=True)

5. NSAF Calculations

# Calculate NSAF scores for proteins
nsaf_df = model.explainability.calculate_NSAF(protein_df, lengths_df)

Advanced Usage

Penalty Factor

The penalty_factor parameter controls how absent features influence predictions:

  • 0: No penalty (default)
  • 1: Full penalty for absent features
  • Values between 0-1: Partial penalty
# Model with full penalty for absent features
model = MLMarker(penalty_factor=1)

Custom SHAP Visualization

# Visualize specific tissue
model.shap_force_plot(tissue_name="Liver")

# Visualize top N predictions
model.shap_force_plot(n_preds=3)

Additional Utilities

from mlmarker.utils import (
    get_protein_info,
    get_hpa_info,
    get_go_enrichment,
    visualise_custom_plot
)

# Get protein information
protein_info = get_protein_info("P12345")

# Get Human Protein Atlas information
hpa_info = get_hpa_info("P12345")

# Perform GO enrichment analysis
enrichment = get_go_enrichment(protein_list)

Requirements

  • Python ≥ 3.8
  • numpy==1.23.5
  • pandas
  • scikit-learn
  • shap==0.42.0
  • plotly
  • bioservices
  • gprofiler-official

Release files for mlmarker 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlmarker 0.1.6
File Size Uploaded
mlmarker-0.1.6.tar.gz 12.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mlmarker 0.1.6
File Interpreter ABI Platform
mlmarker-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 25.9 MB

Release files / mlmarker-0.1.6.tar.gz

Download URL mlmarker-0.1.6.tar.gz
Size 12.8 MB
Tags Source
SHA-256 checksum
How to use checksums
d1b7f0df5836ce9953c1e850e2f82bcefd67173938a63eeb7b8c16cd9c0397b7
BLAKE2b-256 checksum
How to use checksums
b7feb581fe5bcb4532ac8a8d30748a239d2fb2181d0356044acc0380686c7628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.9.23 Linux/6.12.38+deb13-amd64

Release files / mlmarker-0.1.6-py3-none-any.whl

Download URL mlmarker-0.1.6-py3-none-any.whl
Size 13.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
8f009ab08744c844dc6e6d70e7d8770bfa6878818bafe3cc728ad3d531e4f5e7
BLAKE2b-256 checksum
How to use checksums
65b56a58a16e03e7f9fc8fc57a69a67354900c70b6ad3d237e622cdf3bc13bed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.9.23 Linux/6.12.38+deb13-amd64

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page