Python implementation of R's limma package for differential expression analysis
Project description
limma_py
A Python implementation of the popular R limma package for differential expression analysis of gene expression data.
Overview
limma_py is a comprehensive Python port of the widely-used R limma (Linear Models for Microarray Data) package. It provides powerful statistical methods for analyzing gene expression data from microarray and RNA-seq experiments, with a focus on differential expression analysis.
Key Features
- ✅ Complete Functionality - Provides the same core functionality as R's limma package
- ✅ Linear Model Fitting - Supports complex experimental design matrices
- ✅ Empirical Bayes Moderation - Improves statistical power for small sample data
- ✅ Multiple Group Comparisons - Supports complex contrast analysis
- ✅ Pythonic API - User-friendly interface designed for Python users
- ✅ High Performance Computing - Optimized implementation based on NumPy and SciPy
Installation
Via pip
pip install limma_py
From source
git clone https://github.com/wd1566/limma_py
cd limma_py
pip install -e .
Quick Start
import pandas as pd
import numpy as np
import limma_py
# Read CSV file, header=0 indicates the first row contains column names
data = pd.read_csv("data/Harmine_iTSA.csv", header=0)
# Extract gene names (first column)
gene_names = data.iloc[:, 0].values
# Extract expression matrix (all columns starting from the second)
expr_data = data.iloc[:, 1:]
# Define experimental groups: first 5 samples are control group (V_group), last 5 are treatment group (D_group)
group = np.array(["V_group"] * 5 + ["D_group"] * 5)
# Create design matrix using one-hot encoding
design_df = pd.get_dummies(group, drop_first=False)[["V_group", "D_group"]]
# Ensure design matrix is of integer type
design = design_df.astype(int)
# Create a copy of the expression matrix and set gene names as row indices
expr_matrix = expr_data.copy()
expr_matrix.index = gene_names
# Perform linear model fitting using limma
fit_python = limma_py.lmFit(expr_matrix, design)
# Set up contrast matrix: compare differences between treatment group (D_group) and control group (V_group)
contrasts = limma_py.make_contrasts('D_group - V_group', levels=design)
# Perform contrast analysis on the fitted results
fit_python = limma_py.contrasts_fit(fit_python, contrasts)
# Moderate standard errors using empirical Bayes method
eb_python = limma_py.eBayes(fit_python)
# Extract differential expression analysis result table
res = limma_py.toptable(eb_python)
Data Format Requirements
Input data should be in CSV format with the following structure:
Gene,Sample1,Sample2,Sample3,Sample4,Sample5,Sample6,Sample7,Sample8,Sample9,Sample10
Gene_1,8.45,7.89,8.12,15.67,14.89,16.23,8.33,7.95,8.21,8.09
Gene_2,12.34,11.89,12.56,11.45,10.98,12.11,25.67,24.89,26.01,25.34
Gene_3,5.67,6.01,5.89,18.90,19.45,18.23,6.12,5.78,6.34,5.95
Format specifications:
-
First column: Gene/protein names (any identifier)
-
Subsequent columns: Numerical expression matrix, each column represents a sample
-
Must be in CSV format, other formats need to be converted first
Core Functions
lmFit()- Linear model fitting for gene expression datamake_contrasts()- Generate contrast matrices for group comparisonscontrasts_fit()- Extract results for specified contrastseBayes()- Empirical Bayes moderation of standard errorstoptable()- Extract top-ranked genes from analysis results
Documentation
For detailed documentation, examples, and API reference, visit our documentation site.
Use Cases
- Microarray Data Analysis
- RNA-seq Differential Expression Analysis
- Multiple Group Experimental Designs
- Time Series Expression Data
- Any expression data analysis requiring linear modeling
Dependencies
- pandas >= 1.0.0
- numpy >= 1.18.0
- scipy >= 1.4.0
- statsmodels >= 0.11.0
Contributing
Contributions are welcome! Please feel free to submit pull requests, report bugs, or suggest new features.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 limma_py-0.1.0.tar.gz.
File metadata
- Download URL: limma_py-0.1.0.tar.gz
- Upload date:
- Size: 33.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7565eb5ea1248b690f3ebf1e04a00941e58c8c67fb0dbc8d4bf9c8a4eb17d340
|
|
| MD5 |
1a11be9e6507abc2cf0a6fffae784cb8
|
|
| BLAKE2b-256 |
ba3cecc1ad221153b20ed6c87dfbcbc82a983b66153092fbcc10c02f29aa6b36
|
File details
Details for the file limma_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: limma_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b4814f87300600797a77d13963042332a9f25aefdaa77a0b57d8f00328b98de
|
|
| MD5 |
eef15393674ea95f2133f03cc8b86255
|
|
| BLAKE2b-256 |
04d6cd1ef993fe23487afbdbbca30c14c6ccbd011dc268601e088f3c3c444eaa
|