email: johntlovell@gmail.com -- website: lovelleeb.weebly.com -- github: github.com/jtlovell/qtlTools
library(knitr) library(xtable) knitr::opts_chunk$set(echo = TRUE)
\newpage
For the purposes of this tutorial, we will use paramters that mimick some types of NGS data:
library(devtools) install_github("jtlovell/qtlTools") install_github("mckaylab/TSPmap")
libs2load<-c("ASMap","qtlTools","TSP","TSPmap") suppressMessages(sapply(libs2load, require, character.only = TRUE))
set.seed(42) map <- sim.map(len=c(150,200,100), n.mar=c(50,50,50), include.x =FALSE, sex.sp =F) plot.map(map) map.orig<-map
cross.sim <- sim.cross(map, type="riself", n.ind=250, map.function = "kosambi", error.prob = 0.001, keep.qtlgeno = F,missing.prob=0.1) cross<-cross.sim
newMarkerList<-lapply(chrnames(cross), function(x) sample(markernames(cross, chr = x))) names(newMarkerList)<-chrnames(cross) # randomize the positions of markers cross<-newLG(cross, markerList = newMarkerList)
To order markers, we must calculate chromosome - specific recombination fractions. For very large genetic maps (>5k markers for a RIL, >3k markers for a 4-way), we should not attempt to do this for the entire map. Instead, we can do it chromosome-by-chromosome.
For the purposes of this tutorial, let's calculate it for the whole population. Notice that
cross<-est.rf(cross) plot.rf(cross)
There are many methods to order markers. While joinmap4 remains the industry standard, it has drawbacks - it's slow and is not free. Recently several other methods have been proposed using graph theory. MSTmap is a good option, but it can only handle populations with 2-genotype markers (BC/RIL/DH/etc), not F2, 4-way etc. mapping populations. To overcome these issues, it is optimal to assess marker orders through evaluation of the recombination fraction matrix only.
Here, we build upon the TSPmap
protocol and employ a travelling salesperson problem solver to find the shortest path through the recombination fraction matrix, and allow the user to directly pipe an R/qtl cross object into the TSPmap protocol. The optimal method is concorde
, however, this requires a separate installation of the concorde program. See ?tspOrder
for details on how to do this.
cross.order<-tspOrder(cross = cross,hamiltonian = TRUE, method="concorde",concorde_path = "/Users/John/Documents/concorde/TSP")
cross.order<-est.rf(cross.order) plot.rf(cross.order, main = "")
cross.sim<-est.rf(cross.sim) plot.rf(cross.sim, main = "")
newmap<-est.map(cross.order, map.function = "kosambi", error.prob = 0.001) cross.out<-replace.map(cross.order, newmap)
Note that the marker order is identical between the two crosses
plot.map(cross.sim, cross.out)
TSPmap runs agnostic to the orientation of the chromosomes. Since we started with simulated data, it is appropriate to re-orient the chromosomes to match these
map.sim<-pullMap(cross.sim) colnames(map.sim)[2:3]<-c("orig.chr","orig.pos") map.out<-pullMap(cross.out) map<-merge(map.out, map.sim, by = "marker.name") map<-map[match(map.out$marker.name, map$marker.name),] cross.out<-matchMarkerOrder(cross.out, marker.chr.bp = map$orig.chr, marker.pos.bp = map$orig.pos)
plot.map(cross.sim, cross.out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.