agentsclimarketplace

Linear model fitting for gene expression

Skill HolobiomicsLab/asb-skill-collections/collections/transcriptomics/v1/skills/linear-model-fitting-for-gene-expression

Use when you have a normalized gene expression matrix (genes × samples) and an experimental design with known treatment groups or conditions, and you need to estimate the effect of those conditions on expression levels while accounting for sample-to-sample variability.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill linear-model-fitting-for-gene-expression

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.0 KB, 913 tokens by cl100k_base, as published. Nobody here has run it

linear-model-fitting-for-gene-expression

Summary

Fit linear models to gene expression matrices using a design matrix encoding experimental groups or conditions, obtaining coefficient estimates and residual standard errors for downstream differential expression analysis. This skill applies to microarray, RNA-seq, qPCR, and proteomics data.

When to use

You have a normalized gene expression matrix (genes × samples) and an experimental design with known treatment groups or conditions, and you need to estimate the effect of those conditions on expression levels while accounting for sample-to-sample variability. Apply this skill before computing moderated t-statistics or contrasts.

When NOT to use

  • Expression data are not yet normalized; apply normalization and background correction before lmFit.
  • Design is unbalanced or confounded in ways that violate linear model assumptions; consider model diagnostics first.
  • You have already computed per-gene statistics (e.g., from a separate pipeline); lmFit is redundant.

Inputs

  • gene expression matrix (genes × samples; numeric)
  • design matrix (samples × covariates; numeric, typically with intercept)
  • phenotype metadata or experimental group assignments

Outputs

  • MArrayLM object containing fitted coefficients, standard errors, residual degrees of freedom, and design matrix
  • coefficient estimates (log-fold-change or effect sizes) for each gene and design column

How to apply

Construct a design matrix that encodes the experimental groups or conditions of interest as columns (typically with an intercept column). Pass the expression matrix and design matrix to limma's lmFit function, which fits ordinary least squares regression for each gene independently. The function returns an MArrayLM object containing coefficient estimates, standard errors, and residual degrees of freedom for each gene. Verify that all contrast coefficients and standard errors have been computed by inspecting the returned object's structure before proceeding to empirical Bayes moderation (eBayes) or contrast-based analysis.

Related tools

  • limma (Core R package providing lmFit function for linear model fitting to gene expression matrices; also provides downstream empirical Bayes moderation (eBayes) and contrast analysis) — https://github.com/bioc/limma
  • R (Programming environment in which limma and design matrix construction are executed)

Examples

design <- model.matrix(~0 + factor(c('ctrl', 'ctrl', 'treat', 'treat'))); fit <- lmFit(expr_matrix, design)

Evaluation signals

  • MArrayLM object is returned with non-empty coefficients slot matching the number of design columns
  • Residual standard error estimates are positive and finite for all genes
  • Residual degrees of freedom equal (number of samples) − (number of design columns)
  • Coefficients and standard errors show expected magnitude and sign relative to experimental design (e.g., treated samples have non-zero coefficients for treatment column)
  • No NaN or Inf values in coefficients, standard errors, or degrees of freedom (indicates no rank-deficient or singular design)

Limitations

  • Linear model assumes that residuals are normally distributed and homoscedastic across samples; violations may inflate or deflate standard errors.
  • When the number of arrays is small, empirical Bayes moderation (eBayes) is required to stabilize variance estimates; raw lmFit output alone is unstable.
  • Design matrix must have full column rank; perfect collinearity or confounding of factors will produce singular matrices and NA coefficients.
  • lmFit applies ordinary least squares; for small sample sizes or very sparse data, penalized or robust methods may be preferable.

Evidence

  • [other] lmFit produces MArrayLM object with coefficient estimates and residual standard errors: "Apply limma's lmFit function to fit a linear model to the expression matrix using the design matrix, obtaining coefficient estimates and residual standard errors."
  • [other] limma applies to microarray, RNA-seq, qPCR, and proteomics: "The linear model and differential expression functions apply to a wide variety of gene expression technologies including microarrays (single-channel or two-color), quantitative PCR, RNA-seq or"
  • [other] Linear models are used for analyzing designed experiments and assessing differential expression: "Limma is an R package for the analysis of gene expression data, especially the use of linear models for analysing designed experiments"
  • [other] Empirical Bayes methods stabilize results when sample size is small: "Empirical Bayesian methods are used to provide stable results even when the number of arrays is small."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.