bio-services / LinkageMapView

Plot Linkage Group Maps with QTLs
GNU General Public License v3.0
8 stars 12 forks source link

Collapsing LOD interval and labels #13

Open kraltendorf opened 4 years ago

kraltendorf commented 4 years ago

The QTL intervals and labels from my "qtldf" are collapsing on one another making them illegible (see attached). Do you have any work arounds? troubleshooting.pdf

kraltendorf commented 4 years ago

Troubleshooting linkagemapview overlapping qtl intervals

Found a "brute force" work around to this problem and wanted to share Special thanks to @neyhartj

Follow the script below to reproduce the problem and demonstrate a solution

install packages

install.packages("LinkageMapView") library("LinkageMapView")

create a dataframe to test

set.seed(152) pos <- rnorm(150, mean = 50, sd = 15) linkagedat <- data.frame(group = c(rep(1, 150)), position = pos, locus = paste("S", 1:150, sep = ""))

create a qtldf

qtldf <- data.frame(chr = rep(1, 3), qtl = c("seed_size", "seed_weight", "seed_area"), so = c(26, 27, 60), si = c(26, 27, 60), ei = c(27, 28, 75), eo = c(27, 28, 75), col = c("black", "gray", "black"))

it seems to only occur when the intervals begin and end close to one another

set directory

dir <- c("/users/yourname/desktop") setwd(dir)

outfile

outfile = file.path(dir, "lg_test.pdf")

this is the function that produces the figure

lmv.linkage.plot(mapthis = linkage_dat, # data outfile = outfile, # file to output mapthese=c(1), # which LG of those in the dataframe to map lcol="black",lcex=2,lfont=1, # some options for color; font size; etc. rcol="black",rcex=2,rfont=1, showonly=c("S_150", "S_1"), # which loci to show pdf.height=6, # pdf options pdf.pointsize=7, qtldf = qtldf, # datframe of qtl intervals par(lwd=0.1), lty.axis=0)

when you add a "showonly" locus to the problem area, it will force the labels out to the right the problem area is around 26 cM

append a new fake locus onto the dataframe

linkage_dat_append <- data.frame(group = 1, position = 26, locus = "w") linkage_dat1 <- rbind(linkage_dat, linkage_dat_append)

produce a new figure

outfile = file.path(dir, "lg_test2.pdf") lmv.linkage.plot(mapthis = linkage_dat1, outfile = outfile, mapthese=c(1), lcol="black",lcex=2,lfont=1, rcol="black",rcex=2,rfont=1, showonly=c("S_150", "S_1", "w"), # add the fake locus to "show only" pdf.height=6, pdf.pointsize=7, qtldf = qtldf, par(lwd=0.1), lty.axis=0)

you can see that it pops the overlapping lables out to the right you change their font to white so they are not visible

format_list <- list()

label_adjuster <- c("w") cex <- c(0.25) #size - make it small font <- c(1) col <- c("white") # and white format_list[[1]] <- list(locus = label_adjuster, font = font, cex = cex, col = col)

produce a new figure

outfile = file.path(dir, "lg_test3.pdf")

lmv.linkage.plot(mapthis = linkage_dat1, outfile = outfile, mapthese=c(1), lcol="black",lcex=2,lfont=1, rcol="black",rcex=2,rfont=1, showonly=c("S_150", "S_1", "w"), # add the fake locus to "show only" pdf.height=6, pdf.pointsize=7, qtldf = qtldf, par(lwd=0.1), lty.axis=0, markerformatlist=format_list) # add a markerformatlist