circlize icon indicating copy to clipboard operation
circlize copied to clipboard

data is two columns and more than 10 rows

Open slx92 opened this issue 2 years ago • 1 comments

  • When the data is two columns and more than 10 rows, it will not be able to plot correctly and no error will be reported. After modifying part of the code of chordDiagram.R, it can draw correctly.
  • Replace lines 143-145 with the following code
  • if(ncol(x) == 2 && nrow(x) > 10) { x = data.frame(rn=rep(rownames(x),2), cn=c(rep(colnames(x)[1], nrow(x)),rep(colnames(x)[2], nrow(x))), value=c(x[,1],x[,2])) }
  • before image
  • after image

slx92 avatar Jul 07 '22 03:07 slx92

Yes, you are right. My original thought was people may wrongly save an adjacency list (as a two-column data frame) as a two-column matrix. So I convert all two-column matrices with > 10 rows to a data frame. This is obviously too naive and not proper because there are indeed adjacency matrices with two columns (as in your example).

I will just test whether the matrix is numeric or character. If it is character, then I will convert it to a data frame. And if it is a matrix, I will treat it as an adjacency matrix.

You can validate it with the version from GitHub.

jokergoo avatar Jul 27 '22 10:07 jokergoo