Download BALLI R package

You can download the BALLI R package from this link: [Download]

Quick Start

This is an quick start manual of BALLI

require(BALLI)

1. Load Count Data

data <- data.frame(read.table("counts.txt"))

or make example count data

GenerateData <- function(nRow) {
    expr_mean <- runif(1,1,500)
    expr_size <- runif(1,1,50)
    expr <- rnbinom(20,mu=expr_mean,size=expr_size)
    return(expr)
}

data <- data.frame(t(sapply(1:10000,GenerateData)))
colnames(data) <- c(paste0("A",1:10),paste0("B",1:10))
rownames(data) <- paste0("gene",1:10000)
head(data)
##        A1  A2  A3  A4  A5  A6  A7  A8  A9 A10  B1  B2  B3  B4  B5  B6  B7
## gene1 436 216 405 297 542 912 377 295 769 353 322 337 704 638 271 713 281
## gene2 117 120  96 150 118  93 119 110  81 107 114 108 109  95 109  99 131
## gene3  24  59  41  24  47  38  31  39  58  29  23  60  27  31  36  32  39
## gene4 150 185 161 202 186 200 128 165 188 198 225 222 172 181 191 165 150
## gene5 448 375 430 591 443 435 500 586 522 509 356 368 343 377 437 576 392
## gene6 224 252 658 415  48  73 165 455 245 123  76 147 117 200 146 440 147
##        B8  B9 B10
## gene1 339 239 344
## gene2  97  80 117
## gene3  16  35  61
## gene4 146 109 169
## gene5 547 499 492
## gene6  93  86 121

2. Designate Group Information and Make Design Matrix

Group <- c(rep("A",10),rep("B",10))
Group
##  [1] "A" "A" "A" "A" "A" "A" "A" "A" "A" "A" "B" "B" "B" "B" "B" "B" "B"
## [18] "B" "B" "B"
design <- model.matrix(~Group, data = data)
head(design)
##   (Intercept) GroupB
## 1           1      0
## 2           1      0
## 3           1      0
## 4           1      0
## 5           1      0
## 6           1      0

3. Normalize Count Data

dge <- DGEList(counts=data, group=Group)
dge <- calcNormFactors(dge)
dge
## An object of class "DGEList"
## $counts
##        A1  A2  A3  A4  A5  A6  A7  A8  A9 A10  B1  B2  B3  B4  B5  B6  B7
## gene1 436 216 405 297 542 912 377 295 769 353 322 337 704 638 271 713 281
## gene2 117 120  96 150 118  93 119 110  81 107 114 108 109  95 109  99 131
## gene3  24  59  41  24  47  38  31  39  58  29  23  60  27  31  36  32  39
## gene4 150 185 161 202 186 200 128 165 188 198 225 222 172 181 191 165 150
## gene5 448 375 430 591 443 435 500 586 522 509 356 368 343 377 437 576 392
##        B8  B9 B10
## gene1 339 239 344
## gene2  97  80 117
## gene3  16  35  61
## gene4 146 109 169
## gene5 547 499 492
## 9995 more rows ...
## 
## $samples
##    group lib.size norm.factors
## A1     A  2510208    0.9991008
## A2     A  2509591    0.9994565
## A3     A  2517377    1.0004699
## A4     A  2518035    0.9935834
## A5     A  2497185    1.0033379
## 15 more rows ...

4. Estimate Technical Variance

tV <- tecVarEstim(dge,design)
tV
## An object of class "TecVarList"
## $targets
##    group lib.size norm.factors
## A1     A  2507951    0.9991008
## A2     A  2508227    0.9994565
## A3     A  2518560    1.0004699
## A4     A  2501878    0.9935834
## A5     A  2505520    1.0033379
## 15 more rows ...
## 
## $design
##   (Intercept) GroupB
## 1           1      0
## 2           1      0
## 3           1      0
## 4           1      0
## 5           1      0
## 15 more rows ...
## 
## $logcpm
##             A1       A2       A3       A4       A5       A6       A7
## gene1 7.442502 6.429888 7.330073 6.892518 7.757703 8.505893 7.234748
## gene2 5.546935 5.583225 5.256131 5.908204 5.560583 5.215641 5.573214
## gene3 3.273404 4.562076 4.033760 3.276865 4.237125 3.930001 3.641141
## gene4 5.904712 6.206662 6.000565 6.336980 6.215984 6.318267 5.678184
## gene5 7.481650 7.225040 7.416436 7.884611 7.466865 7.438308 7.641877
##             A8       A9      A10       B1       B2       B3       B4
## gene1 6.869452 8.260263 7.139119 7.007537 7.070223 8.129495 7.994749
## gene2 5.448307 5.017251 5.419405 5.511548 5.430773 5.441048 5.250411
## gene3 3.958334 4.537142 3.544929 3.214639 4.585441 3.437770 3.642530
## gene4 6.032172 6.229460 6.305750 6.490883 6.468588 6.097915 6.178605
## gene5 7.859027 7.701551 7.666804 7.152247 7.197090 7.092668 7.236147
##             B5       B6       B7       B8       B9      B10
## gene1 6.762875 8.149757 6.803273 7.081146 6.585307 7.101434
## gene2 5.450877 5.304492 5.703743 5.278564 5.009342 5.547564
## gene3 3.859270 3.682735 3.962217 2.697287 3.822427 4.610757
## gene4 6.258710 6.040002 5.898789 5.867232 5.454410 6.077132
## gene5 7.451713 7.842044 7.283192 7.770997 7.646556 7.617368
## 9995 more rows ...
## 
## $tecVar
##                A1          A2          A3          A4          A5
## gene1 0.002333415 0.002333161 0.002323676 0.002339027 0.002335658
## gene2 0.008848690 0.008847721 0.008811623 0.008870049 0.008857226
## gene3 0.025564621 0.025561853 0.025458675 0.025625668 0.025589018
## gene4 0.005577448 0.005576836 0.005554022 0.005590947 0.005582843
## gene5 0.002045440 0.002045217 0.002036905 0.002050358 0.002047406
##                A6          A7          A8          A9         A10
## gene1 0.002332000 0.002336433 0.002317698 0.002332555 0.002335152
## gene2 0.008843304 0.008860174 0.008788874 0.008845415 0.008855300
## gene3 0.025549225 0.025597443 0.025393648 0.025555262 0.025583514
## gene4 0.005574044 0.005584705 0.005539645 0.005575378 0.005581625
## gene5 0.002044200 0.002048084 0.002031667 0.002044686 0.002046962
##                B1          B2          B3          B4          B5
## gene1 0.002533131 0.002527996 0.002522796 0.002535341 0.002539923
## gene2 0.009234468 0.009215687 0.009196670 0.009242552 0.009259311
## gene3 0.028288451 0.028231588 0.028174008 0.028312928 0.028363667
## gene4 0.005740015 0.005728305 0.005716448 0.005745055 0.005755505
## gene5 0.002269109 0.002264510 0.002259853 0.002271088 0.002275192
##                B6          B7          B8          B9         B10
## gene1 0.002526164 0.002519349 0.002532156 0.002546106 0.002530730
## gene2 0.009208989 0.009184063 0.009230903 0.009281927 0.009225686
## gene3 0.028211306 0.028135833 0.028277658 0.028432089 0.028261863
## gene4 0.005724129 0.005708588 0.005737792 0.005769605 0.005734540
## gene5 0.002262869 0.002256765 0.002268236 0.002280730 0.002266958
## 9995 more rows ...

5. Fit BALLI and See Top Significant Genes

fit <- balliFit(tV,numCores=2)
topGenes(fit)
##               logFC       pBALLI adjpBALLI         pLLI   adjpLLI
## gene5911  0.4001660 4.731706e-05 0.4427909 1.600156e-05 0.1600156
## gene1396  0.6442930 8.855818e-05 0.4427909 3.215682e-05 0.1607841
## gene4465  0.4944188 2.375227e-04 0.6231002 9.867546e-05 0.2675133
## gene4184 -0.6179714 2.594315e-04 0.6231002 1.070053e-04 0.2675133
## gene474  -0.4537314 3.893744e-04 0.6231002 1.684807e-04 0.2935659
## gene4218 -0.3398756 4.625226e-04 0.6231002 2.040532e-04 0.2935659
## gene8847  0.4086070 5.930761e-04 0.6231002 2.694820e-04 0.2935659
## gene6788 -0.6267539 6.145256e-04 0.6231002 2.803082e-04 0.2935659
## gene37    0.3732051 7.004653e-04 0.6231002 3.259825e-04 0.2935659
## gene6093 -0.3885954 7.113118e-04 0.6231002 3.300424e-04 0.2935659