Detect Runs of Homozygosity and Runs of Heterozygosity in Diploid Genomes

Detection of runs of homozygosity and of heterozygosity in diploid genomes using two methods: sliding windows (Purcell et al (2007) ) and consecutive runs (Marras et al (2015) ).

detectRUNS is a R package for the detection of runs of homozygosity (ROH/ROHom) and of heterozygosity (ROHet, a.k.a. "heterozygosity-rich regions") in diploid genomes. Besides runs detection, it implements several functions to summarize and plot results.


detectRUNS is installed as a standard R package. Some core functions are written in C++ to increase efficieny of calculations: this makes use of the R library Rcpp. detectRUNS uses other R packages for data manipulation and plots. These packages are set as Imports, and detectRUNS will try to install any missing packages upon installation.


detectRUNS imports: plyr, iterators, itertools, ggplot2, reshape2, Rcpp, gridExtra, data.table detectRUNS suggests: testthat, knitr, rmarkdown, prettydoc


Please see the package vignette for a complete tutorial. What follows is a minimal working example to give the gist of the tool.


This is a basic example which shows you how to detect runs of homozygosity (ROH):

genotypeFile <- system.file("extdata", "Kijas2016_Sheep_subset.ped", package = "detectRUNS")
mapFile <- system.file("extdata", "", package = "detectRUNS")
# calculating runs with sliding window approach
 # skipping runs calculation
 runs <-, mapFile, windowSize = 15, threshold = 0.1,
 minSNP = 15, ROHet = FALSE,  maxOppWindow = 1, maxMissWindow = 1, maxGap=10^6,
 minLengthBps = 100000,  minDensity = 1/10000)
# loading pre-calculated data
runsFile <- system.file("extdata", "Kijas2016_Sheep_subset.sliding.csv", package="detectRUNS")
colClasses <- c(rep("character", 3), rep("numeric", 4)  )
runs <- read.csv2(runsFile, header = TRUE, stringsAsFactors = FALSE,  colClasses = colClasses)
#2) summarise results
summaryList <- summaryRuns(runs = runs, mapFile = mapFilePath, genotypeFile = genotypeFilePath, Class = 6, snpInRuns = TRUE)
#3) plot results
plot_Runs(runs = runs)


detectRUNS 0.9.3

Major changes

  • First submission to CRAN

Bug fixes

  • No bugs identified at the moment

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.9.6 by Filippo Biscarini, 2 years ago

Report a bug at

Browse source code at

Authors: Filippo Biscarini [aut, cre] , Paolo Cozzi [aut] , Giustino Gaspa [aut] , Gabriele Marras [aut]

Documentation:   PDF Manual  

GPL-3 license

Imports plyr, iterators, itertools, ggplot2, reshape2, Rcpp, gridExtra, data.table

Suggests testthat, knitr, rmarkdown, prettydoc

Linking to Rcpp

See at CRAN