{"id":24319451,"url":"https://github.com/baderlab/flashmm","last_synced_at":"2025-04-13T19:34:15.823Z","repository":{"id":266559982,"uuid":"896715272","full_name":"BaderLab/FLASHMM","owner":"BaderLab","description":"Fast and Scalable Single Cell Differential Expression Analysis using Mixed-effects Models","archived":false,"fork":false,"pushed_at":"2025-04-09T15:02:14.000Z","size":1171,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T15:47:24.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaderLab.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-01T05:25:19.000Z","updated_at":"2025-04-09T15:02:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"a3910681-e84c-44da-9792-e6f8e09016c6","html_url":"https://github.com/BaderLab/FLASHMM","commit_stats":null,"previous_names":["changjiangxu/flashmm","baderlab/flashmm"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaderLab%2FFLASHMM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaderLab%2FFLASHMM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaderLab%2FFLASHMM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaderLab%2FFLASHMM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaderLab","download_url":"https://codeload.github.com/BaderLab/FLASHMM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065299,"owners_count":21041871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-17T15:33:32.703Z","updated_at":"2025-04-13T19:34:15.817Z","avatar_url":"https://github.com/BaderLab.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# FLASH-MM\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nFLASH-MM is a method (package name: FLASHMM) for analysis of single-cell differential expression using a linear mixed- effects model (LMM). The mixed-effects model is a powerful tool in single-cell studies due to their ability to model intra-subject correlation and inter-subject variability.\n\nFLASHMM package provides two functions, lmm and lmmfit, for fitting LMM. The lmm function uses summary statistics as arguments. The lmmfit function is a wrapper function of lmm, which directly uses cell-level data and computes the summary statistics inside the function. The lmmfit function is simple to be operated but it has a limitation of memory use. For large scale data, it is recommended to precompute and store the summary statistics and then use lmm function to fit LMM.\n\nIn summary, FLASHMM package provides the following functions.\n\n* lmm: fit LMM using summary-level data.\n* lmmfit: fit LMM using cell-level data.\n* lmmtest: perform statistical tests on fixed effects and the contrasts of the fixed effects.\n* contrast.matrix: construct contrast matrix combining the fixed effects for various comparisons.\n* simuRNAseq: simulate multi-sample multi-cell-type scRNA-seq dataset based on a negative binomial distribution.\n\n## Installation\n\nYou can install FLASHMM package from CRAN:\n\n```{r echo = TRUE, results = \"hide\", message = FALSE}\ninstall.packages(\"FLASHMM\")\n```\n\nOr the development version from GitHub:\n\n```{r echo = TRUE, results = \"hide\", message = FALSE}\ndevtools::install_github(\"https://github.com/Baderlab/FLASHMM\")\n```\n\n## Example\n\nThis is a basic example which shows you how to use FLASHMM to perform single-cell differential expression analysis.\n\n```{r}\nlibrary(FLASHMM)\n```\n\n### Simulating a scRNA-seq dataset by simuRNAseq\n\nSimulate a multi-sample multi-cell-cluster scRNA-seq dataset that contains 25 samples and 4 clusters (cell-types) with 2 treatments.\n\n```{r dataset}\nset.seed(2412)\ndat \u003c- simuRNAseq(nGenes = 50, nCells = 1000, nsam = 25, ncls = 4, ntrt = 2, nDEgenes = 6)\nnames(dat)\n\n#counts and meta data\ncounts \u003c- dat$counts\nmetadata \u003c- dat$metadata\nhead(metadata)\nrm(dat)\n```\n\n### Differential expression analysis using LMM\n\n**1. Model design**\n\n* Y: gene expression profile (log-transformed counts)\n* X: design matrix for fixed effects\n* Z: design matrix for random effects\n\n```{r}\nY \u003c- log(counts + 1) \nX \u003c- model.matrix(~ 0 + log(libsize) + cls + cls:trt, data = metadata)\nZ \u003c- model.matrix(~ 0 + sam, data = metadata)\nd \u003c- ncol(Z)\n```\n\n**2. LMM fitting**\n\nOption 1: fit LMM by lmmfit function using cell-level data.\n\n```{r}\nfit \u003c- lmmfit(Y, X, Z, d = d)\n```\n\nOption 2: fit LMM by lmm function using summary-level data.\n\n```{r}\n#(1) Computing summary statistics\nn \u003c- nrow(X)\nXX \u003c- t(X)%*%X; XY \u003c- t(Y%*%X)\nZX \u003c- t(Z)%*%X; ZY \u003c- t(Y%*%Z); ZZ \u003c- t(Z)%*%Z\nYnorm \u003c- rowSums(Y*Y)\n\n#(2) Fitting LMM\nfitss \u003c- lmm(XX, XY, ZX, ZY, ZZ, Ynorm = Ynorm, n = n, d = d)\n\nidentical(fit, fitss)\n```\n\n**3. Hypothesis testing**\n\n```{r}\n##Testing coefficients (fixed effects)\ntest \u003c- lmmtest(fit)\n#head(test)\n\n##Note that the testing t-value and p-values are also provided in the LMM fit.\nrange(test - cbind(t(fit$coef), t(fit$t), t(fit$p)))\n#fit$coef[, 1:4]\n#fit$t[, 1:4]\nfit$p[, 1:4]\n##\n\n##Testing contrasts\n##We can make comparisons using contrasts. For example, \n##the effects of treatment B vs A in all clusters can be tested \n##using the contrast constructed as follows:\nct \u003c- numeric(ncol(X))\nindex \u003c- grep(\"B\", colnames(X))\nct[index] \u003c- 1/length(index)\n\ntest \u003c- lmmtest(fit, contrast = ct)\nhead(test)\n\nsessionInfo()\n```\n\n# Citation\n\nIf you find FLASH-MM useful for your publication, please cite:\n\nXu \u0026 Pouyabahar et al., FLASH-MM: Fast and Scalable Single-Cell Differential Expression Analysis Using Linear Mixed-Effects Models.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaderlab%2Fflashmm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaderlab%2Fflashmm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaderlab%2Fflashmm/lists"}