Milo is a method for differential abundance analysis on KNN graph from single-cell datasets. For more details, read our manuscript. If you use Milo in your study, please cite Dann, E., Henderson, N.C., Teichmann, S.A. et al. Differential abundance testing on single-cell data using k-nearest neighbor graphs. Nat Biotechnol (2021).

Build Status Coverage R-CMD-check


## Milo is available from Bioconductor (preferred stable installation)
if (!requireNamespace("BiocManager", quietly = TRUE))


## Install development version
devtools::install_github("MarioniLab/miloR", ref="devel") 


  1. Basic Milo example on simulated dataset
  2. Milo example on mouse gastrulation dataset: this includes a demo for downstream analysis functions.
  3. Integrating miloR in scanpy/anndata workflow (see also milopy for a full workflow in python)
  4. Specifying contrasts of interest for differential abundance testing with Milo
  5. Using a mixed effect model for dependendent samples

Example work flow

An example of the Milo work flow to get started:

milo.meta <- sim_trajectory$meta
milo.obj <- Milo(sim_trajectory$SCE)

Build a graph and neighbourhoods.

milo.obj <- buildGraph(milo.obj, k=20, d=30)
milo.obj <- makeNhoods(milo.obj, k=20, d=30, refined=TRUE, prop=0.2)

Calculate distances, count cells according to an experimental design and perform DA testing.

milo.obj <- calcNhoodDistance(milo.obj, d=30)
milo.obj <- countCells(milo.obj, samples="Sample", <- Condition + Sample, data=milo.meta)) <-[$Freq > 0, ]
rownames( <-$Sample <-[colnames(nhoodCounts(milo.obj)),]

milo.res <- testNhoods(milo.obj, design=~Condition,


For any question, feature request or bug report please create a new issue in this repository. If you have an error or code-based query, please provide the executed code and the preceding code from the point of constructing the Milo object, along with the output of your sessionInfo() - this will help us immeasurably to diagnose the issue.


We welcome contributions and suggestions from the community (though we may not take them onboard if they don't align with our development roadmap - please don't be offended). Please submit the initial idea as an issue, which we will discuss and ask for refinements/clarifications. If we approve the idea, then please open a pull request onto the devel branch, from which we will begin a review process. To smooth the process, please note that code changes must be backwards compatible, and must include all relevant unit tests.

MikeDMorgan/miloR documentation built on Nov. 20, 2023, 4:07 p.m.