how to make a OmicCircos config files
2
1
Entering edit mode
7.6 years ago
Alex ▴ 50

Hi guys,

At present I am plotting a circos picture using OmicCircos,while encountered some problems when made the config file,As the manual say A mapping data are an R data frame which includes values to be drawn in the graph. In the mapping data, columns 1 and 2 are segment name and position respectively. Column 3 and beyond is optional which can be the value or name. I want to make a gene_exp data frame,while the columns 1 is the gene symbol and the columns 2 I'm fusing about whether is a gene star position or the end position ?Any help will be appreciated.

Thanks

Alex

R • 3.7k views
ADD COMMENT
0
Entering edit mode
7.6 years ago
theobroma22 ★ 1.2k
library(OmicCircos)
options(stringsAsFactors=FALSE)
x <- c(29289779, 36374806, 33710802, 23020739, 31606955, 25473135, 
26383534, 29603939, 33717675, 33391235, 35299535, 31678690,
34719086, 29158859, 47181002, 20664393, 24923725, 1348170000)
#scale chrs to 1Mbps
x <- x/1000000
set.seed(2017)
mdm1 <- rep(paste0("MDP", 1),  each = 29.28978)
mdm2 <- rep(paste0("MDP", 2),  each = 36.37481)
mdm3 <- rep(paste0("MDP", 3),  each = 33.71080)
mdm4 <- rep(paste0("MDP", 4),  each = 23.02074)
mdm5 <- rep(paste0("MDP", 5),  each = 31.60695)
mdm6 <- rep(paste0("MDP", 6),  each = 25.47313)
mdm7 <- rep(paste0("MDP", 7),  each = 26.38353)
mdm8 <- rep(paste0("MDP", 8),  each = 29.60394)
mdm9 <- rep(paste0("MDP", 9),  each = 33.71767)
mdm10 <- rep(paste0("MDP", 10), each = 33.39124)
mdm11 <- rep(paste0("MDP", 11), each = 35.29953)
mdm12 <- rep(paste0("MDP", 12), each = 31.67869)
mdm13 <- rep(paste0("MDP", 13), each = 34.71909)
mdm14 <- rep(paste0("MDP", 14), each = 29.15886)
mdm15 <- rep(paste0("MDP", 15), each = 47.18100)
mdm16 <- rep(paste0("MDP", 16), each = 20.66439)
mdm17 <- rep(paste0("MDP", 17), each = 24.92373)
mdmUn <- rep(paste0("MDP", "Un"), each = 1348.17000)
seg1 <- c(mdm1, mdm2, mdm3, mdm4, mdm5, mdm6, mdm7, 
mdm8, mdm9, mdm10, mdm11, mdm12, mdm13, mdm14, mdm15, 
mdm16, mdm17, mdmUn) 
repMd1 <- rep(1:x[1]); repMd2 <- rep(1:x[2]); repMd3 <- rep(1:x[3]); repMd4 <- rep(1:x[4])
repMd5 <- rep(1:x[5]); repMd6 <- rep(1:x[6]); repMd7 <- rep(1:x[7]); repMd8 <- rep(1:x[8])
repMd9 <- rep(1:x[9]); repMd10 <- rep(1:x[10]); repMd11 <- rep(1:x[11]); repMd12 <- rep(1:x[12])
repMd13 <- rep(1:x[13]); repMd14 <- rep(1:x[14]); repMd15 <- rep(1:x[15]); repMd16 <- rep(1:x[16])
repMd17 <- rep(1:x[17]); repMdUn <- rep(1:x[18])
end1 <- c(repMd1, repMd2, repMd3, repMd4, repMd5, repMd6, repMd7, repMd8,
repMd9, repMd10, repMd11, repMd12, repMd13, repMd14, repMd15, repMd16,
repMd17, repMdUn)
de1 <- rep(paste0("CHR", 1), each = 29.28978)
de2 <- rep(paste0("CHR", 2), each = 36.37481)
de3 <- rep(paste0("CHR", 3), each = 33.71080)
de4 <- rep(paste0("CHR", 4), each = 23.02074)
de5 <- rep(paste0("CHR", 5), each = 31.60695)
de6 <- rep(paste0("CHR", 6), each = 25.47313)
de7 <- rep(paste0("CHR", 7), each = 26.38353)
de8 <- rep(paste0("CHR", 8), each = 29.60394)
de9 <- rep(paste0("CHR", 9), each = 33.71767)
de10 <- rep(paste0("CHR", 10), each = 33.39124)
de11 <- rep(paste0("CHR", 11), each = 35.29953)
de12 <- rep(paste0("CHR", 12), each = 31.67869)
de13 <- rep(paste0("CHR", 13), each = 34.71909)
de14 <- rep(paste0("CHR", 14), each = 29.15886)
de15 <- rep(paste0("CHR", 15), each = 47.18100)
de16 <- rep(paste0("CHR", 16), each = 20.66439)
de17 <- rep(paste0("CHR", 17), each = 24.92373)
deUn <- rep(paste0("CHR", "Un"), each = 1348.17000)
seg2 <- c(de1, de2, de3, de4, de5, de6, de7, de8, 
de9, de10, de11, de12, de13, de14, de15, de16, de17, deUn) 
repDE1 <- rep(1:x[1]); repDE2 <- rep(1:x[2]); repDE3 <- rep(1:x[3]); repDE4 <- rep(1:x[4])
repDE5 <- rep(1:x[5]); repDE6 <- rep(1:x[6]); repDE7 <- rep(1:x[7]); repDE8 <- rep(1:x[8])
repDE9 <- rep(1:x[9]); repDE10 <- rep(1:x[10]); repDE11 <- rep(1:x[11]); repDE12 <- rep(1:x[12]);
repDE13 <- rep(1:x[13]); repDE14 <- rep(1:x[14]); repDE15 <- rep(1:x[15]); repDE16 <- rep(1:x[16]);
repDE17 <- rep(1:x[17]); repDEUn <- rep(1:x[18])
end2 <- c(repDE1, repDE2, repDE3, repDE4, repDE5, repDE6, repDE7, repDE8,
repDE9, repDE10, repDE11, repDE12, repDE13, repDE14, repDE15, repDE16,
repDE17, repDEUn)
link.num = 100
link.i = sample(1:length(seg1), link.num, replace = TRUE)
de1 <- length(seg1) +1 
link.j = sample(de1:length(end), link.num, replace = TRUE)
link.df <- cbind(seg.f[link.i, c(1,2,5)], seg.f[link.j, c(1,2,5)])
link.n <- gsub("MDP", "", link.df[,1])
link.n <- gsub("Un", "18", link.n)
link.c <- col2[as.numeric(link.n)]
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), replace = TRUE))
db <- segAnglePo(seg.f, seg=unique(segs))
col1 <- rainbow(18)
col2 <- rainbow(18)
chr.c <- c(col1, rep("black", 18))
#pdf("CIRCOS.pdf", 8, 8)
par(mar=c(2,2,2,2)) 
plot(c(1,800),  c(1,800), type="n", axes=FALSE, xlab="XLAB", ylab="YLAB", main="@THEOBROMA22")
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=1, col=link.c)
#dev.off()

Does this help you?

ADD COMMENT
0
Entering edit mode

You can copy and paste the above code into the R terminal and it should make a completed circos plot.

ADD REPLY
0
Entering edit mode

Hi,theobroma22: It seems that not helpful,when I run db <- segAnglePo(seg.f, seg=unique(segs)),the class length and names length different

Alex

ADD REPLY
0
Entering edit mode

When you paste the above code for seg.f do you have a '(' after data.frame? It should be

seg.f <- data.frame ( seg.name = segs....

This happens from time to time when pasting into biostars and I don't know why...?

I updated the code above so you can get the '('

ADD REPLY
0
Entering edit mode

can you send the code to my gmail,maybe it will clearly to me,the maile is :

Thanks

Alex

ADD REPLY
1
Entering edit mode

Please keep all discussion on the forum and open.

ADD REPLY
0
Entering edit mode
7.6 years ago
theobroma22 ★ 1.2k

Hi Alex,

The above code works for me, so I don't know why it's not working for you. Biostars website sometimes changes the format of special characters in the code. Instead of just copying and pasting the entire code into R, try doing it in pieces or steps and understand what each step is doing. Are you certain that the seg.f, link.df, link.n, link.c, col2 and all other objects were created and stored?? You can confirm this by writing objects() in the R cmd line, and then check the output. I don't know how I can help you beyond this, so if you continue to have problems perhaps try contacting the OmicCircos package maintainer.

ADD COMMENT
0
Entering edit mode

Here are some of the errors from copying and pasting all of the code into R which I had to go back and run the code separately to make sure it worked.

> link.df <- cbind(seg.f[link.i, c(1,2,5)], seg.f[link.j, c(1,2,5)])
Error in eval(expr, envir, enclos) : object 'seg.f' not found
> link.n <- gsub("MDP", "", link.df[,1])
Error in gsub("MDP", "", link.df[, 1]) : object 'link.df' not found
> link.n <- gsub("Un", "18", link.n)
Error in gsub("Un", "18", link.n) : object 'link.n' not found
> link.c <- col2[as.numeric(link.n)]
Error: object 'col2' not found
> 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), replace = TRUE))
> db <- segAnglePo(seg.f, seg=unique(segs))
> col1 <- rainbow(18)
> col2 <- rainbow(18)
> chr.c <- c(col1, rep("black", 18))
> #pdf("CIRCOS.pdf", 8, 8)
> par(mar=c(2,2,2,2)) 
> plot(c(1,800),  c(1,800), type="n", axes=FALSE, xlab="XLAB", ylab="YLAB", main="@THEOBROMA22")
> 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=1, col=link.c)
Error in circos(R = 350, cir = db, W = 40, mapping = link.df, type = "link",  : 
  object 'link.df' not found
> #dev.off()
> seg.f <- data.frame ( seg.name = segs, seg.Start = start, seg.End = end, the.v=runif(length(end)),
+ Note = sample(LETTERS, length(end), replace = TRUE))
> db <- segAnglePo(seg.f, seg=unique(segs))
> col1 <- rainbow(18)
> col2 <- rainbow(18)
> chr.c <- c(col1, rep("black", 18))
> #pdf("CIRCOS.pdf", 8, 8)
> par(mar=c(2,2,2,2)) 
> plot(c(1,800),  c(1,800), type="n", axes=FALSE, xlab="XLAB", ylab="YLAB", main="@THEOBROMA22")
> 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=1, col=link.c)
Error in circos(R = 350, cir = db, W = 40, mapping = link.df, type = "link",  : 
  object 'link.df' not found
> #dev.off()
> link.df <- cbind(seg.f[link.i, c(1,2,5)], seg.f[link.j, c(1,2,5)])
> par(mar=c(2,2,2,2)) 
> plot(c(1,800),  c(1,800), type="n", axes=FALSE, xlab="XLAB", ylab="YLAB", main="@THEOBROMA22")
> 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=1, col=link.c)
Error in circos(R = 350, cir = db, W = 40, mapping = link.df, type = "link",  : 
  object 'link.c' not found
> #dev.off()
> link.c <- col2[as.numeric(link.n)]
Error: object 'link.n' not found
> link.j = sample(de1:length(end), link.num, replace = TRUE)
> link.df <- cbind(seg.f[link.i, c(1,2,5)], seg.f[link.j, c(1,2,5)])
> link.n <- gsub("MDP", "", link.df[,1])
> link.n <- gsub("Un", "18", link.n)
> link.c <- col2[as.numeric(link.n)]
> 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), replace = TRUE))
> db <- segAnglePo(seg.f, seg=unique(segs))
> col1 <- rainbow(18)
> col2 <- rainbow(18)
> chr.c <- c(col1, rep("black", 18))
> #pdf("CIRCOS.pdf", 8, 8)
> par(mar=c(2,2,2,2)) 
> plot(c(1,800),  c(1,800), type="n", axes=FALSE, xlab="XLAB", ylab="YLAB", main="@THEOBROMA22")
> 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=1, col=link.c)
> #dev.off()
>
ADD REPLY

Login before adding your answer.

Traffic: 2686 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6