私は100人の人とその5人の病状診断に関するデータセットを持っています。条件の任意の組み合わせが起こり得るが、条件Dの確率は、条件Aに依存し、Eは各セル共起行列を作るためにB.コードダイアグラムの扇形の幅をサークルサイズに設定
set.seed(14)
numpeople <- 100
diagnoses <- 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 <- 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 <- sapply(diagnoses$B, function(x) rbinom(1, 1, .7*x+.1))
に依存するので、私はそれを設定しました
diagnoses.dist <- t(as.matrix(diagnoses))%*%as.matrix(diagnoses)
diag(diagnoses.dist) <- 0
diagnoses.dist
> 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
は、その後、私は、各診断のための共診断の割合を表示するコードダイアグラムを使用したい:行と列の診断の両方を持つ人々の数であり、Iは行列代数を使用します。デフォルトで
circos.clear()
circos.par(gap.after=10)
chordDiagram(diagnoses.dist, symmetric=TRUE)
、各グループのために割り当てられたセクタのサイズ(パイスライス)は、リンクの数に比例します。
> colSums(diagnoses.dist) #Number of links related to each diagnosis
A B C D E
16 9 10 21 18
各診断の人数を示すためにセクタ幅を設定することはできますか?
> colSums(diagnoses) #Number of people with each diagnosis
A B C D E
16 8 20 29 18
この問題はcirclize帳のsection 14.5に幾分関連と思われるが、私はgap.after
引数に数学を仕事するかどうかはわかりません。 circlizeブックのsection 2.3に基づいて
は、私がcircos.initalize
を使用してセクタサイズを設定しようとしたが、私は外のスケールはまったく同じであるため、chordDiagram
機能は、これを上書きしますと思います。
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)
私はchordDiagram
ではなく、部門のためのあまりにトラックを微調整するために多くのオプションを参照してください。これができる方法はありますか?