knitr::opts_chunk$set(collapse=TRUE,comment="#>")
The LinkageMapView package produces linkage group maps and QTL maps from a variety of inputs. The output is a portable document format (PDF) and publication ready.
There are many options for customizing the maps which will be reviewed in this vignette.
The first argument, mapthis, can be one of the following:
A data frame example:
library(LinkageMapView) data(carrot) head(carrot)
A cross object from the qtl package example:
library(qtl) data(hyper) class(hyper) summary(hyper)
The mapthese parameter is a vector of linkage groups from the input that you wish to print. The default prints all linkage groups in the input. You can print linkage groups in any order and you can print linkage groups more than once.
The following PDF options can be specified and will be passed through to the PDF device.
Note that pdf.width and pdf.height will be calculated automatically if they are not specified.
Continuing with the hyper cross object loaded above from the qtl package:
outfile = file.path(tempdir(), "hyper.pdf") lmv.linkage.plot(hyper,outfile,mapthese=c(1,4,6,15))
knitr::include_graphics("hyper.png")
If more than one locus name appears at the same position, the label is indented slightly to catch your eye. The parameter maxcolsfordups determines how many loci names will print on one line before going to subsequent lines. The default is 3. When multiple lines are required for all the labels at the same position, the labels are joined by a vertical line.
The roundpos parameter, which defaults to 1, specifies how many positions after the decimal point should be printed for the locus position.
Another parameter for handling multiple loci at the same position, is dupnbr. If TRUE, only the first locus name at a position will print with, "## more" afterwards, indicating the number of duplicate locus names at that position:
outfile = file.path(tempdir(), "hyper_dupnbr.pdf") lmv.linkage.plot(hyper,outfile,mapthese=c(1,4,6,15),dupnbr = TRUE)
knitr::include_graphics("hyper_dupnbr.png")
There is another parameter, showonly, which can be used to specify the locus names to be printed. All other locus names and positions will not be printed. The next example will demonstrate the use of the showonly parameter along with loci and position formatting options. By default the positions print to the left of the linkage group and so the position format options begin with an 'l'. And by default the loci print to the right of the linkage group and so the loci format options begin with an 'r':
See help for par, ?par
, for a full description of these defaults.
In this example we will show only one locus per linkage group. The positions and locus will be printed at twice the normal magnification (lcex=2 and rcex=2), the positions will be green, the loci red, and the position font will be bold (2) and the loci font will be italic (3).
outfile = file.path(tempdir(), "hyper_showonly.pdf") lmv.linkage.plot(hyper,outfile,mapthese=c(1,4,6,15),lcol="green",lcex=2,lfont=2, rcol="red",rcex=2,rfont=3, showonly=c("D1Mit123","D4Mit80","D6Mit135","D15Mit156"))
knitr::include_graphics("hyper_showonly.png")
Lines are still drawn across the linkage group to indicate all locus positions even though the labels are not shown. Note that the color of the line across the linkage group and to the loci name defaults to the color of the loci name. This default can be changed with rsegcol=FALSE which indicates the line across the linkage group and to the loci name should be the pdf.fg color instead.
The main parameter is used for a title for the entire drawing and defaults to NULL. By default, each linkage group name is printed above the linkage group. To turn off linkage group names printing use prtlgtitles=FALSE. You can override the linkage group names to be printed by using the lgtitles parameter. The magnification, font and color of the linkage group titles and the main title can be adjusted with the following parameters:
outfile = file.path(tempdir(), "hyper_titles.pdf") lmv.linkage.plot(hyper,outfile,mapthese=c(1,4,6,15),col.lgtitle = "blue",cex.lgtitle=2, col.main = "red",main="Overall Title for the Output Map")
knitr::include_graphics("hyper_titles.png")
There are two different ways to input QTL.
qtldf = a data frame containing these columns:
chr - Linkage group name for QTL.
col - Color for QTL.
qtlscanone = scanone object from package r/qtl. If provided, all QTLs in the data frame will be drawn by calculating their start and end with the r/qtl function bayesint with defaults.
The next example demonstrates several features in addition to qtldf. If you wish to use different colors or formats for different loci labels you can do so with the markerformatlist parameter, providing a list of loci and their desired format options. If you specify ruler=TRUE the positions will not be printed. Instead a vertical axis, or ruler, will be drawn on the left side of the page. You may also reverse the positions on a linkage group. Specify a vector of linkage group names using the revthese parameter. The 'chromosome' has various format options as well:
## plot a carrot comparative linkage map ## kindly provided by Massimo Iorizzo: ## Cavagnaro et al. BMC Genomics 2014, 15:1118 data(carrot) # make a df to pass qtl info qtldf <- data.frame( chr = character(), qtl = character(), so = numeric(), si = numeric(), ei = numeric(), eo = numeric(), col = character(), stringsAsFactors = FALSE ) qtldf <- rbind(qtldf, data.frame( chr = "70349LG3", qtl = "RTPE-Q1", so = 36.6, si = 37, ei = 37, eo = 38, col="red" )) # make a list to pass label options flist <- list() locus <- c("BSSR-094", "K0149", "K0627", "K2161", "ESSR-087", "ESSR-057") font <- c(2) #bold flist[[1]] <- list(locus = locus, font = font) locus <- c("F3H", "FLS1") font <- c(4) #bold italic flist[[2]] <- list(locus = locus, font = font) locus <- c("P3", "P1", "Raa1") font <- c(3) #italic col <- c("red") flist[[3]] <- list(locus = locus, font = font, col = col) outfile = file.path(tempdir(), "carrot.pdf") lmv.linkage.plot( carrot, outfile = outfile, ruler = TRUE, lgtitle = c("2170", "70349", "10117"), maxnbrcolsfordups = 2, markerformatlist = flist, lg.col = "lightblue1", pdf.height = 16, pdf.width = 10, revthese = c("70349LG3"), qtldf=qtldf )
knitr::include_graphics("carrot.png")
The last example will illustrate producing a density map. There is a helper function,
?lmvdencolor
which you may use to provide your own color palette, window size and color
bias. In this example the defaults are accepted and the denmap=TRUE parameter is
specified. In addition, this example customizes the ruler (y axis).
## do a density map with default colors and customize the axis data(oat) ## draw tickmarks at each cM from 0 to largest position of linkage groups to be drawn maxpos <- floor(max(oat$Position[oat$Group == "Mrg01" | oat$Group == "Mrg02"])) at.axis <- seq(0, maxpos) ## put labels on ruler at every 10 cM axlab <- vector() for (lab in 0:maxpos) { if (!lab %% 10) { axlab <- c(axlab, lab) } else { axlab <- c(axlab, NA) } } outfile = file.path(tempdir(), "oat_denmap.pdf") lmv.linkage.plot(oat,outfile,mapthese=c("Mrg01","Mrg02"),denmap=TRUE, cex.axis = 1, at.axis = at.axis, labels.axis = axlab)
knitr::include_graphics("oat_denmap.png")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.