0

I want to initialize a new chord diagram with circlize, but I'm getting an error that doesn't seem to make any sense given the data I'm feeding into it:

Error: Since `xlim` is a matrix, it should have same number of rows as the length of the level of `sectors` and number of columns of 2.

I understand the requirement, but when I try to produce different plots, it fails for some but not others. Here's the relevant code snippet with some output for debugging

dev.new()                                                                       
circos.clear()            
circos.par(cell.padding=c(0,0,0,0), track.margin=c(0,0.01), gap.degree=1)                                     
xlim = cbind(0, regionTotal) 
print(class(region))                                                   
print(length(region))                                                           
print(class(xlim))                                                              
print(dim(xlim))                                                                                                                                                                                       
circos.initialize(factors=region, xlim=xlim)

The output for a plot that works fine:

[1] "character"
[1] 24
[1] "matrix" "array" 
[1] 24  2

And for one that returns the error:

[1] "character"
[1] 50
[1] "matrix" "array" 
[1] 50  2
Error: Since `xlim` is a matrix, it should have same number of rows as the length of the level of `sectors` and number of columns of 2.

I am aware of these question: this one led me to check the class

and this one led me to check my circlize version (0.4.11)

What am I missing??? Thanks for any help you can provide.

1 Answers1

0

After a lot of hair pulling, I figured out the problem: there was a repeated value in my region variable (the factors or sectors entry in circos.initialize), so the effective number of sectors was lower than the dimension of the variable. Hopefully nobody else is dumb enough to make this mistake, but just in case they are, now they can have an additional thing to check if they come across this error.