Great, thank you so much for your help! how stupid of me, I think I have missunderstood what cluster does in this function... can you please explain what cluster does exactly?
best Jonas
Hi!
I'm trying to learn the circlize package and I get weird sorting. Can anyone please tell me why the most expressed and the least expressed gene is ending up where they are (see marking) and not following the gradient?
Data looks like this:
From highest:
...
To lowest:
This is the command I run:
# Create color gradient
col_fun <- colorRamp2(c(-1,0, 1), c("blue", "white", "red"))
# Generate plot on pdf
cairo_pdf("results/plot1_test.pdf", width = 16, height = 9)
# Create gap, start.degree = where to put gap, gap.after = how wide gap should be
circos.par(start.degree = 70, gap.after = 20)
# Create outer track
circos.heatmap(plot1_outer, col = col_fun, rownames.side = "outside", track.height = 0.15)
# Add labels outer track
circos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {
if(CELL_META$sector.numeric.index == 1) { # the last sector
cn = "DEG_LogFC"
n = length(cn)
circos.text(x = rep(CELL_META$cell.xlim[2], n) + convert_x(0.5, "mm"),
y = 1:n - 0.5, labels = cn,
cex = 0.5, adj = c(0, 0.5), facing = "inside")
}
}, bg.border = NA)
# Finnish plot on pdf
dev.off()
I have tried with both cluster = TRUE and cluster = FALSE, also tried sorting the genes before creating the plot but no difference.
Thanks in advance!
/ Jonas
The issue is that you used circos_heatmap() which display genes according to clustering.
You should can turn off this clustering but you need to sort your dataframe beforehand and then specify cluster=FALSEin the circus.heatmap arguments:
plot1_test=plot1_test[order(plot1_test[,1],decreasing=TRUE),,drop=FALSE]
circos.heatmap(plot1_test, cluster=FALSE,col = col_fun,rownames.side = "outside")
Great, thank you so much for your help! how stupid of me, I think I have missunderstood what cluster does in this function... can you please explain what cluster does exactly?
best Jonas
It applies hierarchical clustering on your data, based on Euclidean distance
Agree with Basti .
Just want to add a bit from the documentation.
circos.heatmap() documentation, section 6.4, states firstly that:
By default, the numeric matrix is clustered on rows. cluster argument can be set to FALSE to turn off the clustering.
Of course, when cluster is set to FALSE, no dendrogram is drawn even if dend.side is set.
and secondly that,
Clustering method and distance method are controlled by clustering.method and distance.method arguments.
Please note circos.heatmap() does not directly support clustering on matrix columns. You should apply column reordering before send to circos.heatmap()
Log in to answer this question.
Do you have a reproducible example to share ?
I'm still a newbie sharing examples so please bare with me:), this should do the same that I've done:
Expression data:
)
}, bg.border = NA)