We want to do a graph to show the Syntenic links between a linkage map and physical map visualized using Circos
source("http://bioconductor.org/biocLite.R")
biocLite("OmicCircos")
Each line will represent a connection between the position of a particular marker in our linkage map (black; scale in cM) and a homologous sequence in physical map (various colors; scale in Mb). The idea is to do something like this picture:
G3 (Bethesda). 2015 Feb; 5(2): 241–251. Published online 2014 Dec 17. doi: 10.1534/g3.114.015438
I have a structured family (parental, F1 and F2) that was sequenced and aligned against the reference genome. I did a linkage map using r/onemap (CRAN) to check the recombination fraction of the markers in the F2 family (only markers with Mendelian Inheritance). Now I have the groups obtained by the recombination in this format:
> maps
[[7]]
Printing map:
Markers Position Parent 1 Parent 2
4142 MS33_8248325 0.00 a | | b a | | a
4143 MS33_8248326 0.10 a | | b a | | a
4144 MS33_8248327 0.20 a | | b a | | a
4145 MS33_8248328 0.30 a | | b a | | a
4146 MS33_8248329 0.40 a | | b a | | a
4147 MS33_8248330 0.50 a | | b a | | a
6 markers log-likelihood: -49.90696
MS33_8248325 represents the marker where we have the chromossome (M33) and position (8248325 in the chr) information and the cM postion in the second column.
The maps file contains:
$seq.num
$seq.phases
$seq.rf
$seq.like
$data.nam
$twopt
To each linkage group
How should I show the comparison between linkage map and physical map to prove that they are in agreement?? looks like that "OmicCircos" is a good idea, but I cannot find a tutorial to generate a graph like this one presented here where is divided into two sides (right: chromossomes and left: linkage groups).
I was working in a script that it was proveded by OmicCircos tutorial: Trying to edit this command line and get the appropriate input from my data.
library (OmicCircos)
options (stringsAsFactors=FALSE) ;
set.seed(1234) ;
# initial
seg.num <-10
ind.num <-20
seg.po<- c(20:50)
link.num <- 10
link.pg.num <-4
sim.out<- sim.circos (seg=seg.num, po=seg.po, ind=ind.num, link=link.num, link.pg=link.pg.num)
seg.f<-sim.out$seg.frame
seg.v<-sim.out$seg.mapping
link.v<-sim.out$seg.link
link.pg.v<-sim.out$seg.link.pg
seg.num<-length(unique(seg.f[,1]))
#namesegment(option)
seg.name<-paste("chr",1:seg.num,sep="")
db<-segAnglePo(seg.f,seg=seg.name)
#settransparentcolors
colors<-rainbow(seg.num,alpha=0.5)
#Togetperfectcircle,theoutputfigureshouldbeinsquare.Theoutputfileisthesamewidthandheight.
#Thesamelinevaluesareinthemarginofthegraphicalparameters.
par(mar=c(2,2,2,2));
plot(c(1,800),c(1,800),type="n",axes=FALSE,xlab="",ylab="",main="")
circos(R=400,cir=db,type="chr",col=colors,print.chr.lab=TRUE,W=4,scale=TRUE)
circos(R=360,cir=db,W=40,mapping=seg.v,col.v=3,type="l",B=TRUE,col=colors[1],lwd=2,scale=TRUE)
circos(R=320,cir=db,W=40,mapping=seg.v,col.v=3,type="ls",B=FALSE,col=colors[9],lwd=2,scale=TRUE)
circos(R=280,cir=db,W=40,mapping=seg.v,col.v=3,type="lh",B=TRUE,col=colors[7],lwd=2,scale=TRUE)
circos(R=240,cir=db,W=40,mapping=seg.v,col.v=19,type="ml",B=FALSE,col=colors,lwd=2,scale=TRUE)
circos(R=200,cir=db,W=40,mapping=seg.v,col.v=19,type="ml2",B=TRUE,col=colors, lwd=2)
circos(R=160,cir=db,W=40,mapping=seg.v,col.v=19,type="ml3",B=FALSE,cutoff=5, lwd=2)
circos(R=150,cir=db,W=40,mapping=link.v,type="link",lwd=2,col=colors[c(1,7)])
circos(R=150,cir=db,W=40,mapping=link.pg.v,type="link.pg",lwd=2,col=sample(colors,link.pg.num))
dev.off()
#graphics.off()
follow the link to solve this trick https://support.bioconductor.org/p/80024/#80129
summaryzing:
library (OmicCircos)
options(stringsAsFactors = FALSE)
set.seed(1234)
################################################
Chr1 <- rep(paste0("Chr", 1), each=518);
Chr2 <- rep(paste0("Chr", 2), each=362);
Chr3 <- rep(paste0("Chr", 3), each=347);
Chr4 <- rep(paste0("Chr", 4), each=366);
...
seg1 <- c(Chr1, Chr2, Chr3, Chr4, ...);
repChr1<-rep(1:518);
repChr2<-rep(1:362);
repChr3<-rep(1:347);
repChr4<-rep(1:366);
...
end1 <- c(repChr1, repChr2, repChr3, repChr4, ...);
LG1 <- rep(paste0("LG", 1), each=528);
LG2 <- rep(paste0("LG", 2), each=354);
LG3 <- rep(paste0("LG", 3), each=346);
LG4 <- rep(paste0("LG", 4), each=367);
...
seg2 <- c(LG1, LG2, LG3, LG4, ...);
end2 <- c(repLG1, repLG2, repLG3, repLG4, ...)
end <- c(end1, end2);
segs <- c(seg1, seg2);
start <- end - 1;
seg.f <- data.frame(seg.name=segs, seg.Start=start, seg.End=end, the.v=runif(length(end)), Note=sample(LETTERS, length(end), rep=T));
db <- segAnglePo(seg.f,seg=unique(segs));
## colors
col1 <- rainbow(4+...);
col2 <- rainbow(4+..., alpha=0.3);
chr.c <- c(col1, rep("black", 4+...));
## links - simulation
#link.num <- 100;
#link.i <- sample(1:length(seg1), link.num, rep=T);
#LG1 <- length(seg1) + 1;
#link.j <- sample(LG1:length(end), link.num, rep=T);
#link.df <- cbind(seg.f[link.i,c(1,2,5)], seg.f[link.j,c(1,2,5)]);
#link.n <- gsub("Chr", "", link.df[,1]);
#link.c <- col2[as.numeric(link.n)]
pdf("syntenyGBS.pdf", 8, 8);
par(mar=c(2,2,2,2));
plot(c(1,800),c(1,800),type="n",axes=FALSE,xlab="",ylab="",main="")
circos(R=360, cir=db, type="chr",col=chr.c, print.chr.lab=TRUE, W=40, scale=F)
circos(R=350, cir=db, W=40, mapping=link.df, type="link", lwd=0.1, col=link.c);
dev.off();