Closed lbwfff closed 2 years ago
Yes, you can use circos.labels()
in the normal way. It would be not easy if clustering is turned on, but here since there is no clustering in your code, I think you can just add:
circos.labels(sectors, c(0.5, 9.5, 99.5), c("gene_1", "gene_10", "gene_100"))
You can get the value of sectors
from circos.info()
. This is the name of the sector.
Hi, jokergoo
Thank you for your reply, but I still have some problems with the addition of circos.labels. I found that the added label does not seem to appear in the position I expected. Can you help me see where is the problem in the code?
list<-c(c('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','X','Y'))
mat2<-data.frame(gene=c(paste0('gene_',1:1000)),
chorm=c(sample(list, 1000,replace =T)),
exp=c(sample(c(0), 1000,replace =T)))
mat2$exp[c(1,10,100,1000)]<-c(-1,1,-1,1)
split <- factor(mat2$chorm, levels = c('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','X','Y'))
circos.par(start.degree = 90, gap.degree = 10,gap.after = c(3))
col_fun4 = colorRamp2(c(-1,0,1), c(met.brewer("Homer1")[7],'white',met.brewer("Signac")[4]))
circos.heatmap(mat2[,3], col = col_fun4 ,rownames.side = "none",
split =split,
dend.side='none',na.col = 'white',cluster = F,cell_width=8)
circos.info()
circos.labels(c(mat2$chorm[mat2$exp=='-1' |mat2$exp=='1']),
x=c((1:nrow(mat2))[mat2$exp=='-1' |mat2$exp=='1']-0.5),
labels = c(mat2$gene[mat2$exp=='-1' |mat2$exp=='1']))
circos.clear()
In the above code, I want to group genes with chromosome as split, and I only want to add labels to four genes that are significantly changed, but I found that the labels did not appear in the expected positions after running the code. I don't know why.
Thanks, LeeLee
Currently the following code works:
circos.par(start.degree = 90, gap.degree = 10,gap.after = c(3))
col_fun4 = colorRamp2(c(-1,0,1), c(met.brewer("Homer1")[7],'white',met.brewer("Signac")[4]))
circos.heatmap(mat2[,3], col = col_fun4 ,rownames.side = "none",
split = split,
dend.side='none',na.col = 'white',cluster = F,cell_width=8)
x = NULL
for(i in which(mat2[, 3] != 0)) {
subset = get.cell.meta.data("subset", sector.index = split[i])
order = get.cell.meta.data("row_order", sector.index = split[i])
x = c(x, which((1:nrow(mat2))[subset][order] == i))
}
l = mat2[, 3] != 0
circos.labels(split[l], x = x - 0.5, labels = mat2$gene[l])
circos.clear()
This works both when cluster = TRUE
and cluster = FALSE
. The logic for calculating x
is not very straightforward. I will support it in circlize in the future.
I just added a new function circos.heatmap.get.x()
which automatically calculates the positions of heatmap rows in the circos plot. Check the following code:
circos.par(start.degree = 90, gap.degree = 10,gap.after = c(3))
col_fun4 = colorRamp2(c(-1,0,1), c(met.brewer("Homer1")[7],'white',met.brewer("Signac")[4]))
circos.heatmap(mat2[,3], col = col_fun4 ,rownames.side = "none",
split = split,
dend.side='none',na.col = 'white',cluster = F,cell_width=8)
pos = circos.heatmap.get.x(mat2, c(1, 10, 100, 1000))
circos.labels(pos[, 1], x = pos[, 2], labels = mat2$gene[pos[, 3]])
circos.clear()
It works, my question is solved, thank you.
I have changed the API of circos.heatmap.get.x()
a little bit. Now you do not need to put the matrix in the argument. Simply call:
pos = circos.heatmap.get.x(c(1, 10, 100, 1000))
because the matrix information is already internally cached in the package.
Hi,
I want to use circos.heatmap to show information about a batch of genes, but I only want to show the names of some of them, I see that circos.labels seems to do it, but I don't know how. Or is there any other function that can help me do this? As an example, I have the following matrix and I have a heatmap plotted:
But I only want to display the IDs of the genes: gene_1, gene_10, gene_100, how can I achieve this?
Thanks, LeeLee