Readable NumPy/SciPy implementation of the MaxLFQ workflow
Project description
maxLFQ
A importable NumPy/SciPy implementation of the notebook-derived MaxLFQ workflow for MaxQuant peptide tables. The package extracts the computational workflow from maxLFQmo.py. The notebook works as an interactive teaching and visualization wasm interface, while this module provides a reusable, testable API and command-line interface.
The package performs:
- peptide-species construction from sequence, modification, and charge;
- optional decoy, contaminant, and uniqueness filtering;
- delayed sample normalization;
- protein-wise pairwise peptide log-ratios;
- least-squares protein-profile reconstruction;
- rescaling to observed peptide intensity anchors.
This is an independent Python implementation intended for transparent analysis and teaching. It is not an official MaxLFQ implementation.
Installation
python -m pip install maxlfq
Small reproducible example
import pandas as pd
from maxlfq import maxlfq
peptides = pd.DataFrame(
{
"Leading razor protein": ["P1", "P1", "P2", "P2"],
"Sequence": ["AAA", "BBB", "CCC", "DDD"],
"Modifications": ["Unmodified"] * 4,
"Charge": [2, 2, 3, 2],
"Intensity A": [100, 200, 50, 150],
"Intensity B": [200, 400, 100, 300],
"Intensity C": [50, 100, 25, 75],
}
)
result = maxlfq(peptides)
print(result.normalization_factors)
print(result.lfq)
Expected normalization factors:
A 0.50
B 0.25
C 1.00
Expected LFQ values:
LFQ intensity A LFQ intensity B LFQ intensity C
Protein
P1 150.0 150.0 150.0
P2 100.0 100.0 100.0
For local development:
python -m pip install -e .
#check
python -c "import pandas as pd; from maxlfq import maxlfq; x=pd.DataFrame({'Leading razor protein':['P1','P1','P2','P2'],'Sequence':['AAA','BBB','CCC','DDD'],'Modifications':['Unmodified']*4,'Charge':[2,2,3,2],'Intensity A':[100,200,50,150],'Intensity B':[200,400,100,300],'Intensity C':[50,100,25,75]}); r=maxlfq(x); print(r.normalization_factors); print(r.lfq)"
A 0.50
B 0.25
C 1.00
Name: normalization_factor, dtype: float64
LFQ intensity A LFQ intensity B LFQ intensity C
Protein
P1 150.0 150.0 150.0
P2 100.0 100.0 100.0
Python API
from maxlfq import maxlfq_from_file
result = maxlfq_from_file(
"peptides.txt",
ratio_method="median",
rescale_method="sum",
minimum_ratio_count=1,
normalization_anchor="All Samples Maximum",
filter_decoy=True,
filter_contaminant=True,
)
result.lfq.to_csv("protein_lfq.tsv", sep="\t")
result.normalization_factors.to_csv("normalization_factors.tsv", sep="\t")
result.pairwise_ratios.to_csv("pairwise_ratios.tsv", sep="\t", index=False)
The main result object contains:
lfq: reconstructed protein LFQ matrix;raw_intensity: protein-wise sums before delayed normalization;normalization_factors: fitted sample factors;normalized_species: normalized peptide-species matrix;pairwise_ratios: protein/sample-pair ratio trace;zero_intensity_proteins: proteins excluded because all intensities were zero or missing;h_beforeandh_after: delayed-normalization objectives.
Command line
maxlfq peptides.txt protein_lfq.tsv \
--filter-decoy \
--filter-contaminant \
--normalization-factors-output normalization_factors.tsv \
--pairwise-ratios-output pairwise_ratios.tsv
The same command can be run without the installed entry point:
python -m maxlfq peptides.txt protein_lfq.tsv
Input expectations
By default, the package detects common MaxQuant columns:
Protein: Leading razor protein, Razor protein, Proteins, or Protein IDs
Sequence: Sequence, Peptide sequence, or Peptide
Modification: first column starting with Mod
Charge: Charge, Charges, or z
Intensity: columns starting with "Intensity "
Zero intensities are interpreted as missing. Nonnumeric and infinite intensity values are converted to missing values.
A peptide species is defined as:
UPPERCASE_SEQUENCE + modification + charge
For repeated rows with the same protein/species identifier, the first observed intensity row is retained, matching the original notebook.
Main parameters
result = maxlfq_from_file(
"peptides.txt",
delayed_normalize=True,
normalization_anchor="All Samples Maximum",
profile_anchor=None,
ratio_method="median",
rescale_method="sum",
minimum_ratio_count=1,
filter_decoy=False,
filter_contaminant=False,
filter_unique_groups=False,
filter_unique_proteins=False,
include_zero_intensity=False,
)
profile_anchor=None means that profile reconstruction uses the delayed-normalization anchor.
Delayed normalization
For peptide species p and samples i and j, sample factors are fitted by minimizing:
sum [log(N_i X_p,i) - log(N_j X_p,j)]^2
The factors are identifiable only up to one common multiplier. The selected anchor sets that common scale.
Pairwise ratios
For each protein and sample pair, the package computes the median or mean log2 ratio across shared peptide species:
r_ij = median_p[log2(I_p,i) - log2(I_p,j)]
Pairs with fewer than minimum_ratio_count shared species are omitted.
Profile reconstruction
Protein-level relative profiles are reconstructed by least squares from:
log2(I_i) - log2(I_j) = r_ij
The relative profile is then rescaled using either summed or maximum observed normalized peptide-species intensity.
Validation status
The package was checked for:
- source compilation;
- species-matrix construction;
- zero-intensity protein restoration;
- delayed-normalization factors on a known scaling example;
- reduction of the normalization objective;
- pairwise median-ratio construction;
- protein-profile reconstruction;
- API and command-line execution;
- clean wheel contents and installation.
Reference
Cox J, Hein MY, Luber CA, Paron I, Nagaraj N, Mann M. Accurate proteome-wide label-free quantification by delayed normalization and maximal peptide ratio extraction, termed MaxLFQ. Molecular & Cellular Proteomics. 2014;13(9):2513-2526.
Citation and attribution
The original MaxLFQ publication above, the repo and document the Python package version used. This project is an independent Python implementation and is not the Bioconductor vsn package.
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 maxlfq-0.1.0.tar.gz.
File metadata
- Download URL: maxlfq-0.1.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a9676711b7e4784be22c272b3e58121714add451d1c5e4f575c1c651d41c497
|
|
| MD5 |
ca92488cfc080c57f0aa69eb9da8940e
|
|
| BLAKE2b-256 |
d177db3adbc7b2e2f81739015e6094dae0f6b42d974c4a45205aefad35e1906c
|
File details
Details for the file maxlfq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: maxlfq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ebc970cae08acfa3c82a4ea5a02d742ff408a30617ec88567560141e850c646
|
|
| MD5 |
30f258b7c14344cb4256bece642964e0
|
|
| BLAKE2b-256 |
3b7591e042f0e46e7bb2f147521376da91556035452501cd120f49bb2828466b
|