This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Changing order of elements on Chord diagram in R

Hi all,

I'm currently making a Chort Diagram, and have no idea how to change the order of it.

Like showed on below picture, I want to change those two elements so that elements with grey colors are gathered together as they are from same group.

enter image description here

This is my code to make it:

set.seed(123) circos.clear() chordDiagram(input_mat, grid.col = color_grid.col, col = col_fun, annotationTrack = "grid", big.gap = 3, small.gap = 0.3, group = temp_group, symmetric = F, link.target.prop = F, preAllocateTracks = list( track.height = mm_h(3) ))

I've tried put "input_mat[wanted_order,wanted_order]" instead of "input_mat", but that doesn't work. Input_mat is a matrix; rownames and colnames are exactly same and values are count.

Does anyone have any idea?

chort chart r diagram plot

It would be helpful if you provided a minimal reproducible example so others can test and troubleshoot your issue. Without knowing the structure/contents of input_mat, color_grid.col, col_fun, and temp_group, it’s difficult to determine why input_mat[wanted_order, wanted_order] isn’t working as you expect.

A small example with a dummy matrix and some mock values for the parameters would make it easier for people to play around with the code and suggest a fix. For example, something like this:

input_mat <- matrix(
    c(
        1, 2, 3, 4,
        # another row of numbers
        # another row of numbers
        # another row of numbers
    ),
nrow = 4, byrow = TRUE)

# Assign row and column names, and assign colors for groups, etc.

In case it helps, here’s a general guide on making an MRE: stackoverflow.com/help/minimal-reproducible-example.

Here's some info on formatting code on this site too: biostars.org/p/346537/#9584651.

0 answers

No answers yet.

Log in to answer this question.