title: Set sector width of chord diagram with circlize
body: <p>I have a data set involving 100 people and their diagnosis of 5 medical conditions.  Any combinations of conditions can occur, but I've set it up so that the probability of condition D depends on condition A, and E depends on B. </p>
  
  <pre><code>set.seed(14)
  numpeople &lt;- 100
  diagnoses &lt;- data.frame(A=rbinom(100, 1, .15), 
                          B=rbinom(100, 1, .1),
                          C=rbinom(100, 1, .2)
                          )
  # Probability of diagnosis for D increases by .4 if patient has A, otherwise .5
  diagnoses$D &lt;- sapply(diagnoses$A, function(x) rbinom(1, 1, .4*x+.2))
  # Probability of diagnosis for E increases by .3 if patient has B, otherwise rare
  diagnoses$E &lt;- sapply(diagnoses$B, function(x) rbinom(1, 1, .7*x+.1))
  </code></pre>
  
  <p>To make a co-occurrence matrix, where each cell is the number of people with both of the diagnoses in the row and column, I use matrix algebra: </p>
  
  <pre><code>diagnoses.dist &lt;- t(as.matrix(diagnoses))%*%as.matrix(diagnoses)
  diag(diagnoses.dist) &lt;- 0
  diagnoses.dist
  &gt; diagnoses.dist
     A B C  D E
  A  0 1 1 11 3
  B  1 0 0  1 7
  C  1 0 0  5 4
  D 11 1 5  0 4
  E  3 7 4  4 0
  </code></pre>
  
  <p>Then I'd like to use a chord diagram to show the proportion of co-diagnoses for each diagnosis. </p>
  
  <pre><code>circos.clear()
  circos.par(gap.after=10)
  chordDiagram(diagnoses.dist, symmetric=TRUE)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qsjEf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qsjEf.jpg" alt="Example Chord diagram with 5 groups"></a></p>
  
  <p>By default, size of the sector (pie slice) allocated for each group is proportional to the number of links. </p>
  
  <pre><code>&gt; colSums(diagnoses.dist) #Number of links related to each diagnosis
   A  B  C  D  E 
  16  9 10 21 18 
  </code></pre>
  
  <p>Is it possible to set the sector width to illustrate the number of people which each diagnosis? </p>
  
  <pre><code>&gt; colSums(diagnoses) #Number of people with each diagnosis
   A  B  C  D  E 
  16  8 20 29 18 
  </code></pre>
  
  <p>This problem seems somewhat related to <a href="http://zuguang.de/circlize_book/book/advanced-usage-of-chorddiagram.html#compare-two-chord-diagrams" rel="nofollow noreferrer">section 14.5</a> of the circlize book, but I'm not sure how to work the math for the <code>gap.after</code> argument.  </p>
  
  <p>Based on <a href="http://zuguang.de/circlize_book/book/circular-layout.html#sectors-and-tracks" rel="nofollow noreferrer">section 2.3</a> of the circlize book, I tried setting the sector size using <code>circos.initalize</code> but I think the <code>chordDiagram</code> function overrides this, because the scale on the outside is exactly the same.</p>
  
  <pre><code>circos.clear()
  circos.par(gap.after=10)
  circos.initialize(factors=names(diagnoses), x=colSums(diagnoses)/sum(diagnoses), xlim=c(0,1))
  chordDiagram(diagnoses.dist, symmetric=TRUE)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1ljPf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ljPf.jpg" alt="enter image description here"></a></p>
  
  <p>I see a lot of options to fine-tune tracks in <code>chordDiagram</code> but not much for sectors.  Is there a way this can be done?</p>