## Main Bubbletree Functions

### BubbleTree model and diagram

BubbleTree is a model based on three valid assumptions: 1) the paired normal specimen expresses the common diploid state, 2) variant sites are bi-allelic, and 3) genome segments (rather than the whole genome) with homogeneous copy number ratio and BAFs, exist in the profiled tumor genome. The first two assumptions generally hold, whereas the last homogeneity assumption can also be satisfied even in the case of a complex tumor clonal structure.

As the three assumptions are all generally plausible, we therefore developed a model for the BubbleTree diagram. For one homogenous genomic segment (x:y;p), we have,

Expected copy number, (CN)=2×(1-p)+(x+y)×p

Copy Ratio, R=(CN)/2=(1-p)+(x+y)/2×p (1)

B allele frequency, BAF=(y×p+1×(1-p))/((x+y)×p+2×(1-p))

and the homozygous-deviation score (HDS),

HDS= ∣BAF-0.5∣=(p×∣y-x∣)/(2×[(x+y)×p+2×(1-p)]) (2)

Based on equations (1) and (2), we are able to calculate an R score (copy ratio) and HDS for a segment (x:y; p). For example, (0:1; 0.75) will provide 0.625 and 0.3 for the R scores and HDS, respectively.

These calculations are performed by the getRBD() function

```
library(BubbleTree)
data(hetero.gr)
data(cnv.gr)
rbd=getRBD(snp.gr=hetero.gr,cnv.gr=cnv.gr)
```

```
## Segments with high SD:
## [1] seg.id hds.median hds.sd num.mark seg.mean chr
## [7] start end cyto.band
## <0 rows> (or 0-length row.names)
```

`head(rbd)`

```
## seg.id hds.median hds.sd num.mark seg.mean chr start end
## 1 1 0.12270 0.07103365 553 0.5339 chr1 762098 3440694
## 2 2 0.13615 0.05958364 5351 0.4673 chr1 3447666 49118903
## 3 3 0.29650 0.06771401 4272 -0.6061 chr1 49128694 121310027
## 4 8 0.25810 0.04683305 1188 1.0343 chr1 150418684 155954980
## 5 9 0.02815 0.04344431 6934 0.0513 chr1 155979184 247835485
## 6 10 0.28095 0.05170589 65 -0.6147 chr1 247875098 249210700
## cyto.band
## 1 p36.33
## 2 p36.32
## 3 p33
## 4 q21.3
## 5 q22
## 6 q44
```

A plot of R score and HDS at various ploidy states forms the branches of a BubbleTree plot which can be generated as follows. Normally, this function is called internally by the plotBubbles() function.

`drawBranches()`