|
BufferedMatrix.Rcheck/tests_i386/objectTesting.Rout
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(BufferedMatrix);library.dynam("BufferedMatrix","BufferedMatrix", .libPaths());
Attaching package: 'BufferedMatrix'
The following objects are masked from 'package:base':
colMeans, colSums, rowMeans, rowSums
>
>
> ### this is used to control how many repetitions in something below
> ### higher values result in more checks.
> nreps <-100 ##20000
>
>
> ## test creation and some simple assignments and subsetting operations
>
> ## first on single elements
> tmp <- createBufferedMatrix(1000,10)
>
> tmp[10,5]
[1] 0
> tmp[10,5] <- 10
> tmp[10,5]
[1] 10
> tmp[10,5] <- 12.445
> tmp[10,5]
[1] 12.445
>
>
>
> ## now testing accessing multiple elements
> tmp2 <- createBufferedMatrix(10,20)
>
>
> tmp2[3,1] <- 51.34
> tmp2[9,2] <- 9.87654
> tmp2[,1:2]
[,1] [,2]
[1,] 0.00 0.00000
[2,] 0.00 0.00000
[3,] 51.34 0.00000
[4,] 0.00 0.00000
[5,] 0.00 0.00000
[6,] 0.00 0.00000
[7,] 0.00 0.00000
[8,] 0.00 0.00000
[9,] 0.00 9.87654
[10,] 0.00 0.00000
> tmp2[,-(3:20)]
[,1] [,2]
[1,] 0.00 0.00000
[2,] 0.00 0.00000
[3,] 51.34 0.00000
[4,] 0.00 0.00000
[5,] 0.00 0.00000
[6,] 0.00 0.00000
[7,] 0.00 0.00000
[8,] 0.00 0.00000
[9,] 0.00 9.87654
[10,] 0.00 0.00000
> tmp2[3,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 51.34 0 0 0 0 0 0 0 0 0 0 0 0
[,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] 0 0 0 0 0 0 0
> tmp2[-3,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[2,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[3,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[4,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[5,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[6,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[7,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[8,] 0 9.87654 0 0 0 0 0 0 0 0 0 0 0
[9,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] 0 0 0 0 0 0 0
[2,] 0 0 0 0 0 0 0
[3,] 0 0 0 0 0 0 0
[4,] 0 0 0 0 0 0 0
[5,] 0 0 0 0 0 0 0
[6,] 0 0 0 0 0 0 0
[7,] 0 0 0 0 0 0 0
[8,] 0 0 0 0 0 0 0
[9,] 0 0 0 0 0 0 0
> tmp2[2,1:3]
[,1] [,2] [,3]
[1,] 0 0 0
> tmp2[3:9,1:3]
[,1] [,2] [,3]
[1,] 51.34 0.00000 0
[2,] 0.00 0.00000 0
[3,] 0.00 0.00000 0
[4,] 0.00 0.00000 0
[5,] 0.00 0.00000 0
[6,] 0.00 0.00000 0
[7,] 0.00 9.87654 0
> tmp2[-4,-4]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[2,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[3,] 51.34 0.00000 0 0 0 0 0 0 0 0 0 0 0
[4,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[5,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[6,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[7,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[8,] 0.00 9.87654 0 0 0 0 0 0 0 0 0 0 0
[9,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[,14] [,15] [,16] [,17] [,18] [,19]
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
[4,] 0 0 0 0 0 0
[5,] 0 0 0 0 0 0
[6,] 0 0 0 0 0 0
[7,] 0 0 0 0 0 0
[8,] 0 0 0 0 0 0
[9,] 0 0 0 0 0 0
>
> ## now testing accessing/assigning multiple elements
> tmp3 <- createBufferedMatrix(10,10)
>
> for (i in 1:10){
+ for (j in 1:10){
+ tmp3[i,j] <- (j-1)*10 + i
+ }
+ }
>
> tmp3[2:4,2:4]
[,1] [,2] [,3]
[1,] 12 22 32
[2,] 13 23 33
[3,] 14 24 34
> tmp3[c(-10),c(2:4,2:4,10,1,2,1:10,10:1)]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 11 21 31 11 21 31 91 1 11 1 11 21 31
[2,] 12 22 32 12 22 32 92 2 12 2 12 22 32
[3,] 13 23 33 13 23 33 93 3 13 3 13 23 33
[4,] 14 24 34 14 24 34 94 4 14 4 14 24 34
[5,] 15 25 35 15 25 35 95 5 15 5 15 25 35
[6,] 16 26 36 16 26 36 96 6 16 6 16 26 36
[7,] 17 27 37 17 27 37 97 7 17 7 17 27 37
[8,] 18 28 38 18 28 38 98 8 18 8 18 28 38
[9,] 19 29 39 19 29 39 99 9 19 9 19 29 39
[,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
[1,] 41 51 61 71 81 91 91 81 71 61 51 41
[2,] 42 52 62 72 82 92 92 82 72 62 52 42
[3,] 43 53 63 73 83 93 93 83 73 63 53 43
[4,] 44 54 64 74 84 94 94 84 74 64 54 44
[5,] 45 55 65 75 85 95 95 85 75 65 55 45
[6,] 46 56 66 76 86 96 96 86 76 66 56 46
[7,] 47 57 67 77 87 97 97 87 77 67 57 47
[8,] 48 58 68 78 88 98 98 88 78 68 58 48
[9,] 49 59 69 79 89 99 99 89 79 69 59 49
[,26] [,27] [,28] [,29]
[1,] 31 21 11 1
[2,] 32 22 12 2
[3,] 33 23 13 3
[4,] 34 24 14 4
[5,] 35 25 15 5
[6,] 36 26 16 6
[7,] 37 27 17 7
[8,] 38 28 18 8
[9,] 39 29 19 9
> tmp3[-c(1:5),-c(6:10)]
[,1] [,2] [,3] [,4] [,5]
[1,] 6 16 26 36 46
[2,] 7 17 27 37 47
[3,] 8 18 28 38 48
[4,] 9 19 29 39 49
[5,] 10 20 30 40 50
>
> ## assignment of whole columns
> tmp3[,1] <- c(1:10*100.0)
> tmp3[,1:2] <- tmp3[,1:2]*100
> tmp3[,1:2] <- tmp3[,2:1]
> tmp3[,1:2]
[,1] [,2]
[1,] 1100 1e+04
[2,] 1200 2e+04
[3,] 1300 3e+04
[4,] 1400 4e+04
[5,] 1500 5e+04
[6,] 1600 6e+04
[7,] 1700 7e+04
[8,] 1800 8e+04
[9,] 1900 9e+04
[10,] 2000 1e+05
>
>
> tmp3[,-1] <- tmp3[,1:9]
> tmp3[,1:10]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1100 1100 1e+04 21 31 41 51 61 71 81
[2,] 1200 1200 2e+04 22 32 42 52 62 72 82
[3,] 1300 1300 3e+04 23 33 43 53 63 73 83
[4,] 1400 1400 4e+04 24 34 44 54 64 74 84
[5,] 1500 1500 5e+04 25 35 45 55 65 75 85
[6,] 1600 1600 6e+04 26 36 46 56 66 76 86
[7,] 1700 1700 7e+04 27 37 47 57 67 77 87
[8,] 1800 1800 8e+04 28 38 48 58 68 78 88
[9,] 1900 1900 9e+04 29 39 49 59 69 79 89
[10,] 2000 2000 1e+05 30 40 50 60 70 80 90
>
> tmp3[,1:2] <- rep(1,10)
> tmp3[,1:2] <- rep(1,20)
> tmp3[,1:2] <- matrix(c(1:5),1,5)
>
> tmp3[,-c(1:8)] <- matrix(c(1:5),1,5)
>
> tmp3[1,] <- 1:10
> tmp3[1,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 2 3 4 5 6 7 8 9 10
> tmp3[-1,] <- c(1,2)
> tmp3[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 2 3 4 5 6 7 8 9 10
[2,] 1 2 1 2 1 2 1 2 1 2
[3,] 2 1 2 1 2 1 2 1 2 1
[4,] 1 2 1 2 1 2 1 2 1 2
[5,] 2 1 2 1 2 1 2 1 2 1
[6,] 1 2 1 2 1 2 1 2 1 2
[7,] 2 1 2 1 2 1 2 1 2 1
[8,] 1 2 1 2 1 2 1 2 1 2
[9,] 2 1 2 1 2 1 2 1 2 1
[10,] 1 2 1 2 1 2 1 2 1 2
> tmp3[-c(1:8),] <- matrix(c(1:5),1,5)
> tmp3[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 2 3 4 5 6 7 8 9 10
[2,] 1 2 1 2 1 2 1 2 1 2
[3,] 2 1 2 1 2 1 2 1 2 1
[4,] 1 2 1 2 1 2 1 2 1 2
[5,] 2 1 2 1 2 1 2 1 2 1
[6,] 1 2 1 2 1 2 1 2 1 2
[7,] 2 1 2 1 2 1 2 1 2 1
[8,] 1 2 1 2 1 2 1 2 1 2
[9,] 1 3 5 2 4 1 3 5 2 4
[10,] 2 4 1 3 5 2 4 1 3 5
>
>
> tmp3[1:2,1:2] <- 5555.04
> tmp3[-(1:2),1:2] <- 1234.56789
>
>
>
> ## testing accessors for the directory and prefix
> directory(tmp3)
[1] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386"
> prefix(tmp3)
[1] "BM"
>
> ## testing if we can remove these objects
> rm(tmp, tmp2, tmp3)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 408056 12.5 849838 26 632071 19.3
Vcells 463676 3.6 8388608 64 1454215 11.1
>
>
>
>
> ##
> ## checking reads
> ##
>
> tmp2 <- createBufferedMatrix(10,20)
>
> test.sample <- rnorm(10*20)
>
> tmp2[1:10,1:20] <- test.sample
>
> test.matrix <- matrix(test.sample,10,20)
>
> ## testing reads
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ which.col <- sample(1:20,1)
+ if (tmp2[which.row,which.col] != test.matrix[which.row,which.col]){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,1)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> date()
[1] "Wed Oct 16 02:22:02 2019"
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
> date()
[1] "Wed Oct 16 02:22:03 2019"
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ which.col <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[which.row,which.col] == test.matrix[which.row,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
>
>
> RowMode(tmp2)
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ which.col <- sample(1:20,1)
+ if (tmp2[which.row,which.col] != test.matrix[which.row,which.col]){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,1)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,5,replace=TRUE)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> date()
[1] "Wed Oct 16 02:22:05 2019"
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ which.col <- sample(1:20,5,replace=TRUE)
+ if (!all(tmp2[which.row,which.col] == test.matrix[which.row,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
> date()
[1] "Wed Oct 16 02:22:06 2019"
>
> ColMode(tmp2)
>
>
>
> ### Now testing assignments
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+
+ new.data <- rnorm(20)
+ tmp2[which.row,] <- new.data
+ test.matrix[which.row,] <- new.data
+ if (rep > 1){
+ if (!all(tmp2[prev.row,] == test.matrix[prev.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.row <- which.row
+
+ }
>
>
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,1)
+ new.data <- rnorm(10)
+ tmp2[,which.col] <- new.data
+ test.matrix[,which.col]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[,prev.col] == test.matrix[,prev.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.col <- which.col
+ }
>
>
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,5,replace=TRUE)
+ new.data <- matrix(rnorm(50),5,10)
+ tmp2[,which.col] <- new.data
+ test.matrix[,which.col]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[,prev.col] == test.matrix[,prev.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.col <- which.col
+ }
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ new.data <- matrix(rnorm(50),5,10)
+ tmp2[which.row,] <- new.data
+ test.matrix[which.row,]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[prev.row,] == test.matrix[prev.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.row <- which.row
+ }
>
>
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ which.col <- sample(1:20,5,replace=TRUE)
+ new.data <- matrix(rnorm(25),5,5)
+ tmp2[which.row,which.col] <- new.data
+ test.matrix[which.row,which.col]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[prev.row,prev.col] == test.matrix[prev.row,prev.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.row <- which.row
+ prev.col <- which.col
+ }
>
>
>
>
> ###
> ###
> ### testing some more functions
> ###
>
>
>
> ## duplication function
> tmp5 <- duplicate(tmp2)
>
> # making sure really did copy everything.
> tmp5[1,1] <- tmp5[1,1] +100.00
>
> if (tmp5[1,1] == tmp2[1,1]){
+ stop("Problem with duplication")
+ }
>
>
>
>
> ### testing elementwise applying of functions
>
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 100.4066299 -0.5506606 0.2058723 0.1999109
[2,] -0.2621874 -0.3624380 -0.9164488 0.3066757
[3,] 2.0804476 -0.3679892 -0.8401530 0.2995073
[4,] -0.1585063 -0.1177263 -0.7865227 0.5306903
> ewApply(tmp5,abs)
BufferedMatrix object
Matrix size: 10 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 1.6 Kilobytes.
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 100.4066299 0.5506606 0.2058723 0.1999109
[2,] 0.2621874 0.3624380 0.9164488 0.3066757
[3,] 2.0804476 0.3679892 0.8401530 0.2995073
[4,] 0.1585063 0.1177263 0.7865227 0.5306903
> ewApply(tmp5,sqrt)
BufferedMatrix object
Matrix size: 10 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 1.6 Kilobytes.
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 10.0203109 0.7420651 0.4537315 0.4471139
[2,] 0.5120424 0.6020282 0.9573133 0.5537831
[3,] 1.4423757 0.6066211 0.9165986 0.5472726
[4,] 0.3981285 0.3431127 0.8868611 0.7284849
>
> my.function <- function(x,power){
+ (x+5)^power
+ }
>
> ewApply(tmp5,my.function,power=2)
BufferedMatrix object
Matrix size: 10 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 1.6 Kilobytes.
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 225.60974 32.97131 29.74319 29.67105
[2,] 30.38261 31.38272 35.48958 30.84451
[3,] 41.50420 31.43420 35.00614 30.77223
[4,] 29.13979 28.54885 34.65513 32.81554
>
>
>
> ## testing functions that elementwise transform the matrix
> sqrt(tmp5)
> exp(tmp5)
> log(tmp5,2)
> pow(tmp5,2)
>
>
>
>
>
> ## testing functions that apply to entire matrix
> Max(tmp5)
[1] 469.5771
> Min(tmp5)
[1] 53.75224
> mean(tmp5)
[1] 72.28792
> Sum(tmp5)
[1] 14457.58
> Var(tmp5)
[1] 870.5949
>
>
> ## testing functions applied to rows or columns
>
> rowMeans(tmp5)
[1] 89.83969 68.78245 71.83764 69.48594 71.36174 71.24699 70.11096 69.51445
[9] 72.29990 68.39943
> rowSums(tmp5)
[1] 1796.794 1375.649 1436.753 1389.719 1427.235 1424.940 1402.219 1390.289
[9] 1445.998 1367.989
> rowVars(tmp5)
[1] 8103.95653 73.70082 74.29810 82.40583 59.21376 100.22005
[7] 66.06861 62.75426 81.27137 37.71039
> rowSd(tmp5)
[1] 90.021978 8.584918 8.619635 9.077766 7.695048 10.010997 8.128260
[8] 7.921758 9.015063 6.140878
> rowMax(tmp5)
[1] 469.57711 87.30627 86.90799 89.38443 84.50875 98.41030 85.39286
[8] 79.27917 88.04839 78.57167
> rowMin(tmp5)
[1] 53.75224 54.02930 54.90862 58.17457 60.13160 54.78245 53.82198 55.51805
[9] 60.46000 56.45756
>
> colMeans(tmp5)
[1] 107.93433 66.32285 70.99239 67.51147 73.44786 78.27234 71.67350
[8] 68.51348 71.04995 70.87003 72.30067 66.12586 65.52881 74.46126
[15] 67.58245 66.70647 74.69351 69.54872 69.07154 73.15086
> colSums(tmp5)
[1] 1079.3433 663.2285 709.9239 675.1147 734.4786 782.7234 716.7350
[8] 685.1348 710.4995 708.7003 723.0067 661.2586 655.2881 744.6126
[15] 675.8245 667.0647 746.9351 695.4872 690.7154 731.5086
> colVars(tmp5)
[1] 16201.75409 61.12270 41.93588 37.45995 140.29720 114.97181
[7] 100.45230 47.82646 45.76978 83.59857 78.83226 57.25213
[13] 72.36045 101.57017 34.87793 113.46015 34.10971 56.48038
[19] 46.58712 54.52365
> colSd(tmp5)
[1] 127.286111 7.818101 6.475792 6.120453 11.844712 10.722491
[7] 10.022589 6.915668 6.765337 9.143225 8.878753 7.566514
[13] 8.506495 10.078203 5.905754 10.651768 5.840352 7.515343
[19] 6.825476 7.384013
> colMax(tmp5)
[1] 469.57711 85.39286 78.82561 81.40158 98.41030 96.09250 87.26537
[8] 84.15594 79.27917 82.57303 88.04839 78.89258 83.17082 86.90799
[15] 78.98772 89.38443 86.38916 81.85164 78.28629 83.15962
> colMin(tmp5)
[1] 60.65066 55.71603 60.16564 60.03565 58.17457 61.58546 60.18254 59.85971
[9] 59.44147 53.82198 53.75224 54.78245 56.45756 59.84856 60.53642 54.02930
[17] 68.04079 59.23594 55.51805 60.86853
>
>
> ### setting a random element to NA and then testing with na.rm=TRUE or na.rm=FALSE (The default)
>
>
> which.row <- sample(1:10,1,replace=TRUE)
> which.col <- sample(1:20,1,replace=TRUE)
>
> tmp5[which.row,which.col] <- NA
>
> Max(tmp5)
[1] NA
> Min(tmp5)
[1] NA
> mean(tmp5)
[1] NA
> Sum(tmp5)
[1] NA
> Var(tmp5)
[1] NA
>
> rowMeans(tmp5)
[1] 89.83969 68.78245 71.83764 69.48594 71.36174 NA 70.11096 69.51445
[9] 72.29990 68.39943
> rowSums(tmp5)
[1] 1796.794 1375.649 1436.753 1389.719 1427.235 NA 1402.219 1390.289
[9] 1445.998 1367.989
> rowVars(tmp5)
[1] 8103.95653 73.70082 74.29810 82.40583 59.21376 105.75118
[7] 66.06861 62.75426 81.27137 37.71039
> rowSd(tmp5)
[1] 90.021978 8.584918 8.619635 9.077766 7.695048 10.283539 8.128260
[8] 7.921758 9.015063 6.140878
> rowMax(tmp5)
[1] 469.57711 87.30627 86.90799 89.38443 84.50875 NA 85.39286
[8] 79.27917 88.04839 78.57167
> rowMin(tmp5)
[1] 53.75224 54.02930 54.90862 58.17457 60.13160 NA 53.82198 55.51805
[9] 60.46000 56.45756
>
> colMeans(tmp5)
[1] 107.93433 66.32285 70.99239 NA 73.44786 78.27234 71.67350
[8] 68.51348 71.04995 70.87003 72.30067 66.12586 65.52881 74.46126
[15] 67.58245 66.70647 74.69351 69.54872 69.07154 73.15086
> colSums(tmp5)
[1] 1079.3433 663.2285 709.9239 NA 734.4786 782.7234 716.7350
[8] 685.1348 710.4995 708.7003 723.0067 661.2586 655.2881 744.6126
[15] 675.8245 667.0647 746.9351 695.4872 690.7154 731.5086
> colVars(tmp5)
[1] 16201.75409 61.12270 41.93588 NA 140.29720 114.97181
[7] 100.45230 47.82646 45.76978 83.59857 78.83226 57.25213
[13] 72.36045 101.57017 34.87793 113.46015 34.10971 56.48038
[19] 46.58712 54.52365
> colSd(tmp5)
[1] 127.286111 7.818101 6.475792 NA 11.844712 10.722491
[7] 10.022589 6.915668 6.765337 9.143225 8.878753 7.566514
[13] 8.506495 10.078203 5.905754 10.651768 5.840352 7.515343
[19] 6.825476 7.384013
> colMax(tmp5)
[1] 469.57711 85.39286 78.82561 NA 98.41030 96.09250 87.26537
[8] 84.15594 79.27917 82.57303 88.04839 78.89258 83.17082 86.90799
[15] 78.98772 89.38443 86.38916 81.85164 78.28629 83.15962
> colMin(tmp5)
[1] 60.65066 55.71603 60.16564 NA 58.17457 61.58546 60.18254 59.85971
[9] 59.44147 53.82198 53.75224 54.78245 56.45756 59.84856 60.53642 54.02930
[17] 68.04079 59.23594 55.51805 60.86853
>
> Max(tmp5,na.rm=TRUE)
[1] 469.5771
> Min(tmp5,na.rm=TRUE)
[1] 53.75224
> mean(tmp5,na.rm=TRUE)
[1] 72.28917
> Sum(tmp5,na.rm=TRUE)
[1] 14385.54
> Var(tmp5,na.rm=TRUE)
[1] 874.9916
>
> rowMeans(tmp5,na.rm=TRUE)
[1] 89.83969 68.78245 71.83764 69.48594 71.36174 71.20532 70.11096 69.51445
[9] 72.29990 68.39943
> rowSums(tmp5,na.rm=TRUE)
[1] 1796.794 1375.649 1436.753 1389.719 1427.235 1352.901 1402.219 1390.289
[9] 1445.998 1367.989
> rowVars(tmp5,na.rm=TRUE)
[1] 8103.95653 73.70082 74.29810 82.40583 59.21376 105.75118
[7] 66.06861 62.75426 81.27137 37.71039
> rowSd(tmp5,na.rm=TRUE)
[1] 90.021978 8.584918 8.619635 9.077766 7.695048 10.283539 8.128260
[8] 7.921758 9.015063 6.140878
> rowMax(tmp5,na.rm=TRUE)
[1] 469.57711 87.30627 86.90799 89.38443 84.50875 98.41030 85.39286
[8] 79.27917 88.04839 78.57167
> rowMin(tmp5,na.rm=TRUE)
[1] 53.75224 54.02930 54.90862 58.17457 60.13160 54.78245 53.82198 55.51805
[9] 60.46000 56.45756
>
> colMeans(tmp5,na.rm=TRUE)
[1] 107.93433 66.32285 70.99239 67.00845 73.44786 78.27234 71.67350
[8] 68.51348 71.04995 70.87003 72.30067 66.12586 65.52881 74.46126
[15] 67.58245 66.70647 74.69351 69.54872 69.07154 73.15086
> colSums(tmp5,na.rm=TRUE)
[1] 1079.3433 663.2285 709.9239 603.0760 734.4786 782.7234 716.7350
[8] 685.1348 710.4995 708.7003 723.0067 661.2586 655.2881 744.6126
[15] 675.8245 667.0647 746.9351 695.4872 690.7154 731.5086
> colVars(tmp5,na.rm=TRUE)
[1] 16201.75409 61.12270 41.93588 39.29580 140.29720 114.97181
[7] 100.45230 47.82646 45.76978 83.59857 78.83226 57.25213
[13] 72.36045 101.57017 34.87793 113.46015 34.10971 56.48038
[19] 46.58712 54.52365
> colSd(tmp5,na.rm=TRUE)
[1] 127.286111 7.818101 6.475792 6.268636 11.844712 10.722491
[7] 10.022589 6.915668 6.765337 9.143225 8.878753 7.566514
[13] 8.506495 10.078203 5.905754 10.651768 5.840352 7.515343
[19] 6.825476 7.384013
> colMax(tmp5,na.rm=TRUE)
[1] 469.57711 85.39286 78.82561 81.40158 98.41030 96.09250 87.26537
[8] 84.15594 79.27917 82.57303 88.04839 78.89258 83.17082 86.90799
[15] 78.98772 89.38443 86.38916 81.85164 78.28629 83.15962
> colMin(tmp5,na.rm=TRUE)
[1] 60.65066 55.71603 60.16564 60.03565 58.17457 61.58546 60.18254 59.85971
[9] 59.44147 53.82198 53.75224 54.78245 56.45756 59.84856 60.53642 54.02930
[17] 68.04079 59.23594 55.51805 60.86853
>
> # now set an entire row to NA
>
> tmp5[which.row,] <- NA
> rowMeans(tmp5,na.rm=TRUE)
[1] 89.83969 68.78245 71.83764 69.48594 71.36174 NaN 70.11096 69.51445
[9] 72.29990 68.39943
> rowSums(tmp5,na.rm=TRUE)
[1] 1796.794 1375.649 1436.753 1389.719 1427.235 0.000 1402.219 1390.289
[9] 1445.998 1367.989
> rowVars(tmp5,na.rm=TRUE)
[1] 8103.95653 73.70082 74.29810 82.40583 59.21376 NA
[7] 66.06861 62.75426 81.27137 37.71039
> rowSd(tmp5,na.rm=TRUE)
[1] 90.021978 8.584918 8.619635 9.077766 7.695048 NA 8.128260
[8] 7.921758 9.015063 6.140878
> rowMax(tmp5,na.rm=TRUE)
[1] 469.57711 87.30627 86.90799 89.38443 84.50875 NA 85.39286
[8] 79.27917 88.04839 78.57167
> rowMin(tmp5,na.rm=TRUE)
[1] 53.75224 54.02930 54.90862 58.17457 60.13160 NA 53.82198 55.51805
[9] 60.46000 56.45756
>
>
> # now set an entire col to NA
>
>
> tmp5[,which.col] <- NA
> colMeans(tmp5,na.rm=TRUE)
[1] 112.90021 67.50139 70.42746 NaN 70.67425 78.29395 70.06102
[8] 68.41777 70.18828 70.99477 72.57770 67.38624 65.94002 75.39309
[15] 67.62575 67.14852 74.93608 68.97848 68.54417 73.07394
> colSums(tmp5,na.rm=TRUE)
[1] 1016.1019 607.5125 633.8471 0.0000 636.0683 704.6455 630.5492
[8] 615.7600 631.6945 638.9529 653.1993 606.4762 593.4602 678.5378
[15] 608.6317 604.3367 674.4248 620.8063 616.8975 657.6655
> colVars(tmp5,na.rm=TRUE)
[1] 17949.54801 53.13738 43.58740 NA 71.28943 129.33803
[7] 83.75765 53.70172 43.13819 93.87333 87.82291 46.53739
[13] 79.50322 104.49786 39.21659 125.44423 37.71147 59.88214
[19] 49.28165 61.27255
> colSd(tmp5,na.rm=TRUE)
[1] 133.975923 7.289539 6.602075 NA 8.443307 11.372688
[7] 9.151921 7.328146 6.567967 9.688825 9.371388 6.821832
[13] 8.916458 10.222419 6.262315 11.200189 6.140966 7.738355
[19] 7.020089 7.827679
> colMax(tmp5,na.rm=TRUE)
[1] 469.57711 85.39286 78.82561 -Inf 83.95236 96.09250 87.26537
[8] 84.15594 79.27917 82.57303 88.04839 78.89258 83.17082 86.90799
[15] 78.98772 89.38443 86.38916 81.85164 78.28629 83.15962
> colMin(tmp5,na.rm=TRUE)
[1] 60.65066 59.42070 60.16564 Inf 58.17457 61.58546 60.18254 59.85971
[9] 59.44147 53.82198 53.75224 58.67604 56.45756 59.84856 60.53642 54.02930
[17] 68.04079 59.23594 55.51805 60.86853
>
>
>
>
> copymatrix <- matrix(rnorm(200,150,15),10,20)
>
> tmp5[1:10,1:20] <- copymatrix
> which.row <- 3
> which.col <- 1
> cat(which.row," ",which.col,"\n")
3 1
> tmp5[which.row,which.col] <- NA
> copymatrix[which.row,which.col] <- NA
>
> rowVars(tmp5,na.rm=TRUE)
[1] 202.56000 163.77912 73.73833 234.10182 354.28590 238.83620 299.78362
[8] 329.67869 250.18234 316.35725
> apply(copymatrix,1,var,na.rm=TRUE)
[1] 202.56000 163.77912 73.73833 234.10182 354.28590 238.83620 299.78362
[8] 329.67869 250.18234 316.35725
>
>
>
> copymatrix <- matrix(rnorm(200,150,15),10,20)
>
> tmp5[1:10,1:20] <- copymatrix
> which.row <- 1
> which.col <- 3
> cat(which.row," ",which.col,"\n")
1 3
> tmp5[which.row,which.col] <- NA
> copymatrix[which.row,which.col] <- NA
>
> colVars(tmp5,na.rm=TRUE)-apply(copymatrix,2,var,na.rm=TRUE)
[1] 2.842171e-14 -9.947598e-14 -2.842171e-14 -1.705303e-13 -2.842171e-14
[6] 2.842171e-14 -2.842171e-14 -8.526513e-14 8.526513e-14 2.842171e-14
[11] 5.684342e-14 -1.989520e-13 0.000000e+00 -1.136868e-13 8.526513e-14
[16] 0.000000e+00 -1.136868e-13 3.410605e-13 2.842171e-14 0.000000e+00
>
>
>
>
>
>
>
>
>
>
> ## making sure these things agree
> ##
> ## first when there is no NA
>
>
>
> agree.checks <- function(buff.matrix,r.matrix,err.tol=1e-10){
+
+ if (Max(buff.matrix,na.rm=TRUE) != max(r.matrix,na.rm=TRUE)){
+ stop("No agreement in Max")
+ }
+
+
+ if (Min(buff.matrix,na.rm=TRUE) != min(r.matrix,na.rm=TRUE)){
+ stop("No agreement in Min")
+ }
+
+
+ if (abs(Sum(buff.matrix,na.rm=TRUE)- sum(r.matrix,na.rm=TRUE)) > err.tol){
+
+ cat(Sum(buff.matrix,na.rm=TRUE),"\n")
+ cat(sum(r.matrix,na.rm=TRUE),"\n")
+ cat(Sum(buff.matrix,na.rm=TRUE) - sum(r.matrix,na.rm=TRUE),"\n")
+
+ stop("No agreement in Sum")
+ }
+
+ if (abs(mean(buff.matrix,na.rm=TRUE) - mean(r.matrix,na.rm=TRUE)) > err.tol){
+ stop("No agreement in mean")
+ }
+
+
+ if(abs(Var(buff.matrix,na.rm=TRUE) - var(as.vector(r.matrix),na.rm=TRUE)) > err.tol){
+ stop("No agreement in Var")
+ }
+
+
+
+ if(any(abs(rowMeans(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,mean,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in rowMeans")
+ }
+
+
+ if(any(abs(colMeans(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,mean,na.rm=TRUE))> err.tol,na.rm=TRUE)){
+ stop("No agreement in colMeans")
+ }
+
+
+ if(any(abs(rowSums(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,sum,na.rm=TRUE))> err.tol,na.rm=TRUE)){
+ stop("No agreement in rowSums")
+ }
+
+
+ if(any(abs(colSums(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,sum,na.rm=TRUE))> err.tol,na.rm=TRUE)){
+ stop("No agreement in colSums")
+ }
+
+ ### this is to get around the fact that R doesn't like to compute NA on an entire vector of NA when
+ ### computing variance
+ my.Var <- function(x,na.rm=FALSE){
+ if (all(is.na(x))){
+ return(NA)
+ } else {
+ var(x,na.rm=na.rm)
+ }
+
+ }
+
+ if(any(abs(rowVars(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,my.Var,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in rowVars")
+ }
+
+
+ if(any(abs(colVars(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,my.Var,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in rowVars")
+ }
+
+
+ if(any(abs(rowMax(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,max,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMax")
+ }
+
+
+ if(any(abs(colMax(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,max,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMax")
+ }
+
+
+
+ if(any(abs(rowMin(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,min,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMin")
+ }
+
+
+ if(any(abs(colMin(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,min,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMin")
+ }
+
+ if(any(abs(colMedians(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,median,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMedian")
+ }
+
+ if(any(abs(colRanges(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,range,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colRanges")
+ }
+
+
+
+ }
>
>
>
>
>
>
>
>
>
> for (rep in 1:20){
+ copymatrix <- matrix(rnorm(200,150,15),10,20)
+
+ tmp5[1:10,1:20] <- copymatrix
+
+
+ agree.checks(tmp5,copymatrix)
+
+ ## now lets assign some NA values and check agreement
+
+ which.row <- sample(1:10,1,replace=TRUE)
+ which.col <- sample(1:20,1,replace=TRUE)
+
+ cat(which.row," ",which.col,"\n")
+
+ tmp5[which.row,which.col] <- NA
+ copymatrix[which.row,which.col] <- NA
+
+ agree.checks(tmp5,copymatrix)
+
+ ## make an entire row NA
+ tmp5[which.row,] <- NA
+ copymatrix[which.row,] <- NA
+
+
+ agree.checks(tmp5,copymatrix)
+
+ ### also make an entire col NA
+ tmp5[,which.col] <- NA
+ copymatrix[,which.col] <- NA
+
+ agree.checks(tmp5,copymatrix)
+
+ ### now make 1 element non NA with NA in the rest of row and column
+
+ tmp5[which.row,which.col] <- rnorm(1,150,15)
+ copymatrix[which.row,which.col] <- tmp5[which.row,which.col]
+
+ agree.checks(tmp5,copymatrix)
+ }
9 3
9 18
2 2
4 14
1 15
9 19
2 15
6 5
7 16
8 17
9 18
10 15
2 20
3 10
5 3
6 16
2 15
4 3
2 6
6 15
There were 50 or more warnings (use warnings() to see the first 50)
>
>
> ### now test 1 by n and n by 1 matrix
>
>
> err.tol <- 1e-12
>
> rm(tmp5)
>
> dataset1 <- rnorm(100)
> dataset2 <- rnorm(100)
>
> tmp <- createBufferedMatrix(1,100)
> tmp[1,] <- dataset1
>
> tmp2 <- createBufferedMatrix(100,1)
> tmp2[,1] <- dataset2
>
>
>
>
>
> Max(tmp)
[1] 2.46405
> Min(tmp)
[1] -1.827889
> mean(tmp)
[1] 0.1325096
> Sum(tmp)
[1] 13.25096
> Var(tmp)
[1] 0.8502736
>
> rowMeans(tmp)
[1] 0.1325096
> rowSums(tmp)
[1] 13.25096
> rowVars(tmp)
[1] 0.8502736
> rowSd(tmp)
[1] 0.9221028
> rowMax(tmp)
[1] 2.46405
> rowMin(tmp)
[1] -1.827889
>
> colMeans(tmp)
[1] 0.21034125 -0.56378084 1.57467951 0.98226262 1.40016744 -1.25799253
[7] 1.33640608 -0.37124945 -0.26309005 -0.10941280 -0.04563498 0.73446559
[13] 0.09515416 1.07435154 0.37233992 0.30841257 0.82219587 0.74790164
[19] -0.41987526 -0.61464204 -0.46953869 0.04419457 -0.08032873 0.20677833
[25] 1.74056758 -0.47015262 -1.47122074 -1.12237418 -0.33645913 1.08842519
[31] 0.38658273 -0.02510926 0.89994640 2.07672410 -0.87414028 0.16088948
[37] 0.98584250 -0.27690611 2.06369580 -0.35433302 1.28218787 0.56260101
[43] -1.55764240 1.16002069 0.42626153 0.45981373 0.55563729 0.67626657
[49] -0.66015609 0.47596556 -0.01587779 0.70381667 0.61302597 1.08608261
[55] -1.00642152 0.54302162 0.45249650 -0.73274832 0.89138631 1.71550885
[61] -0.58288692 -0.20559949 1.10095316 -0.63042072 -1.08421734 -0.59333271
[67] 0.18104692 0.41280861 -1.41495156 -0.84917999 -1.47659930 -0.34238752
[73] -0.93237959 -0.85503276 1.84469595 -0.76878298 -0.46609446 -0.80833718
[79] -0.13581487 2.46404952 0.75848834 1.01050139 0.71021411 -0.76618787
[85] -1.18970260 0.05692194 0.78037811 -0.29838097 -0.28785772 -1.16368978
[91] -1.82788855 0.11376294 -0.06639165 -1.26602524 0.56750824 1.36879647
[97] 0.52724447 1.33304918 0.79454808 -0.57919505
> colSums(tmp)
[1] 0.21034125 -0.56378084 1.57467951 0.98226262 1.40016744 -1.25799253
[7] 1.33640608 -0.37124945 -0.26309005 -0.10941280 -0.04563498 0.73446559
[13] 0.09515416 1.07435154 0.37233992 0.30841257 0.82219587 0.74790164
[19] -0.41987526 -0.61464204 -0.46953869 0.04419457 -0.08032873 0.20677833
[25] 1.74056758 -0.47015262 -1.47122074 -1.12237418 -0.33645913 1.08842519
[31] 0.38658273 -0.02510926 0.89994640 2.07672410 -0.87414028 0.16088948
[37] 0.98584250 -0.27690611 2.06369580 -0.35433302 1.28218787 0.56260101
[43] -1.55764240 1.16002069 0.42626153 0.45981373 0.55563729 0.67626657
[49] -0.66015609 0.47596556 -0.01587779 0.70381667 0.61302597 1.08608261
[55] -1.00642152 0.54302162 0.45249650 -0.73274832 0.89138631 1.71550885
[61] -0.58288692 -0.20559949 1.10095316 -0.63042072 -1.08421734 -0.59333271
[67] 0.18104692 0.41280861 -1.41495156 -0.84917999 -1.47659930 -0.34238752
[73] -0.93237959 -0.85503276 1.84469595 -0.76878298 -0.46609446 -0.80833718
[79] -0.13581487 2.46404952 0.75848834 1.01050139 0.71021411 -0.76618787
[85] -1.18970260 0.05692194 0.78037811 -0.29838097 -0.28785772 -1.16368978
[91] -1.82788855 0.11376294 -0.06639165 -1.26602524 0.56750824 1.36879647
[97] 0.52724447 1.33304918 0.79454808 -0.57919505
> colVars(tmp)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> colSd(tmp)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> colMax(tmp)
[1] 0.21034125 -0.56378084 1.57467951 0.98226262 1.40016744 -1.25799253
[7] 1.33640608 -0.37124945 -0.26309005 -0.10941280 -0.04563498 0.73446559
[13] 0.09515416 1.07435154 0.37233992 0.30841257 0.82219587 0.74790164
[19] -0.41987526 -0.61464204 -0.46953869 0.04419457 -0.08032873 0.20677833
[25] 1.74056758 -0.47015262 -1.47122074 -1.12237418 -0.33645913 1.08842519
[31] 0.38658273 -0.02510926 0.89994640 2.07672410 -0.87414028 0.16088948
[37] 0.98584250 -0.27690611 2.06369580 -0.35433302 1.28218787 0.56260101
[43] -1.55764240 1.16002069 0.42626153 0.45981373 0.55563729 0.67626657
[49] -0.66015609 0.47596556 -0.01587779 0.70381667 0.61302597 1.08608261
[55] -1.00642152 0.54302162 0.45249650 -0.73274832 0.89138631 1.71550885
[61] -0.58288692 -0.20559949 1.10095316 -0.63042072 -1.08421734 -0.59333271
[67] 0.18104692 0.41280861 -1.41495156 -0.84917999 -1.47659930 -0.34238752
[73] -0.93237959 -0.85503276 1.84469595 -0.76878298 -0.46609446 -0.80833718
[79] -0.13581487 2.46404952 0.75848834 1.01050139 0.71021411 -0.76618787
[85] -1.18970260 0.05692194 0.78037811 -0.29838097 -0.28785772 -1.16368978
[91] -1.82788855 0.11376294 -0.06639165 -1.26602524 0.56750824 1.36879647
[97] 0.52724447 1.33304918 0.79454808 -0.57919505
> colMin(tmp)
[1] 0.21034125 -0.56378084 1.57467951 0.98226262 1.40016744 -1.25799253
[7] 1.33640608 -0.37124945 -0.26309005 -0.10941280 -0.04563498 0.73446559
[13] 0.09515416 1.07435154 0.37233992 0.30841257 0.82219587 0.74790164
[19] -0.41987526 -0.61464204 -0.46953869 0.04419457 -0.08032873 0.20677833
[25] 1.74056758 -0.47015262 -1.47122074 -1.12237418 -0.33645913 1.08842519
[31] 0.38658273 -0.02510926 0.89994640 2.07672410 -0.87414028 0.16088948
[37] 0.98584250 -0.27690611 2.06369580 -0.35433302 1.28218787 0.56260101
[43] -1.55764240 1.16002069 0.42626153 0.45981373 0.55563729 0.67626657
[49] -0.66015609 0.47596556 -0.01587779 0.70381667 0.61302597 1.08608261
[55] -1.00642152 0.54302162 0.45249650 -0.73274832 0.89138631 1.71550885
[61] -0.58288692 -0.20559949 1.10095316 -0.63042072 -1.08421734 -0.59333271
[67] 0.18104692 0.41280861 -1.41495156 -0.84917999 -1.47659930 -0.34238752
[73] -0.93237959 -0.85503276 1.84469595 -0.76878298 -0.46609446 -0.80833718
[79] -0.13581487 2.46404952 0.75848834 1.01050139 0.71021411 -0.76618787
[85] -1.18970260 0.05692194 0.78037811 -0.29838097 -0.28785772 -1.16368978
[91] -1.82788855 0.11376294 -0.06639165 -1.26602524 0.56750824 1.36879647
[97] 0.52724447 1.33304918 0.79454808 -0.57919505
> colMedians(tmp)
[1] 0.21034125 -0.56378084 1.57467951 0.98226262 1.40016744 -1.25799253
[7] 1.33640608 -0.37124945 -0.26309005 -0.10941280 -0.04563498 0.73446559
[13] 0.09515416 1.07435154 0.37233992 0.30841257 0.82219587 0.74790164
[19] -0.41987526 -0.61464204 -0.46953869 0.04419457 -0.08032873 0.20677833
[25] 1.74056758 -0.47015262 -1.47122074 -1.12237418 -0.33645913 1.08842519
[31] 0.38658273 -0.02510926 0.89994640 2.07672410 -0.87414028 0.16088948
[37] 0.98584250 -0.27690611 2.06369580 -0.35433302 1.28218787 0.56260101
[43] -1.55764240 1.16002069 0.42626153 0.45981373 0.55563729 0.67626657
[49] -0.66015609 0.47596556 -0.01587779 0.70381667 0.61302597 1.08608261
[55] -1.00642152 0.54302162 0.45249650 -0.73274832 0.89138631 1.71550885
[61] -0.58288692 -0.20559949 1.10095316 -0.63042072 -1.08421734 -0.59333271
[67] 0.18104692 0.41280861 -1.41495156 -0.84917999 -1.47659930 -0.34238752
[73] -0.93237959 -0.85503276 1.84469595 -0.76878298 -0.46609446 -0.80833718
[79] -0.13581487 2.46404952 0.75848834 1.01050139 0.71021411 -0.76618787
[85] -1.18970260 0.05692194 0.78037811 -0.29838097 -0.28785772 -1.16368978
[91] -1.82788855 0.11376294 -0.06639165 -1.26602524 0.56750824 1.36879647
[97] 0.52724447 1.33304918 0.79454808 -0.57919505
> colRanges(tmp)
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0.2103412 -0.5637808 1.57468 0.9822626 1.400167 -1.257993 1.336406
[2,] 0.2103412 -0.5637808 1.57468 0.9822626 1.400167 -1.257993 1.336406
[,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] -0.3712494 -0.26309 -0.1094128 -0.04563498 0.7344656 0.09515416 1.074352
[2,] -0.3712494 -0.26309 -0.1094128 -0.04563498 0.7344656 0.09515416 1.074352
[,15] [,16] [,17] [,18] [,19] [,20] [,21]
[1,] 0.3723399 0.3084126 0.8221959 0.7479016 -0.4198753 -0.614642 -0.4695387
[2,] 0.3723399 0.3084126 0.8221959 0.7479016 -0.4198753 -0.614642 -0.4695387
[,22] [,23] [,24] [,25] [,26] [,27] [,28]
[1,] 0.04419457 -0.08032873 0.2067783 1.740568 -0.4701526 -1.471221 -1.122374
[2,] 0.04419457 -0.08032873 0.2067783 1.740568 -0.4701526 -1.471221 -1.122374
[,29] [,30] [,31] [,32] [,33] [,34] [,35]
[1,] -0.3364591 1.088425 0.3865827 -0.02510926 0.8999464 2.076724 -0.8741403
[2,] -0.3364591 1.088425 0.3865827 -0.02510926 0.8999464 2.076724 -0.8741403
[,36] [,37] [,38] [,39] [,40] [,41] [,42]
[1,] 0.1608895 0.9858425 -0.2769061 2.063696 -0.354333 1.282188 0.562601
[2,] 0.1608895 0.9858425 -0.2769061 2.063696 -0.354333 1.282188 0.562601
[,43] [,44] [,45] [,46] [,47] [,48] [,49]
[1,] -1.557642 1.160021 0.4262615 0.4598137 0.5556373 0.6762666 -0.6601561
[2,] -1.557642 1.160021 0.4262615 0.4598137 0.5556373 0.6762666 -0.6601561
[,50] [,51] [,52] [,53] [,54] [,55] [,56]
[1,] 0.4759656 -0.01587779 0.7038167 0.613026 1.086083 -1.006422 0.5430216
[2,] 0.4759656 -0.01587779 0.7038167 0.613026 1.086083 -1.006422 0.5430216
[,57] [,58] [,59] [,60] [,61] [,62] [,63]
[1,] 0.4524965 -0.7327483 0.8913863 1.715509 -0.5828869 -0.2055995 1.100953
[2,] 0.4524965 -0.7327483 0.8913863 1.715509 -0.5828869 -0.2055995 1.100953
[,64] [,65] [,66] [,67] [,68] [,69] [,70]
[1,] -0.6304207 -1.084217 -0.5933327 0.1810469 0.4128086 -1.414952 -0.84918
[2,] -0.6304207 -1.084217 -0.5933327 0.1810469 0.4128086 -1.414952 -0.84918
[,71] [,72] [,73] [,74] [,75] [,76] [,77]
[1,] -1.476599 -0.3423875 -0.9323796 -0.8550328 1.844696 -0.768783 -0.4660945
[2,] -1.476599 -0.3423875 -0.9323796 -0.8550328 1.844696 -0.768783 -0.4660945
[,78] [,79] [,80] [,81] [,82] [,83] [,84]
[1,] -0.8083372 -0.1358149 2.46405 0.7584883 1.010501 0.7102141 -0.7661879
[2,] -0.8083372 -0.1358149 2.46405 0.7584883 1.010501 0.7102141 -0.7661879
[,85] [,86] [,87] [,88] [,89] [,90] [,91]
[1,] -1.189703 0.05692194 0.7803781 -0.298381 -0.2878577 -1.16369 -1.827889
[2,] -1.189703 0.05692194 0.7803781 -0.298381 -0.2878577 -1.16369 -1.827889
[,92] [,93] [,94] [,95] [,96] [,97] [,98]
[1,] 0.1137629 -0.06639165 -1.266025 0.5675082 1.368796 0.5272445 1.333049
[2,] 0.1137629 -0.06639165 -1.266025 0.5675082 1.368796 0.5272445 1.333049
[,99] [,100]
[1,] 0.7945481 -0.5791951
[2,] 0.7945481 -0.5791951
>
>
> Max(tmp2)
[1] 2.531325
> Min(tmp2)
[1] -2.065254
> mean(tmp2)
[1] -0.1102814
> Sum(tmp2)
[1] -11.02814
> Var(tmp2)
[1] 0.9522014
>
> rowMeans(tmp2)
[1] 0.86287511 -0.84208225 0.40880718 0.23411726 -0.67665659 0.29506316
[7] -0.87101400 -0.44419849 -0.84735238 -0.46060934 0.68672924 -0.74214780
[13] -0.89825943 -0.12907117 -0.50222343 0.82923103 -1.16609405 -0.02384595
[19] -0.94267885 0.75488714 -0.56711403 -1.77215295 1.53178947 0.14878438
[25] 0.94210435 -0.22336075 -1.98066838 -1.48290014 -0.16091344 2.06834165
[31] -0.78080061 -0.56258228 1.67460130 1.71991346 -1.77394591 0.54381526
[37] -0.99607977 -2.06525378 0.86687497 -0.53487985 -0.40016933 0.03163577
[43] 1.46909748 0.98987029 2.53132527 -0.17036256 -0.46287555 -1.42809515
[49] 0.27735755 0.74969075 -0.59446516 -0.13721866 0.86090444 0.47411420
[55] -1.10012028 -0.11908917 -0.46303709 0.13522013 0.42120033 -0.81741983
[61] -1.31075604 0.36009564 0.26036919 0.47335285 -1.54779532 -1.21667954
[67] -1.84988776 -1.62758246 1.60367562 0.01567768 -0.38948347 -0.04351092
[73] 0.32590734 -1.06269995 -1.37986281 -0.40089855 0.62080994 0.97942879
[79] 0.04921964 1.51214590 0.24712819 0.20416610 0.80146192 -0.25962103
[85] 1.43575348 -0.30060989 -1.39763137 -0.20361840 0.83600466 -0.68638075
[91] 1.28501249 -0.79501455 -0.56177120 -0.48329541 1.04361161 0.12545505
[97] -1.02622803 -0.59169712 0.91307280 -1.35407750
> rowSums(tmp2)
[1] 0.86287511 -0.84208225 0.40880718 0.23411726 -0.67665659 0.29506316
[7] -0.87101400 -0.44419849 -0.84735238 -0.46060934 0.68672924 -0.74214780
[13] -0.89825943 -0.12907117 -0.50222343 0.82923103 -1.16609405 -0.02384595
[19] -0.94267885 0.75488714 -0.56711403 -1.77215295 1.53178947 0.14878438
[25] 0.94210435 -0.22336075 -1.98066838 -1.48290014 -0.16091344 2.06834165
[31] -0.78080061 -0.56258228 1.67460130 1.71991346 -1.77394591 0.54381526
[37] -0.99607977 -2.06525378 0.86687497 -0.53487985 -0.40016933 0.03163577
[43] 1.46909748 0.98987029 2.53132527 -0.17036256 -0.46287555 -1.42809515
[49] 0.27735755 0.74969075 -0.59446516 -0.13721866 0.86090444 0.47411420
[55] -1.10012028 -0.11908917 -0.46303709 0.13522013 0.42120033 -0.81741983
[61] -1.31075604 0.36009564 0.26036919 0.47335285 -1.54779532 -1.21667954
[67] -1.84988776 -1.62758246 1.60367562 0.01567768 -0.38948347 -0.04351092
[73] 0.32590734 -1.06269995 -1.37986281 -0.40089855 0.62080994 0.97942879
[79] 0.04921964 1.51214590 0.24712819 0.20416610 0.80146192 -0.25962103
[85] 1.43575348 -0.30060989 -1.39763137 -0.20361840 0.83600466 -0.68638075
[91] 1.28501249 -0.79501455 -0.56177120 -0.48329541 1.04361161 0.12545505
[97] -1.02622803 -0.59169712 0.91307280 -1.35407750
> rowVars(tmp2)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> rowSd(tmp2)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> rowMax(tmp2)
[1] 0.86287511 -0.84208225 0.40880718 0.23411726 -0.67665659 0.29506316
[7] -0.87101400 -0.44419849 -0.84735238 -0.46060934 0.68672924 -0.74214780
[13] -0.89825943 -0.12907117 -0.50222343 0.82923103 -1.16609405 -0.02384595
[19] -0.94267885 0.75488714 -0.56711403 -1.77215295 1.53178947 0.14878438
[25] 0.94210435 -0.22336075 -1.98066838 -1.48290014 -0.16091344 2.06834165
[31] -0.78080061 -0.56258228 1.67460130 1.71991346 -1.77394591 0.54381526
[37] -0.99607977 -2.06525378 0.86687497 -0.53487985 -0.40016933 0.03163577
[43] 1.46909748 0.98987029 2.53132527 -0.17036256 -0.46287555 -1.42809515
[49] 0.27735755 0.74969075 -0.59446516 -0.13721866 0.86090444 0.47411420
[55] -1.10012028 -0.11908917 -0.46303709 0.13522013 0.42120033 -0.81741983
[61] -1.31075604 0.36009564 0.26036919 0.47335285 -1.54779532 -1.21667954
[67] -1.84988776 -1.62758246 1.60367562 0.01567768 -0.38948347 -0.04351092
[73] 0.32590734 -1.06269995 -1.37986281 -0.40089855 0.62080994 0.97942879
[79] 0.04921964 1.51214590 0.24712819 0.20416610 0.80146192 -0.25962103
[85] 1.43575348 -0.30060989 -1.39763137 -0.20361840 0.83600466 -0.68638075
[91] 1.28501249 -0.79501455 -0.56177120 -0.48329541 1.04361161 0.12545505
[97] -1.02622803 -0.59169712 0.91307280 -1.35407750
> rowMin(tmp2)
[1] 0.86287511 -0.84208225 0.40880718 0.23411726 -0.67665659 0.29506316
[7] -0.87101400 -0.44419849 -0.84735238 -0.46060934 0.68672924 -0.74214780
[13] -0.89825943 -0.12907117 -0.50222343 0.82923103 -1.16609405 -0.02384595
[19] -0.94267885 0.75488714 -0.56711403 -1.77215295 1.53178947 0.14878438
[25] 0.94210435 -0.22336075 -1.98066838 -1.48290014 -0.16091344 2.06834165
[31] -0.78080061 -0.56258228 1.67460130 1.71991346 -1.77394591 0.54381526
[37] -0.99607977 -2.06525378 0.86687497 -0.53487985 -0.40016933 0.03163577
[43] 1.46909748 0.98987029 2.53132527 -0.17036256 -0.46287555 -1.42809515
[49] 0.27735755 0.74969075 -0.59446516 -0.13721866 0.86090444 0.47411420
[55] -1.10012028 -0.11908917 -0.46303709 0.13522013 0.42120033 -0.81741983
[61] -1.31075604 0.36009564 0.26036919 0.47335285 -1.54779532 -1.21667954
[67] -1.84988776 -1.62758246 1.60367562 0.01567768 -0.38948347 -0.04351092
[73] 0.32590734 -1.06269995 -1.37986281 -0.40089855 0.62080994 0.97942879
[79] 0.04921964 1.51214590 0.24712819 0.20416610 0.80146192 -0.25962103
[85] 1.43575348 -0.30060989 -1.39763137 -0.20361840 0.83600466 -0.68638075
[91] 1.28501249 -0.79501455 -0.56177120 -0.48329541 1.04361161 0.12545505
[97] -1.02622803 -0.59169712 0.91307280 -1.35407750
>
> colMeans(tmp2)
[1] -0.1102814
> colSums(tmp2)
[1] -11.02814
> colVars(tmp2)
[1] 0.9522014
> colSd(tmp2)
[1] 0.9758081
> colMax(tmp2)
[1] 2.531325
> colMin(tmp2)
[1] -2.065254
> colMedians(tmp2)
[1] -0.165638
> colRanges(tmp2)
[,1]
[1,] -2.065254
[2,] 2.531325
>
> dataset1 <- matrix(dataset1,1,100)
>
> agree.checks(tmp,dataset1)
>
> dataset2 <- matrix(dataset2,100,1)
> agree.checks(tmp2,dataset2)
>
>
> tmp <- createBufferedMatrix(10,10)
>
> tmp[1:10,1:10] <- rnorm(100)
> colApply(tmp,sum)
[1] -2.94506777 -6.68581238 2.01579395 0.94936088 5.40285836 -3.12678299
[7] 2.80425037 0.01819916 1.54092038 -0.31027735
> colApply(tmp,quantile)[,1]
[,1]
[1,] -2.68832199
[2,] -0.21683993
[3,] -0.01319427
[4,] 0.40584531
[5,] 0.93411353
>
> rowApply(tmp,sum)
[1] 1.9655623 0.1839045 -2.1744743 1.9380777 -0.6858619 -2.2378164
[7] 2.1050142 0.6422163 -2.7923487 0.7191687
> rowApply(tmp,rank)[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 10 1 8 8 6 7 3 5 6 1
[2,] 6 5 3 1 1 10 4 1 2 2
[3,] 9 4 7 9 2 5 7 10 5 4
[4,] 3 2 9 10 9 8 1 4 3 10
[5,] 1 9 10 5 7 9 8 7 8 9
[6,] 4 7 2 4 10 3 6 2 4 3
[7,] 8 10 6 3 4 6 2 3 9 5
[8,] 2 6 5 6 8 1 9 9 1 8
[9,] 5 8 4 2 5 4 5 8 10 6
[10,] 7 3 1 7 3 2 10 6 7 7
>
> tmp <- createBufferedMatrix(5,20)
>
> tmp[1:5,1:20] <- rnorm(100)
> colApply(tmp,sum)
[1] 1.3376662 0.7002425 3.0336188 0.9416966 3.6069467 -1.2847405
[7] -0.9541809 -3.3488437 -0.0230720 -0.1803286 -1.3239670 -1.5364628
[13] 2.4801377 -3.0942689 1.3750337 -1.7055106 1.0508943 1.1675378
[19] -0.5830503 0.4615902
> colApply(tmp,quantile)[,1]
[,1]
[1,] -1.8876946
[2,] -0.2002762
[3,] 0.8029818
[4,] 1.2689978
[5,] 1.3536574
>
> rowApply(tmp,sum)
[1] 5.705092 -2.513440 -1.374680 -5.000760 5.304727
> rowApply(tmp,rank)[1:5,]
[,1] [,2] [,3] [,4] [,5]
[1,] 18 2 17 10 17
[2,] 19 15 1 6 13
[3,] 6 19 8 20 16
[4,] 8 9 18 13 10
[5,] 17 20 15 11 14
>
>
> as.matrix(tmp)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1.3536574 1.7915177 -0.3133486 0.027964665 0.92174230 -0.9846281
[2,] -1.8876946 0.2580587 1.6153070 -0.047803287 1.70561742 -0.4197652
[3,] 0.8029818 -1.2842347 -0.1757552 0.806237957 0.43110337 0.3765264
[4,] -0.2002762 -0.5827631 0.9780234 0.150745767 -0.08945971 0.7016199
[5,] 1.2689978 0.5176640 0.9293922 0.004551542 0.63794333 -0.9584936
[,7] [,8] [,9] [,10] [,11] [,12]
[1,] 0.74411541 0.50553657 0.4259234 -0.52230802 -0.3992739 0.7725651
[2,] 0.15975358 -1.43069319 -0.5093161 0.07695274 -1.3301553 0.3714566
[3,] 0.07007821 -0.88825981 -0.8902098 -0.91176840 -0.1655993 -1.0055417
[4,] -1.19402364 -1.45272330 -0.4958376 0.66822008 0.2419257 -0.5374216
[5,] -0.73410444 -0.08270396 1.4463681 0.50857501 0.3291358 -1.1375212
[,13] [,14] [,15] [,16] [,17] [,18]
[1,] 0.3634000 0.7745113 -1.08921113 -1.067647 0.61888342 1.9707567
[2,] -0.7218236 0.1982003 0.05836890 1.341963 0.19537378 -2.1339703
[3,] 1.3874302 -0.6671674 0.06804022 -1.212849 -0.01477922 0.1481582
[4,] 0.5961511 -2.3446371 -0.33666199 0.400989 0.45620199 -1.0825620
[5,] 0.8549800 -1.0551761 2.67449769 -1.167966 -0.20478562 2.2651551
[,19] [,20]
[1,] 0.07731548 -0.26638031
[2,] 0.35941413 -0.37268468
[3,] 0.57929099 1.17163716
[4,] -0.85410120 -0.02416925
[5,] -0.74496966 -0.04681272
>
>
> is.BufferedMatrix(tmp)
[1] TRUE
>
> as.BufferedMatrix(as.matrix(tmp))
BufferedMatrix object
Matrix size: 5 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 1.9 Kilobytes.
Disk usage : 800 bytes.
>
>
>
> subBufferedMatrix(tmp,1:5,1:5)
BufferedMatrix object
Matrix size: 5 5
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 632 bytes.
Disk usage : 200 bytes.
> subBufferedMatrix(tmp,,5:8)
BufferedMatrix object
Matrix size: 5 4
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 544 bytes.
Disk usage : 160 bytes.
> subBufferedMatrix(tmp,1:3,)
BufferedMatrix object
Matrix size: 3 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 1.9 Kilobytes.
Disk usage : 480 bytes.
>
>
> rm(tmp)
>
>
> ###
> ### Testing colnames and rownames
> ###
>
> tmp <- createBufferedMatrix(5,20)
> tmp[1:5,1:20] <- rnorm(100)
>
>
> colnames(tmp)
NULL
> rownames(tmp)
NULL
>
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
> colnames(tmp)
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
> rownames(tmp)
[1] "row1" "row2" "row3" "row4" "row5"
>
>
> tmp["row1",]
col1 col2 col3 col4 col5 col6 col7
row1 -0.5646376 0.9480391 -0.06061048 -1.501423 -0.2927144 0.318237 -0.9827178
col8 col9 col10 col11 col12 col13
row1 -1.801152 -0.06115842 0.2792111 -0.8933507 -0.02522346 -0.4844673
col14 col15 col16 col17 col18 col19 col20
row1 0.1592828 -1.524283 0.4911905 0.9369325 0.964763 -0.008705161 -0.2013845
> tmp[,"col10"]
col10
row1 0.2792111
row2 -1.2266003
row3 -0.3867597
row4 -1.3455641
row5 -2.3499597
> tmp[c("row1","row5"),]
col1 col2 col3 col4 col5 col6 col7
row1 -0.5646376 0.94803908 -0.06061048 -1.501423 -0.2927144 0.318237 -0.9827178
row5 0.8979118 0.03330359 -0.57122184 -1.391362 -1.4369568 1.158451 2.3325459
col8 col9 col10 col11 col12 col13
row1 -1.8011522 -0.06115842 0.2792111 -0.8933507 -0.02522346 -0.48446732
row5 0.8223263 0.94590338 -2.3499597 0.2766591 0.22265849 0.04077132
col14 col15 col16 col17 col18 col19
row1 0.1592828 -1.5242825 0.4911905 0.9369325 0.964763 -0.008705161
row5 1.0843176 -0.8240909 0.5263126 -1.3908639 -1.256244 1.675138478
col20
row1 -0.2013845
row5 1.8925993
> tmp[,c("col6","col20")]
col6 col20
row1 0.3182370 -0.2013845
row2 -1.9104461 -0.1739290
row3 0.5668831 1.5977490
row4 -1.6141318 -0.9031944
row5 1.1584513 1.8925993
> tmp[c("row1","row5"),c("col6","col20")]
col6 col20
row1 0.318237 -0.2013845
row5 1.158451 1.8925993
>
>
>
>
> tmp["row1",] <- rnorm(20,mean=10)
> tmp[,"col10"] <- rnorm(5,mean=30)
> tmp[c("row1","row5"),] <- rnorm(40,mean=50)
> tmp[,c("col6","col20")] <- rnorm(10,mean=75)
> tmp[c("row1","row5"),c("col6","col20")] <- rnorm(4,mean=105)
>
> tmp["row1",]
col1 col2 col3 col4 col5 col6 col7 col8
row1 50.3431 48.57824 51.49688 50.5375 49.82881 104.1985 51.63399 51.84193
col9 col10 col11 col12 col13 col14 col15 col16
row1 49.89478 48.67806 51.16179 50.82096 49.96705 49.96287 51.27789 50.82104
col17 col18 col19 col20
row1 51.65303 51.06271 49.92516 104.4284
> tmp[,"col10"]
col10
row1 48.67806
row2 30.99579
row3 28.71921
row4 29.70293
row5 49.91467
> tmp[c("row1","row5"),]
col1 col2 col3 col4 col5 col6 col7 col8
row1 50.34310 48.57824 51.49688 50.53750 49.82881 104.1985 51.63399 51.84193
row5 48.54739 50.33320 50.63370 50.50598 49.65772 104.8676 49.73430 49.57078
col9 col10 col11 col12 col13 col14 col15 col16
row1 49.89478 48.67806 51.16179 50.82096 49.96705 49.96287 51.27789 50.82104
row5 49.72699 49.91467 50.92974 50.58869 49.62215 48.64202 49.97829 49.52931
col17 col18 col19 col20
row1 51.65303 51.06271 49.92516 104.4284
row5 48.51792 47.94948 49.62427 105.4209
> tmp[,c("col6","col20")]
col6 col20
row1 104.19853 104.42840
row2 75.30710 72.83380
row3 75.35978 75.92541
row4 74.75908 73.41516
row5 104.86761 105.42095
> tmp[c("row1","row5"),c("col6","col20")]
col6 col20
row1 104.1985 104.4284
row5 104.8676 105.4209
>
>
> subBufferedMatrix(tmp,c("row1","row5"),c("col6","col20"))[1:2,1:2]
col6 col20
row1 104.1985 104.4284
row5 104.8676 105.4209
>
>
>
>
>
> tmp <- createBufferedMatrix(5,20)
> tmp[1:5,1:20] <- rnorm(100)
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
>
> tmp[,"col13"]
col13
[1,] -0.2766931
[2,] 0.7931707
[3,] 0.2319932
[4,] 0.9887592
[5,] 0.2261013
> tmp[,c("col17","col7")]
col17 col7
[1,] 0.42412305 -0.7329806
[2,] -1.08653243 -2.0550613
[3,] -0.02809199 -1.0681302
[4,] 1.84712309 -0.9383834
[5,] 1.66565540 0.5149202
>
> subBufferedMatrix(tmp,,c("col6","col20"))[,1:2]
col6 col20
[1,] -1.2346624 1.70184023
[2,] -0.1932769 -0.08541191
[3,] -1.3928356 -1.24084346
[4,] 1.7487519 0.02176131
[5,] 0.3899019 0.42411283
> subBufferedMatrix(tmp,1,c("col6"))[,1]
col1
[1,] -1.234662
> subBufferedMatrix(tmp,1:2,c("col6"))[,1]
col6
[1,] -1.2346624
[2,] -0.1932769
>
>
>
> tmp <- createBufferedMatrix(5,20)
> tmp[1:5,1:20] <- rnorm(100)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
>
>
>
> subBufferedMatrix(tmp,c("row3","row1"),)[,1:20]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
row3 -0.9127631 -0.8547964 1.023700 -0.4527781 -0.6465873 -1.942951 -1.5861538
row1 -0.8587126 -1.6660376 1.628582 -0.2629895 -0.5465051 -0.901156 -0.2311077
[,8] [,9] [,10] [,11] [,12] [,13]
row3 1.1809780 0.07208657 -1.923796 -0.45570807 -2.4403111 -0.1572273
row1 0.7745039 -2.20492546 -1.125591 -0.09619462 -0.4404184 1.8362437
[,14] [,15] [,16] [,17] [,18] [,19] [,20]
row3 0.8253162 0.7594772 0.9881835 0.5477217 -0.4912386 -0.9227448 -0.8013403
row1 0.3859789 0.6060569 -0.4306772 1.9992669 0.2405396 -2.5352926 -0.8653468
> subBufferedMatrix(tmp,c("row2"),1:10)[,1:10]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
row2 -0.2993527 -0.1370969 -0.08603736 0.1770039 0.736211 0.6826977 1.593057
[,8] [,9] [,10]
row2 -0.0517912 1.358018 1.4374
> subBufferedMatrix(tmp,c("row5"),1:20)[,1:20]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
row5 -0.3876826 -0.03239138 0.7730289 0.4459592 -0.2318467 -0.7162315 0.96598
[,8] [,9] [,10] [,11] [,12] [,13] [,14]
row5 -0.001213244 0.684045 0.484481 0.03233101 -0.7879574 0.5777228 -0.1614843
[,15] [,16] [,17] [,18] [,19] [,20]
row5 -0.5425815 -0.09135147 -1.359507 0.1278715 1.075022 -1.324895
>
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
> colnames(tmp)
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
> rownames(tmp)
[1] "row1" "row2" "row3" "row4" "row5"
>
>
> colnames(tmp) <- NULL
> rownames(tmp) <- NULL
>
> colnames(tmp)
NULL
> rownames(tmp)
NULL
>
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
> dimnames(tmp)
[[1]]
[1] "row1" "row2" "row3" "row4" "row5"
[[2]]
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
>
> dimnames(tmp) <- NULL
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> dimnames(tmp)
[[1]]
NULL
[[2]]
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
>
>
> dimnames(tmp) <- NULL
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
> dimnames(tmp)
[[1]]
[1] "row1" "row2" "row3" "row4" "row5"
[[2]]
NULL
>
> dimnames(tmp) <- list(NULL,c(colnames(tmp,do.NULL=FALSE)))
> dimnames(tmp)
[[1]]
NULL
[[2]]
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
>
>
>
> ###
> ### Testing logical indexing
> ###
> ###
>
> tmp <- createBufferedMatrix(230,15)
> tmp[1:230,1:15] <- rnorm(230*15)
> x <-tmp[1:230,1:15]
>
> for (rep in 1:10){
+ which.cols <- sample(c(TRUE,FALSE),15,replace=T)
+ which.rows <- sample(c(TRUE,FALSE),230,replace=T)
+
+ if (!all(tmp[which.rows,which.cols] == x[which.rows,which.cols])){
+ stop("No agreement when logical indexing\n")
+ }
+
+ if (!all(subBufferedMatrix(tmp,,which.cols)[,1:sum(which.cols)] == x[,which.cols])){
+ stop("No agreement when logical indexing in subBufferedMatrix cols\n")
+ }
+ if (!all(subBufferedMatrix(tmp,which.rows,)[1:sum(which.rows),] == x[which.rows,])){
+ stop("No agreement when logical indexing in subBufferedMatrix rows\n")
+ }
+
+
+ if (!all(subBufferedMatrix(tmp,which.rows,which.cols)[1:sum(which.rows),1:sum(which.cols)]== x[which.rows,which.cols])){
+ stop("No agreement when logical indexing in subBufferedMatrix rows and columns\n")
+ }
+ }
>
>
> ##
> ## Test the ReadOnlyMode
> ##
>
> ReadOnlyMode(tmp)
> is.ReadOnlyMode(tmp)
[1] TRUE
>
> filenames(tmp)
[1] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e0121f4b6e"
[2] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e078263ab5"
[3] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e0214e52a9"
[4] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e05e6616c3"
[5] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e048b96aed"
[6] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e036ae5c22"
[7] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e05a3d571f"
[8] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e07ffe583"
[9] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e05beed14"
[10] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e07919a00"
[11] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e04bc42454"
[12] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e021d861ff"
[13] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e04b91221d"
[14] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e066c3535a"
[15] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_i386\\BM17e0493646ab"
>
>
> ### testing coercion functions
> ###
>
> tmp <- as(tmp,"matrix")
> tmp <- as(tmp,"BufferedMatrix")
>
>
>
> ### testing whether can move storage from one location to another
>
> MoveStorageDirectory(tmp,"NewDirectory",full.path=FALSE)
> MoveStorageDirectory(tmp,getwd(),full.path=TRUE)
Warning message:
In dir.create(new.directory) :
'C:\Users\biocbuild\bbs-3.9-bioc\meat\BufferedMatrix.Rcheck\tests_i386' already exists
>
>
> RowMode(tmp)
> rowMedians(tmp)
[1] -0.2746031544 0.4392173595 0.0850287032 0.3668940976 -0.1776146164
[6] -0.1461585568 0.1586464639 -0.2065437084 -0.2827354217 0.3473241545
[11] -0.0604752452 0.0767771786 0.1612777964 0.0366817755 -0.5783906727
[16] -0.8598869610 -0.1589808147 0.1557228744 -0.2146850998 -0.2297554215
[21] -0.3118713660 -0.0496465676 0.5513368816 0.3119062514 -0.3919099328
[26] 0.2856573922 0.2747234133 -0.4822409029 -0.2854738619 -0.2087180333
[31] -0.5863158802 0.4419100652 -0.4302968068 0.1003428042 -0.1775323314
[36] -0.1201122293 -0.3166161272 0.4839981225 0.4479467247 0.1057557991
[41] -0.1012526665 0.1820361399 -0.1765143144 0.1549389502 0.0336394081
[46] 0.0748794947 0.6291719845 0.0013801565 -0.4120358155 -0.1286232346
[51] 0.3558674093 -0.1668892607 -0.4227880873 0.6051013482 -0.1786766242
[56] 0.5860426317 -0.2180465124 -0.1405886445 0.4976178301 -0.5070406956
[61] 0.1063942731 -0.0403487606 0.2064185601 0.1950165688 0.1552130899
[66] 0.1262080620 0.4134061754 0.3916993572 -0.5958622473 0.0343387203
[71] 0.1097468338 0.0142017692 0.0064479399 -0.1428837524 -0.0765720818
[76] -0.1679857001 -0.0407205629 -0.5011824535 -0.0972530270 -0.0624734778
[81] 0.1783800181 0.2474743665 -0.0747835181 -0.1040799610 -0.5861701415
[86] -0.0347269428 0.4449536255 0.0091580699 -0.2098543568 0.2597487039
[91] -0.4717310650 0.2962691364 0.1071844392 0.0911279303 0.5517801469
[96] -0.5241850951 0.2397949044 0.2179922025 -0.2097049342 0.1921869833
[101] 0.2147837805 -0.3274700587 0.3743263937 -0.3391459054 -0.0009693625
[106] -0.0258650143 -0.1891823073 -0.1843397654 0.2025635081 0.1754714893
[111] -0.1227198745 0.2016523959 -0.1581645330 -0.5258034235 -0.1772456861
[116] 0.3204743852 -0.5944347349 -0.4980714220 0.0127412276 -0.0734656045
[121] -0.2357769876 -0.1054609554 -0.3435802198 0.2896522019 -0.0525630028
[126] -0.6037162264 -0.3287802462 -0.3132595224 0.1960476671 -0.4040657955
[131] -0.0785643453 0.6291666224 -0.8647101286 0.3539534301 0.1110393699
[136] 0.0545888074 0.0262637843 -0.1280574841 -0.1488250455 -0.1505202200
[141] -0.1144783471 0.4853892008 0.2757173665 0.0610519878 0.2502924033
[146] -0.3972684776 0.0219554802 -0.7576775151 -0.4347499762 0.1387377372
[151] 0.6667150111 -0.3280146131 -0.4066254489 -0.0114184794 0.0792367698
[156] 0.2428962197 0.5715931858 0.0314751886 0.2249752435 -0.1418443320
[161] 0.0622324599 0.3454796599 0.2321228156 0.5255344264 0.5027564871
[166] 0.1450094915 0.0612770599 -0.1417492285 0.3987033949 -0.0489149078
[171] -0.2226627153 0.1642078394 -0.0291309053 -0.0414030002 0.3068948868
[176] 0.0491779697 0.0648602928 0.0645904919 0.0649801476 0.1071632488
[181] 0.2875323534 0.1245970495 -0.2165193356 0.3924899059 0.1907878292
[186] -0.3283375643 -0.2217146148 -0.1896780879 0.0227404464 0.0215275386
[191] 0.1272979488 -0.3646227349 0.2722119877 0.4920621378 -0.2554396019
[196] 0.0045993826 -0.1953545480 -0.5211083186 0.0861856150 0.0888719184
[201] 0.0609807658 0.0749962001 -0.4063134216 -0.5234231692 -0.6310261162
[206] -0.0848813308 0.1629838249 -0.0083883289 -0.4184928769 0.4559979467
[211] 0.1775780084 -0.2789713329 -0.3434279666 -0.4893558770 0.0144394805
[216] -0.5000378629 0.4388403731 -0.0229130367 -0.0311036216 0.0694487822
[221] -0.1550512806 0.0165396947 -0.4912797864 0.3288676168 -0.3386751495
[226] 0.3802085690 0.3338070569 0.0539624068 0.1664244383 0.0219762068
>
> proc.time()
user system elapsed
3.34 8.15 11.87
|
BufferedMatrix.Rcheck/tests_x64/objectTesting.Rout
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(BufferedMatrix);library.dynam("BufferedMatrix","BufferedMatrix", .libPaths());
Attaching package: 'BufferedMatrix'
The following objects are masked from 'package:base':
colMeans, colSums, rowMeans, rowSums
>
>
> ### this is used to control how many repetitions in something below
> ### higher values result in more checks.
> nreps <-100 ##20000
>
>
> ## test creation and some simple assignments and subsetting operations
>
> ## first on single elements
> tmp <- createBufferedMatrix(1000,10)
>
> tmp[10,5]
[1] 0
> tmp[10,5] <- 10
> tmp[10,5]
[1] 10
> tmp[10,5] <- 12.445
> tmp[10,5]
[1] 12.445
>
>
>
> ## now testing accessing multiple elements
> tmp2 <- createBufferedMatrix(10,20)
>
>
> tmp2[3,1] <- 51.34
> tmp2[9,2] <- 9.87654
> tmp2[,1:2]
[,1] [,2]
[1,] 0.00 0.00000
[2,] 0.00 0.00000
[3,] 51.34 0.00000
[4,] 0.00 0.00000
[5,] 0.00 0.00000
[6,] 0.00 0.00000
[7,] 0.00 0.00000
[8,] 0.00 0.00000
[9,] 0.00 9.87654
[10,] 0.00 0.00000
> tmp2[,-(3:20)]
[,1] [,2]
[1,] 0.00 0.00000
[2,] 0.00 0.00000
[3,] 51.34 0.00000
[4,] 0.00 0.00000
[5,] 0.00 0.00000
[6,] 0.00 0.00000
[7,] 0.00 0.00000
[8,] 0.00 0.00000
[9,] 0.00 9.87654
[10,] 0.00 0.00000
> tmp2[3,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 51.34 0 0 0 0 0 0 0 0 0 0 0 0
[,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] 0 0 0 0 0 0 0
> tmp2[-3,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[2,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[3,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[4,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[5,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[6,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[7,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[8,] 0 9.87654 0 0 0 0 0 0 0 0 0 0 0
[9,] 0 0.00000 0 0 0 0 0 0 0 0 0 0 0
[,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] 0 0 0 0 0 0 0
[2,] 0 0 0 0 0 0 0
[3,] 0 0 0 0 0 0 0
[4,] 0 0 0 0 0 0 0
[5,] 0 0 0 0 0 0 0
[6,] 0 0 0 0 0 0 0
[7,] 0 0 0 0 0 0 0
[8,] 0 0 0 0 0 0 0
[9,] 0 0 0 0 0 0 0
> tmp2[2,1:3]
[,1] [,2] [,3]
[1,] 0 0 0
> tmp2[3:9,1:3]
[,1] [,2] [,3]
[1,] 51.34 0.00000 0
[2,] 0.00 0.00000 0
[3,] 0.00 0.00000 0
[4,] 0.00 0.00000 0
[5,] 0.00 0.00000 0
[6,] 0.00 0.00000 0
[7,] 0.00 9.87654 0
> tmp2[-4,-4]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[2,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[3,] 51.34 0.00000 0 0 0 0 0 0 0 0 0 0 0
[4,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[5,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[6,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[7,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[8,] 0.00 9.87654 0 0 0 0 0 0 0 0 0 0 0
[9,] 0.00 0.00000 0 0 0 0 0 0 0 0 0 0 0
[,14] [,15] [,16] [,17] [,18] [,19]
[1,] 0 0 0 0 0 0
[2,] 0 0 0 0 0 0
[3,] 0 0 0 0 0 0
[4,] 0 0 0 0 0 0
[5,] 0 0 0 0 0 0
[6,] 0 0 0 0 0 0
[7,] 0 0 0 0 0 0
[8,] 0 0 0 0 0 0
[9,] 0 0 0 0 0 0
>
> ## now testing accessing/assigning multiple elements
> tmp3 <- createBufferedMatrix(10,10)
>
> for (i in 1:10){
+ for (j in 1:10){
+ tmp3[i,j] <- (j-1)*10 + i
+ }
+ }
>
> tmp3[2:4,2:4]
[,1] [,2] [,3]
[1,] 12 22 32
[2,] 13 23 33
[3,] 14 24 34
> tmp3[c(-10),c(2:4,2:4,10,1,2,1:10,10:1)]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,] 11 21 31 11 21 31 91 1 11 1 11 21 31
[2,] 12 22 32 12 22 32 92 2 12 2 12 22 32
[3,] 13 23 33 13 23 33 93 3 13 3 13 23 33
[4,] 14 24 34 14 24 34 94 4 14 4 14 24 34
[5,] 15 25 35 15 25 35 95 5 15 5 15 25 35
[6,] 16 26 36 16 26 36 96 6 16 6 16 26 36
[7,] 17 27 37 17 27 37 97 7 17 7 17 27 37
[8,] 18 28 38 18 28 38 98 8 18 8 18 28 38
[9,] 19 29 39 19 29 39 99 9 19 9 19 29 39
[,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
[1,] 41 51 61 71 81 91 91 81 71 61 51 41
[2,] 42 52 62 72 82 92 92 82 72 62 52 42
[3,] 43 53 63 73 83 93 93 83 73 63 53 43
[4,] 44 54 64 74 84 94 94 84 74 64 54 44
[5,] 45 55 65 75 85 95 95 85 75 65 55 45
[6,] 46 56 66 76 86 96 96 86 76 66 56 46
[7,] 47 57 67 77 87 97 97 87 77 67 57 47
[8,] 48 58 68 78 88 98 98 88 78 68 58 48
[9,] 49 59 69 79 89 99 99 89 79 69 59 49
[,26] [,27] [,28] [,29]
[1,] 31 21 11 1
[2,] 32 22 12 2
[3,] 33 23 13 3
[4,] 34 24 14 4
[5,] 35 25 15 5
[6,] 36 26 16 6
[7,] 37 27 17 7
[8,] 38 28 18 8
[9,] 39 29 19 9
> tmp3[-c(1:5),-c(6:10)]
[,1] [,2] [,3] [,4] [,5]
[1,] 6 16 26 36 46
[2,] 7 17 27 37 47
[3,] 8 18 28 38 48
[4,] 9 19 29 39 49
[5,] 10 20 30 40 50
>
> ## assignment of whole columns
> tmp3[,1] <- c(1:10*100.0)
> tmp3[,1:2] <- tmp3[,1:2]*100
> tmp3[,1:2] <- tmp3[,2:1]
> tmp3[,1:2]
[,1] [,2]
[1,] 1100 1e+04
[2,] 1200 2e+04
[3,] 1300 3e+04
[4,] 1400 4e+04
[5,] 1500 5e+04
[6,] 1600 6e+04
[7,] 1700 7e+04
[8,] 1800 8e+04
[9,] 1900 9e+04
[10,] 2000 1e+05
>
>
> tmp3[,-1] <- tmp3[,1:9]
> tmp3[,1:10]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1100 1100 1e+04 21 31 41 51 61 71 81
[2,] 1200 1200 2e+04 22 32 42 52 62 72 82
[3,] 1300 1300 3e+04 23 33 43 53 63 73 83
[4,] 1400 1400 4e+04 24 34 44 54 64 74 84
[5,] 1500 1500 5e+04 25 35 45 55 65 75 85
[6,] 1600 1600 6e+04 26 36 46 56 66 76 86
[7,] 1700 1700 7e+04 27 37 47 57 67 77 87
[8,] 1800 1800 8e+04 28 38 48 58 68 78 88
[9,] 1900 1900 9e+04 29 39 49 59 69 79 89
[10,] 2000 2000 1e+05 30 40 50 60 70 80 90
>
> tmp3[,1:2] <- rep(1,10)
> tmp3[,1:2] <- rep(1,20)
> tmp3[,1:2] <- matrix(c(1:5),1,5)
>
> tmp3[,-c(1:8)] <- matrix(c(1:5),1,5)
>
> tmp3[1,] <- 1:10
> tmp3[1,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 2 3 4 5 6 7 8 9 10
> tmp3[-1,] <- c(1,2)
> tmp3[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 2 3 4 5 6 7 8 9 10
[2,] 1 2 1 2 1 2 1 2 1 2
[3,] 2 1 2 1 2 1 2 1 2 1
[4,] 1 2 1 2 1 2 1 2 1 2
[5,] 2 1 2 1 2 1 2 1 2 1
[6,] 1 2 1 2 1 2 1 2 1 2
[7,] 2 1 2 1 2 1 2 1 2 1
[8,] 1 2 1 2 1 2 1 2 1 2
[9,] 2 1 2 1 2 1 2 1 2 1
[10,] 1 2 1 2 1 2 1 2 1 2
> tmp3[-c(1:8),] <- matrix(c(1:5),1,5)
> tmp3[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 2 3 4 5 6 7 8 9 10
[2,] 1 2 1 2 1 2 1 2 1 2
[3,] 2 1 2 1 2 1 2 1 2 1
[4,] 1 2 1 2 1 2 1 2 1 2
[5,] 2 1 2 1 2 1 2 1 2 1
[6,] 1 2 1 2 1 2 1 2 1 2
[7,] 2 1 2 1 2 1 2 1 2 1
[8,] 1 2 1 2 1 2 1 2 1 2
[9,] 1 3 5 2 4 1 3 5 2 4
[10,] 2 4 1 3 5 2 4 1 3 5
>
>
> tmp3[1:2,1:2] <- 5555.04
> tmp3[-(1:2),1:2] <- 1234.56789
>
>
>
> ## testing accessors for the directory and prefix
> directory(tmp3)
[1] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64"
> prefix(tmp3)
[1] "BM"
>
> ## testing if we can remove these objects
> rm(tmp, tmp2, tmp3)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 408057 21.8 849841 45.4 632071 33.8
Vcells 702566 5.4 8388608 64.0 1654127 12.7
>
>
>
>
> ##
> ## checking reads
> ##
>
> tmp2 <- createBufferedMatrix(10,20)
>
> test.sample <- rnorm(10*20)
>
> tmp2[1:10,1:20] <- test.sample
>
> test.matrix <- matrix(test.sample,10,20)
>
> ## testing reads
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ which.col <- sample(1:20,1)
+ if (tmp2[which.row,which.col] != test.matrix[which.row,which.col]){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,1)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> date()
[1] "Wed Oct 16 02:22:17 2019"
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
> date()
[1] "Wed Oct 16 02:22:17 2019"
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ which.col <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[which.row,which.col] == test.matrix[which.row,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
>
>
> RowMode(tmp2)
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ which.col <- sample(1:20,1)
+ if (tmp2[which.row,which.col] != test.matrix[which.row,which.col]){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,1)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,5,replace=TRUE)
+ if (!all(tmp2[,which.col] == test.matrix[,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ if (!all(tmp2[which.row,] == test.matrix[which.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
>
>
> date()
[1] "Wed Oct 16 02:22:19 2019"
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ which.col <- sample(1:20,5,replace=TRUE)
+ if (!all(tmp2[which.row,which.col] == test.matrix[which.row,which.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
> date()
[1] "Wed Oct 16 02:22:21 2019"
>
> ColMode(tmp2)
>
>
>
> ### Now testing assignments
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,1)
+
+ new.data <- rnorm(20)
+ tmp2[which.row,] <- new.data
+ test.matrix[which.row,] <- new.data
+ if (rep > 1){
+ if (!all(tmp2[prev.row,] == test.matrix[prev.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.row <- which.row
+
+ }
>
>
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,1)
+ new.data <- rnorm(10)
+ tmp2[,which.col] <- new.data
+ test.matrix[,which.col]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[,prev.col] == test.matrix[,prev.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.col <- which.col
+ }
>
>
>
>
>
> for (rep in 1:nreps){
+ which.col <- sample(1:20,5,replace=TRUE)
+ new.data <- matrix(rnorm(50),5,10)
+ tmp2[,which.col] <- new.data
+ test.matrix[,which.col]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[,prev.col] == test.matrix[,prev.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.col <- which.col
+ }
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ new.data <- matrix(rnorm(50),5,10)
+ tmp2[which.row,] <- new.data
+ test.matrix[which.row,]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[prev.row,] == test.matrix[prev.row,])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.row <- which.row
+ }
>
>
>
>
>
> for (rep in 1:nreps){
+ which.row <- sample(1:10,5,replace=TRUE)
+ which.col <- sample(1:20,5,replace=TRUE)
+ new.data <- matrix(rnorm(25),5,5)
+ tmp2[which.row,which.col] <- new.data
+ test.matrix[which.row,which.col]<- new.data
+
+ if (rep > 1){
+ if (!all(tmp2[prev.row,prev.col] == test.matrix[prev.row,prev.col])){
+ cat("incorrect agreement")
+ break;
+ }
+ }
+ prev.row <- which.row
+ prev.col <- which.col
+ }
>
>
>
>
> ###
> ###
> ### testing some more functions
> ###
>
>
>
> ## duplication function
> tmp5 <- duplicate(tmp2)
>
> # making sure really did copy everything.
> tmp5[1,1] <- tmp5[1,1] +100.00
>
> if (tmp5[1,1] == tmp2[1,1]){
+ stop("Problem with duplication")
+ }
>
>
>
>
> ### testing elementwise applying of functions
>
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 99.3805221 -0.07363331 1.5854162 -0.70361199
[2,] 1.7696392 -0.62911036 -1.0513359 -0.44717486
[3,] -1.2605285 0.15162452 0.0432175 -0.10313421
[4,] 0.8954874 -1.64775242 2.0812692 0.04836146
> ewApply(tmp5,abs)
BufferedMatrix object
Matrix size: 10 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 1.6 Kilobytes.
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 99.3805221 0.07363331 1.5854162 0.70361199
[2,] 1.7696392 0.62911036 1.0513359 0.44717486
[3,] 1.2605285 0.15162452 0.0432175 0.10313421
[4,] 0.8954874 1.64775242 2.0812692 0.04836146
> ewApply(tmp5,sqrt)
BufferedMatrix object
Matrix size: 10 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 1.6 Kilobytes.
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 9.9689780 0.2713546 1.2591331 0.8388158
[2,] 1.3302779 0.7931648 1.0253467 0.6687113
[3,] 1.1227326 0.3893899 0.2078882 0.3211452
[4,] 0.9463019 1.2836481 1.4426605 0.2199124
>
> my.function <- function(x,power){
+ (x+5)^power
+ }
>
> ewApply(tmp5,my.function,power=2)
BufferedMatrix object
Matrix size: 10 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 1.6 Kilobytes.
> tmp5[1:4,1:4]
[,1] [,2] [,3] [,4]
[1,] 224.07030 27.78718 39.17675 34.09177
[2,] 40.07242 33.56076 36.30480 32.13429
[3,] 37.48785 29.04552 27.12210 28.31459
[4,] 35.35851 39.48423 41.50787 27.24749
>
>
>
> ## testing functions that elementwise transform the matrix
> sqrt(tmp5)
> exp(tmp5)
> log(tmp5,2)
> pow(tmp5,2)
>
>
>
>
>
> ## testing functions that apply to entire matrix
> Max(tmp5)
[1] 466.373
> Min(tmp5)
[1] 52.83993
> mean(tmp5)
[1] 72.20877
> Sum(tmp5)
[1] 14441.75
> Var(tmp5)
[1] 851.2114
>
>
> ## testing functions applied to rows or columns
>
> rowMeans(tmp5)
[1] 90.66665 69.80618 68.95905 73.57910 71.83251 70.34997 68.29017 69.17932
[9] 68.82523 70.59947
> rowSums(tmp5)
[1] 1813.333 1396.124 1379.181 1471.582 1436.650 1406.999 1365.803 1383.586
[9] 1376.505 1411.989
> rowVars(tmp5)
[1] 7877.90202 60.54043 67.38696 118.72179 96.26411 56.43753
[7] 45.65362 45.36366 83.19841 41.67025
> rowSd(tmp5)
[1] 88.757546 7.780773 8.208956 10.895953 9.811428 7.512491 6.756746
[8] 6.735255 9.121316 6.455249
> rowMax(tmp5)
[1] 466.37298 88.19109 84.17669 98.72451 91.26594 84.40221 78.96034
[8] 77.91404 83.03101 82.74724
> rowMin(tmp5)
[1] 57.83537 55.39609 56.45110 56.71207 54.91348 56.12508 52.83993 55.70265
[9] 53.76566 55.18888
>
> colMeans(tmp5)
[1] 115.56747 69.30629 72.12724 66.78790 70.25189 71.74999 71.62534
[8] 70.33721 72.88728 69.21601 71.71634 67.66106 73.98748 72.17714
[15] 74.00336 62.25886 69.63556 68.69575 68.16108 66.02205
> colSums(tmp5)
[1] 1155.6747 693.0629 721.2724 667.8790 702.5189 717.4999 716.2534
[8] 703.3721 728.8728 692.1601 717.1634 676.6106 739.8748 721.7714
[15] 740.0336 622.5886 696.3556 686.9575 681.6108 660.2205
> colVars(tmp5)
[1] 15220.97229 59.88100 81.08352 40.64207 40.39066 140.37843
[7] 49.59940 101.84318 86.15597 45.34670 46.19900 102.25466
[13] 43.02332 54.70996 92.06856 26.37215 51.64246 13.36684
[19] 71.89697 81.15313
> colSd(tmp5)
[1] 123.373305 7.738282 9.004639 6.375113 6.355365 11.848140
[7] 7.042684 10.091738 9.282024 6.733996 6.796985 10.112105
[13] 6.559216 7.396618 9.595236 5.135382 7.186269 3.656069
[19] 8.479208 9.008503
> colMax(tmp5)
[1] 466.37298 82.18126 86.39320 76.96498 82.79925 90.66133 82.32538
[8] 91.26594 86.26515 79.11115 85.95403 80.87353 87.19081 84.40221
[15] 98.72451 70.32383 84.32901 73.60487 88.19109 83.03101
> colMin(tmp5)
[1] 68.66745 57.83537 56.45110 56.71207 62.94441 55.70265 59.83435 57.25446
[9] 53.76566 58.93070 64.55819 52.83993 62.73913 59.56466 65.49628 55.18888
[17] 61.41332 61.08404 57.12616 54.91348
>
>
> ### setting a random element to NA and then testing with na.rm=TRUE or na.rm=FALSE (The default)
>
>
> which.row <- sample(1:10,1,replace=TRUE)
> which.col <- sample(1:20,1,replace=TRUE)
>
> tmp5[which.row,which.col] <- NA
>
> Max(tmp5)
[1] NA
> Min(tmp5)
[1] NA
> mean(tmp5)
[1] NA
> Sum(tmp5)
[1] NA
> Var(tmp5)
[1] NA
>
> rowMeans(tmp5)
[1] 90.66665 69.80618 68.95905 NA 71.83251 70.34997 68.29017 69.17932
[9] 68.82523 70.59947
> rowSums(tmp5)
[1] 1813.333 1396.124 1379.181 NA 1436.650 1406.999 1365.803 1383.586
[9] 1376.505 1411.989
> rowVars(tmp5)
[1] 7877.90202 60.54043 67.38696 116.18723 96.26411 56.43753
[7] 45.65362 45.36366 83.19841 41.67025
> rowSd(tmp5)
[1] 88.757546 7.780773 8.208956 10.779018 9.811428 7.512491 6.756746
[8] 6.735255 9.121316 6.455249
> rowMax(tmp5)
[1] 466.37298 88.19109 84.17669 NA 91.26594 84.40221 78.96034
[8] 77.91404 83.03101 82.74724
> rowMin(tmp5)
[1] 57.83537 55.39609 56.45110 NA 54.91348 56.12508 52.83993 55.70265
[9] 53.76566 55.18888
>
> colMeans(tmp5)
[1] 115.56747 69.30629 72.12724 66.78790 70.25189 71.74999 71.62534
[8] 70.33721 72.88728 69.21601 71.71634 67.66106 73.98748 72.17714
[15] 74.00336 62.25886 69.63556 NA 68.16108 66.02205
> colSums(tmp5)
[1] 1155.6747 693.0629 721.2724 667.8790 702.5189 717.4999 716.2534
[8] 703.3721 728.8728 692.1601 717.1634 676.6106 739.8748 721.7714
[15] 740.0336 622.5886 696.3556 NA 681.6108 660.2205
> colVars(tmp5)
[1] 15220.97229 59.88100 81.08352 40.64207 40.39066 140.37843
[7] 49.59940 101.84318 86.15597 45.34670 46.19900 102.25466
[13] 43.02332 54.70996 92.06856 26.37215 51.64246 NA
[19] 71.89697 81.15313
> colSd(tmp5)
[1] 123.373305 7.738282 9.004639 6.375113 6.355365 11.848140
[7] 7.042684 10.091738 9.282024 6.733996 6.796985 10.112105
[13] 6.559216 7.396618 9.595236 5.135382 7.186269 NA
[19] 8.479208 9.008503
> colMax(tmp5)
[1] 466.37298 82.18126 86.39320 76.96498 82.79925 90.66133 82.32538
[8] 91.26594 86.26515 79.11115 85.95403 80.87353 87.19081 84.40221
[15] 98.72451 70.32383 84.32901 NA 88.19109 83.03101
> colMin(tmp5)
[1] 68.66745 57.83537 56.45110 56.71207 62.94441 55.70265 59.83435 57.25446
[9] 53.76566 58.93070 64.55819 52.83993 62.73913 59.56466 65.49628 55.18888
[17] 61.41332 NA 57.12616 54.91348
>
> Max(tmp5,na.rm=TRUE)
[1] 466.373
> Min(tmp5,na.rm=TRUE)
[1] 52.83993
> mean(tmp5,na.rm=TRUE)
[1] 72.26467
> Sum(tmp5,na.rm=TRUE)
[1] 14380.67
> Var(tmp5,na.rm=TRUE)
[1] 854.8823
>
> rowMeans(tmp5,na.rm=TRUE)
[1] 90.66665 69.80618 68.95905 74.23674 71.83251 70.34997 68.29017 69.17932
[9] 68.82523 70.59947
> rowSums(tmp5,na.rm=TRUE)
[1] 1813.333 1396.124 1379.181 1410.498 1436.650 1406.999 1365.803 1383.586
[9] 1376.505 1411.989
> rowVars(tmp5,na.rm=TRUE)
[1] 7877.90202 60.54043 67.38696 116.18723 96.26411 56.43753
[7] 45.65362 45.36366 83.19841 41.67025
> rowSd(tmp5,na.rm=TRUE)
[1] 88.757546 7.780773 8.208956 10.779018 9.811428 7.512491 6.756746
[8] 6.735255 9.121316 6.455249
> rowMax(tmp5,na.rm=TRUE)
[1] 466.37298 88.19109 84.17669 98.72451 91.26594 84.40221 78.96034
[8] 77.91404 83.03101 82.74724
> rowMin(tmp5,na.rm=TRUE)
[1] 57.83537 55.39609 56.45110 56.71207 54.91348 56.12508 52.83993 55.70265
[9] 53.76566 55.18888
>
> colMeans(tmp5,na.rm=TRUE)
[1] 115.56747 69.30629 72.12724 66.78790 70.25189 71.74999 71.62534
[8] 70.33721 72.88728 69.21601 71.71634 67.66106 73.98748 72.17714
[15] 74.00336 62.25886 69.63556 69.54150 68.16108 66.02205
> colSums(tmp5,na.rm=TRUE)
[1] 1155.6747 693.0629 721.2724 667.8790 702.5189 717.4999 716.2534
[8] 703.3721 728.8728 692.1601 717.1634 676.6106 739.8748 721.7714
[15] 740.0336 622.5886 696.3556 625.8735 681.6108 660.2205
> colVars(tmp5,na.rm=TRUE)
[1] 15220.97229 59.88100 81.08352 40.64207 40.39066 140.37843
[7] 49.59940 101.84318 86.15597 45.34670 46.19900 102.25466
[13] 43.02332 54.70996 92.06856 26.37215 51.64246 6.99072
[19] 71.89697 81.15313
> colSd(tmp5,na.rm=TRUE)
[1] 123.373305 7.738282 9.004639 6.375113 6.355365 11.848140
[7] 7.042684 10.091738 9.282024 6.733996 6.796985 10.112105
[13] 6.559216 7.396618 9.595236 5.135382 7.186269 2.643997
[19] 8.479208 9.008503
> colMax(tmp5,na.rm=TRUE)
[1] 466.37298 82.18126 86.39320 76.96498 82.79925 90.66133 82.32538
[8] 91.26594 86.26515 79.11115 85.95403 80.87353 87.19081 84.40221
[15] 98.72451 70.32383 84.32901 73.60487 88.19109 83.03101
> colMin(tmp5,na.rm=TRUE)
[1] 68.66745 57.83537 56.45110 56.71207 62.94441 55.70265 59.83435 57.25446
[9] 53.76566 58.93070 64.55819 52.83993 62.73913 59.56466 65.49628 55.18888
[17] 61.41332 65.62153 57.12616 54.91348
>
> # now set an entire row to NA
>
> tmp5[which.row,] <- NA
> rowMeans(tmp5,na.rm=TRUE)
[1] 90.66665 69.80618 68.95905 NaN 71.83251 70.34997 68.29017 69.17932
[9] 68.82523 70.59947
> rowSums(tmp5,na.rm=TRUE)
[1] 1813.333 1396.124 1379.181 0.000 1436.650 1406.999 1365.803 1383.586
[9] 1376.505 1411.989
> rowVars(tmp5,na.rm=TRUE)
[1] 7877.90202 60.54043 67.38696 NA 96.26411 56.43753
[7] 45.65362 45.36366 83.19841 41.67025
> rowSd(tmp5,na.rm=TRUE)
[1] 88.757546 7.780773 8.208956 NA 9.811428 7.512491 6.756746
[8] 6.735255 9.121316 6.455249
> rowMax(tmp5,na.rm=TRUE)
[1] 466.37298 88.19109 84.17669 NA 91.26594 84.40221 78.96034
[8] 77.91404 83.03101 82.74724
> rowMin(tmp5,na.rm=TRUE)
[1] 57.83537 55.39609 56.45110 NA 54.91348 56.12508 52.83993 55.70265
[9] 53.76566 55.18888
>
>
> # now set an entire col to NA
>
>
> tmp5[,which.col] <- NA
> colMeans(tmp5,na.rm=TRUE)
[1] 120.23117 67.87574 70.54213 67.90743 70.19628 70.94255 72.20841
[8] 70.41648 73.25755 70.35882 70.13438 66.25440 73.35858 72.64645
[15] 71.25656 62.57635 68.00296 NaN 68.09758 65.32480
> colSums(tmp5,na.rm=TRUE)
[1] 1082.0806 610.8816 634.8792 611.1669 631.7665 638.4829 649.8757
[8] 633.7483 659.3179 633.2294 631.2094 596.2896 660.2272 653.8180
[15] 641.3091 563.1871 612.0266 0.0000 612.8782 587.9232
> colVars(tmp5,na.rm=TRUE)
[1] 16878.90444 44.34324 62.95261 31.62201 45.40470 150.59112
[7] 51.97454 114.50289 95.38309 36.32231 23.81945 92.77625
[13] 43.95161 59.07093 18.69721 28.53471 28.11204 NA
[19] 80.83872 85.82801
> colSd(tmp5,na.rm=TRUE)
[1] 129.918838 6.659072 7.934268 5.623345 6.738301 12.271557
[7] 7.209337 10.700602 9.766427 6.026799 4.880518 9.632043
[13] 6.629601 7.685761 4.324027 5.341789 5.302079 NA
[19] 8.991036 9.264341
> colMax(tmp5,na.rm=TRUE)
[1] 466.37298 74.46443 81.54127 76.96498 82.79925 90.66133 82.32538
[8] 91.26594 86.26515 79.11115 78.36203 80.87353 87.19081 84.40221
[15] 78.22796 70.32383 74.73155 -Inf 88.19109 83.03101
> colMin(tmp5,na.rm=TRUE)
[1] 68.66745 57.83537 56.45110 58.93310 62.94441 55.70265 59.83435 57.25446
[9] 53.76566 61.54799 64.55819 52.83993 62.73913 59.56466 65.49628 55.18888
[17] 61.41332 Inf 57.12616 54.91348
>
>
>
>
> copymatrix <- matrix(rnorm(200,150,15),10,20)
>
> tmp5[1:10,1:20] <- copymatrix
> which.row <- 3
> which.col <- 1
> cat(which.row," ",which.col,"\n")
3 1
> tmp5[which.row,which.col] <- NA
> copymatrix[which.row,which.col] <- NA
>
> rowVars(tmp5,na.rm=TRUE)
[1] 175.9693 151.2492 171.7193 169.1034 370.5854 250.2965 207.0386 218.1400
[9] 221.5229 301.4261
> apply(copymatrix,1,var,na.rm=TRUE)
[1] 175.9693 151.2492 171.7193 169.1034 370.5854 250.2965 207.0386 218.1400
[9] 221.5229 301.4261
>
>
>
> copymatrix <- matrix(rnorm(200,150,15),10,20)
>
> tmp5[1:10,1:20] <- copymatrix
> which.row <- 1
> which.col <- 3
> cat(which.row," ",which.col,"\n")
1 3
> tmp5[which.row,which.col] <- NA
> copymatrix[which.row,which.col] <- NA
>
> colVars(tmp5,na.rm=TRUE)-apply(copymatrix,2,var,na.rm=TRUE)
[1] 0.000000e+00 -2.842171e-14 8.526513e-14 0.000000e+00 -1.136868e-13
[6] 8.526513e-14 -1.421085e-14 -2.842171e-14 -5.684342e-14 0.000000e+00
[11] -5.684342e-14 0.000000e+00 1.989520e-13 0.000000e+00 -1.989520e-13
[16] 2.842171e-14 2.273737e-13 8.526513e-14 0.000000e+00 7.105427e-14
>
>
>
>
>
>
>
>
>
>
> ## making sure these things agree
> ##
> ## first when there is no NA
>
>
>
> agree.checks <- function(buff.matrix,r.matrix,err.tol=1e-10){
+
+ if (Max(buff.matrix,na.rm=TRUE) != max(r.matrix,na.rm=TRUE)){
+ stop("No agreement in Max")
+ }
+
+
+ if (Min(buff.matrix,na.rm=TRUE) != min(r.matrix,na.rm=TRUE)){
+ stop("No agreement in Min")
+ }
+
+
+ if (abs(Sum(buff.matrix,na.rm=TRUE)- sum(r.matrix,na.rm=TRUE)) > err.tol){
+
+ cat(Sum(buff.matrix,na.rm=TRUE),"\n")
+ cat(sum(r.matrix,na.rm=TRUE),"\n")
+ cat(Sum(buff.matrix,na.rm=TRUE) - sum(r.matrix,na.rm=TRUE),"\n")
+
+ stop("No agreement in Sum")
+ }
+
+ if (abs(mean(buff.matrix,na.rm=TRUE) - mean(r.matrix,na.rm=TRUE)) > err.tol){
+ stop("No agreement in mean")
+ }
+
+
+ if(abs(Var(buff.matrix,na.rm=TRUE) - var(as.vector(r.matrix),na.rm=TRUE)) > err.tol){
+ stop("No agreement in Var")
+ }
+
+
+
+ if(any(abs(rowMeans(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,mean,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in rowMeans")
+ }
+
+
+ if(any(abs(colMeans(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,mean,na.rm=TRUE))> err.tol,na.rm=TRUE)){
+ stop("No agreement in colMeans")
+ }
+
+
+ if(any(abs(rowSums(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,sum,na.rm=TRUE))> err.tol,na.rm=TRUE)){
+ stop("No agreement in rowSums")
+ }
+
+
+ if(any(abs(colSums(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,sum,na.rm=TRUE))> err.tol,na.rm=TRUE)){
+ stop("No agreement in colSums")
+ }
+
+ ### this is to get around the fact that R doesn't like to compute NA on an entire vector of NA when
+ ### computing variance
+ my.Var <- function(x,na.rm=FALSE){
+ if (all(is.na(x))){
+ return(NA)
+ } else {
+ var(x,na.rm=na.rm)
+ }
+
+ }
+
+ if(any(abs(rowVars(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,my.Var,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in rowVars")
+ }
+
+
+ if(any(abs(colVars(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,my.Var,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in rowVars")
+ }
+
+
+ if(any(abs(rowMax(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,max,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMax")
+ }
+
+
+ if(any(abs(colMax(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,max,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMax")
+ }
+
+
+
+ if(any(abs(rowMin(buff.matrix,na.rm=TRUE) - apply(r.matrix,1,min,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMin")
+ }
+
+
+ if(any(abs(colMin(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,min,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMin")
+ }
+
+ if(any(abs(colMedians(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,median,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colMedian")
+ }
+
+ if(any(abs(colRanges(buff.matrix,na.rm=TRUE) - apply(r.matrix,2,range,na.rm=TRUE)) > err.tol,na.rm=TRUE)){
+ stop("No agreement in colRanges")
+ }
+
+
+
+ }
>
>
>
>
>
>
>
>
>
> for (rep in 1:20){
+ copymatrix <- matrix(rnorm(200,150,15),10,20)
+
+ tmp5[1:10,1:20] <- copymatrix
+
+
+ agree.checks(tmp5,copymatrix)
+
+ ## now lets assign some NA values and check agreement
+
+ which.row <- sample(1:10,1,replace=TRUE)
+ which.col <- sample(1:20,1,replace=TRUE)
+
+ cat(which.row," ",which.col,"\n")
+
+ tmp5[which.row,which.col] <- NA
+ copymatrix[which.row,which.col] <- NA
+
+ agree.checks(tmp5,copymatrix)
+
+ ## make an entire row NA
+ tmp5[which.row,] <- NA
+ copymatrix[which.row,] <- NA
+
+
+ agree.checks(tmp5,copymatrix)
+
+ ### also make an entire col NA
+ tmp5[,which.col] <- NA
+ copymatrix[,which.col] <- NA
+
+ agree.checks(tmp5,copymatrix)
+
+ ### now make 1 element non NA with NA in the rest of row and column
+
+ tmp5[which.row,which.col] <- rnorm(1,150,15)
+ copymatrix[which.row,which.col] <- tmp5[which.row,which.col]
+
+ agree.checks(tmp5,copymatrix)
+ }
8 18
5 1
10 8
2 6
2 17
5 13
9 20
2 14
4 16
6 18
1 12
7 9
6 2
5 8
9 8
2 2
5 19
7 18
1 20
5 6
There were 50 or more warnings (use warnings() to see the first 50)
>
>
> ### now test 1 by n and n by 1 matrix
>
>
> err.tol <- 1e-12
>
> rm(tmp5)
>
> dataset1 <- rnorm(100)
> dataset2 <- rnorm(100)
>
> tmp <- createBufferedMatrix(1,100)
> tmp[1,] <- dataset1
>
> tmp2 <- createBufferedMatrix(100,1)
> tmp2[,1] <- dataset2
>
>
>
>
>
> Max(tmp)
[1] 2.065205
> Min(tmp)
[1] -1.980141
> mean(tmp)
[1] 0.01516715
> Sum(tmp)
[1] 1.516715
> Var(tmp)
[1] 0.8499396
>
> rowMeans(tmp)
[1] 0.01516715
> rowSums(tmp)
[1] 1.516715
> rowVars(tmp)
[1] 0.8499396
> rowSd(tmp)
[1] 0.9219217
> rowMax(tmp)
[1] 2.065205
> rowMin(tmp)
[1] -1.980141
>
> colMeans(tmp)
[1] 0.09152705 -0.96823684 1.65535405 0.02646867 0.19027912 -0.44266756
[7] 1.28477106 -0.35231100 0.07336815 0.80935122 0.01113923 1.06606789
[13] -0.90452659 -0.01136166 -0.91294895 0.25749550 -0.59084750 -0.81133073
[19] 0.60518446 -1.25139632 0.47526529 0.60529039 0.48962631 0.17542717
[25] -0.80282337 -1.52592323 -0.85220261 -0.79945245 -0.35900929 -0.35262166
[31] -0.84335799 1.52017012 -1.18553187 0.47416105 0.41209011 -0.96153687
[37] -0.13671442 -1.43826289 -0.92287138 -1.98014133 0.98997075 -0.62893056
[43] -0.04056852 -0.21790782 0.28638290 0.14145493 1.01213619 0.31915023
[49] -1.12082423 0.90845114 0.32673711 0.02826049 0.51614831 -0.69880364
[55] -1.43009265 0.47359133 0.61789390 -1.70356606 1.63611828 1.02142692
[61] 1.30863802 0.47088437 -1.07682049 0.50469570 -0.16796567 -1.37389447
[67] -1.10985400 0.06510832 -0.56803806 0.07702034 -0.06714373 0.26083477
[73] -0.88906444 0.07311281 0.31283783 -1.54100194 1.45718801 -0.54801734
[79] 0.97269885 1.09784193 0.22240293 0.61336363 2.06520484 -1.39726061
[85] 0.16774483 -0.28561172 0.24024783 -0.31249435 1.39128569 -1.56410419
[91] 1.11564945 1.84763135 0.64747487 1.35413222 -1.04373982 1.37398813
[97] -0.05341379 -0.54995973 0.58500884 1.58611496
> colSums(tmp)
[1] 0.09152705 -0.96823684 1.65535405 0.02646867 0.19027912 -0.44266756
[7] 1.28477106 -0.35231100 0.07336815 0.80935122 0.01113923 1.06606789
[13] -0.90452659 -0.01136166 -0.91294895 0.25749550 -0.59084750 -0.81133073
[19] 0.60518446 -1.25139632 0.47526529 0.60529039 0.48962631 0.17542717
[25] -0.80282337 -1.52592323 -0.85220261 -0.79945245 -0.35900929 -0.35262166
[31] -0.84335799 1.52017012 -1.18553187 0.47416105 0.41209011 -0.96153687
[37] -0.13671442 -1.43826289 -0.92287138 -1.98014133 0.98997075 -0.62893056
[43] -0.04056852 -0.21790782 0.28638290 0.14145493 1.01213619 0.31915023
[49] -1.12082423 0.90845114 0.32673711 0.02826049 0.51614831 -0.69880364
[55] -1.43009265 0.47359133 0.61789390 -1.70356606 1.63611828 1.02142692
[61] 1.30863802 0.47088437 -1.07682049 0.50469570 -0.16796567 -1.37389447
[67] -1.10985400 0.06510832 -0.56803806 0.07702034 -0.06714373 0.26083477
[73] -0.88906444 0.07311281 0.31283783 -1.54100194 1.45718801 -0.54801734
[79] 0.97269885 1.09784193 0.22240293 0.61336363 2.06520484 -1.39726061
[85] 0.16774483 -0.28561172 0.24024783 -0.31249435 1.39128569 -1.56410419
[91] 1.11564945 1.84763135 0.64747487 1.35413222 -1.04373982 1.37398813
[97] -0.05341379 -0.54995973 0.58500884 1.58611496
> colVars(tmp)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> colSd(tmp)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> colMax(tmp)
[1] 0.09152705 -0.96823684 1.65535405 0.02646867 0.19027912 -0.44266756
[7] 1.28477106 -0.35231100 0.07336815 0.80935122 0.01113923 1.06606789
[13] -0.90452659 -0.01136166 -0.91294895 0.25749550 -0.59084750 -0.81133073
[19] 0.60518446 -1.25139632 0.47526529 0.60529039 0.48962631 0.17542717
[25] -0.80282337 -1.52592323 -0.85220261 -0.79945245 -0.35900929 -0.35262166
[31] -0.84335799 1.52017012 -1.18553187 0.47416105 0.41209011 -0.96153687
[37] -0.13671442 -1.43826289 -0.92287138 -1.98014133 0.98997075 -0.62893056
[43] -0.04056852 -0.21790782 0.28638290 0.14145493 1.01213619 0.31915023
[49] -1.12082423 0.90845114 0.32673711 0.02826049 0.51614831 -0.69880364
[55] -1.43009265 0.47359133 0.61789390 -1.70356606 1.63611828 1.02142692
[61] 1.30863802 0.47088437 -1.07682049 0.50469570 -0.16796567 -1.37389447
[67] -1.10985400 0.06510832 -0.56803806 0.07702034 -0.06714373 0.26083477
[73] -0.88906444 0.07311281 0.31283783 -1.54100194 1.45718801 -0.54801734
[79] 0.97269885 1.09784193 0.22240293 0.61336363 2.06520484 -1.39726061
[85] 0.16774483 -0.28561172 0.24024783 -0.31249435 1.39128569 -1.56410419
[91] 1.11564945 1.84763135 0.64747487 1.35413222 -1.04373982 1.37398813
[97] -0.05341379 -0.54995973 0.58500884 1.58611496
> colMin(tmp)
[1] 0.09152705 -0.96823684 1.65535405 0.02646867 0.19027912 -0.44266756
[7] 1.28477106 -0.35231100 0.07336815 0.80935122 0.01113923 1.06606789
[13] -0.90452659 -0.01136166 -0.91294895 0.25749550 -0.59084750 -0.81133073
[19] 0.60518446 -1.25139632 0.47526529 0.60529039 0.48962631 0.17542717
[25] -0.80282337 -1.52592323 -0.85220261 -0.79945245 -0.35900929 -0.35262166
[31] -0.84335799 1.52017012 -1.18553187 0.47416105 0.41209011 -0.96153687
[37] -0.13671442 -1.43826289 -0.92287138 -1.98014133 0.98997075 -0.62893056
[43] -0.04056852 -0.21790782 0.28638290 0.14145493 1.01213619 0.31915023
[49] -1.12082423 0.90845114 0.32673711 0.02826049 0.51614831 -0.69880364
[55] -1.43009265 0.47359133 0.61789390 -1.70356606 1.63611828 1.02142692
[61] 1.30863802 0.47088437 -1.07682049 0.50469570 -0.16796567 -1.37389447
[67] -1.10985400 0.06510832 -0.56803806 0.07702034 -0.06714373 0.26083477
[73] -0.88906444 0.07311281 0.31283783 -1.54100194 1.45718801 -0.54801734
[79] 0.97269885 1.09784193 0.22240293 0.61336363 2.06520484 -1.39726061
[85] 0.16774483 -0.28561172 0.24024783 -0.31249435 1.39128569 -1.56410419
[91] 1.11564945 1.84763135 0.64747487 1.35413222 -1.04373982 1.37398813
[97] -0.05341379 -0.54995973 0.58500884 1.58611496
> colMedians(tmp)
[1] 0.09152705 -0.96823684 1.65535405 0.02646867 0.19027912 -0.44266756
[7] 1.28477106 -0.35231100 0.07336815 0.80935122 0.01113923 1.06606789
[13] -0.90452659 -0.01136166 -0.91294895 0.25749550 -0.59084750 -0.81133073
[19] 0.60518446 -1.25139632 0.47526529 0.60529039 0.48962631 0.17542717
[25] -0.80282337 -1.52592323 -0.85220261 -0.79945245 -0.35900929 -0.35262166
[31] -0.84335799 1.52017012 -1.18553187 0.47416105 0.41209011 -0.96153687
[37] -0.13671442 -1.43826289 -0.92287138 -1.98014133 0.98997075 -0.62893056
[43] -0.04056852 -0.21790782 0.28638290 0.14145493 1.01213619 0.31915023
[49] -1.12082423 0.90845114 0.32673711 0.02826049 0.51614831 -0.69880364
[55] -1.43009265 0.47359133 0.61789390 -1.70356606 1.63611828 1.02142692
[61] 1.30863802 0.47088437 -1.07682049 0.50469570 -0.16796567 -1.37389447
[67] -1.10985400 0.06510832 -0.56803806 0.07702034 -0.06714373 0.26083477
[73] -0.88906444 0.07311281 0.31283783 -1.54100194 1.45718801 -0.54801734
[79] 0.97269885 1.09784193 0.22240293 0.61336363 2.06520484 -1.39726061
[85] 0.16774483 -0.28561172 0.24024783 -0.31249435 1.39128569 -1.56410419
[91] 1.11564945 1.84763135 0.64747487 1.35413222 -1.04373982 1.37398813
[97] -0.05341379 -0.54995973 0.58500884 1.58611496
> colRanges(tmp)
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0.09152705 -0.9682368 1.655354 0.02646867 0.1902791 -0.4426676 1.284771
[2,] 0.09152705 -0.9682368 1.655354 0.02646867 0.1902791 -0.4426676 1.284771
[,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] -0.352311 0.07336815 0.8093512 0.01113923 1.066068 -0.9045266 -0.01136166
[2,] -0.352311 0.07336815 0.8093512 0.01113923 1.066068 -0.9045266 -0.01136166
[,15] [,16] [,17] [,18] [,19] [,20] [,21]
[1,] -0.9129489 0.2574955 -0.5908475 -0.8113307 0.6051845 -1.251396 0.4752653
[2,] -0.9129489 0.2574955 -0.5908475 -0.8113307 0.6051845 -1.251396 0.4752653
[,22] [,23] [,24] [,25] [,26] [,27] [,28]
[1,] 0.6052904 0.4896263 0.1754272 -0.8028234 -1.525923 -0.8522026 -0.7994525
[2,] 0.6052904 0.4896263 0.1754272 -0.8028234 -1.525923 -0.8522026 -0.7994525
[,29] [,30] [,31] [,32] [,33] [,34] [,35]
[1,] -0.3590093 -0.3526217 -0.843358 1.52017 -1.185532 0.474161 0.4120901
[2,] -0.3590093 -0.3526217 -0.843358 1.52017 -1.185532 0.474161 0.4120901
[,36] [,37] [,38] [,39] [,40] [,41] [,42]
[1,] -0.9615369 -0.1367144 -1.438263 -0.9228714 -1.980141 0.9899707 -0.6289306
[2,] -0.9615369 -0.1367144 -1.438263 -0.9228714 -1.980141 0.9899707 -0.6289306
[,43] [,44] [,45] [,46] [,47] [,48] [,49]
[1,] -0.04056852 -0.2179078 0.2863829 0.1414549 1.012136 0.3191502 -1.120824
[2,] -0.04056852 -0.2179078 0.2863829 0.1414549 1.012136 0.3191502 -1.120824
[,50] [,51] [,52] [,53] [,54] [,55] [,56]
[1,] 0.9084511 0.3267371 0.02826049 0.5161483 -0.6988036 -1.430093 0.4735913
[2,] 0.9084511 0.3267371 0.02826049 0.5161483 -0.6988036 -1.430093 0.4735913
[,57] [,58] [,59] [,60] [,61] [,62] [,63]
[1,] 0.6178939 -1.703566 1.636118 1.021427 1.308638 0.4708844 -1.07682
[2,] 0.6178939 -1.703566 1.636118 1.021427 1.308638 0.4708844 -1.07682
[,64] [,65] [,66] [,67] [,68] [,69] [,70]
[1,] 0.5046957 -0.1679657 -1.373894 -1.109854 0.06510832 -0.5680381 0.07702034
[2,] 0.5046957 -0.1679657 -1.373894 -1.109854 0.06510832 -0.5680381 0.07702034
[,71] [,72] [,73] [,74] [,75] [,76] [,77]
[1,] -0.06714373 0.2608348 -0.8890644 0.07311281 0.3128378 -1.541002 1.457188
[2,] -0.06714373 0.2608348 -0.8890644 0.07311281 0.3128378 -1.541002 1.457188
[,78] [,79] [,80] [,81] [,82] [,83] [,84]
[1,] -0.5480173 0.9726989 1.097842 0.2224029 0.6133636 2.065205 -1.397261
[2,] -0.5480173 0.9726989 1.097842 0.2224029 0.6133636 2.065205 -1.397261
[,85] [,86] [,87] [,88] [,89] [,90] [,91]
[1,] 0.1677448 -0.2856117 0.2402478 -0.3124943 1.391286 -1.564104 1.115649
[2,] 0.1677448 -0.2856117 0.2402478 -0.3124943 1.391286 -1.564104 1.115649
[,92] [,93] [,94] [,95] [,96] [,97] [,98]
[1,] 1.847631 0.6474749 1.354132 -1.04374 1.373988 -0.05341379 -0.5499597
[2,] 1.847631 0.6474749 1.354132 -1.04374 1.373988 -0.05341379 -0.5499597
[,99] [,100]
[1,] 0.5850088 1.586115
[2,] 0.5850088 1.586115
>
>
> Max(tmp2)
[1] 2.761696
> Min(tmp2)
[1] -1.842833
> mean(tmp2)
[1] 0.1487732
> Sum(tmp2)
[1] 14.87732
> Var(tmp2)
[1] 0.9326063
>
> rowMeans(tmp2)
[1] -0.54110957 -0.30100102 0.74403409 0.35014434 0.43705484 0.15357140
[7] -0.16667617 0.07244208 1.34557979 0.04062895 -0.64630183 1.27655576
[13] -0.21650807 -0.38734423 1.69006151 -1.48207001 0.79535392 -0.26373352
[19] -1.29135600 0.91355821 -0.65552499 0.07182836 -0.87529597 1.73588984
[25] -0.71899309 -1.57852559 0.89129367 -0.73922932 -1.43325141 0.10900816
[31] 0.07909953 -1.84283346 -1.00332816 -0.08545431 -0.11801302 0.53622414
[37] 0.91847521 -0.36783705 1.30510570 0.21774839 0.65087389 1.20212092
[43] 0.83891892 0.60250859 0.35428336 -0.58800354 -1.19033068 1.11706653
[49] -0.91929807 1.48259879 0.36454634 1.17825626 1.22151531 -0.74332351
[55] 1.17287356 2.13819881 -0.29780718 -0.23270365 0.35592916 -0.84578915
[61] -0.03538621 -0.41803400 0.59727680 -0.54738087 -0.54733668 -1.28096085
[67] -0.17212148 0.46017763 -1.41068403 2.62003605 -1.00114217 -1.06154245
[73] 0.50358783 0.43360352 1.03624825 2.53530866 -0.20585366 -0.53900360
[79] 0.78928305 0.25169558 -0.58558172 0.45235018 0.41948823 -0.44874770
[85] 2.76169630 -0.24935004 -1.01557758 -0.05474929 1.96215879 0.87070931
[91] 0.71579194 -0.09794411 1.49982538 0.34667396 1.28721787 -0.27315328
[97] 0.31800545 -0.65024856 -0.36434129 -0.85638512
> rowSums(tmp2)
[1] -0.54110957 -0.30100102 0.74403409 0.35014434 0.43705484 0.15357140
[7] -0.16667617 0.07244208 1.34557979 0.04062895 -0.64630183 1.27655576
[13] -0.21650807 -0.38734423 1.69006151 -1.48207001 0.79535392 -0.26373352
[19] -1.29135600 0.91355821 -0.65552499 0.07182836 -0.87529597 1.73588984
[25] -0.71899309 -1.57852559 0.89129367 -0.73922932 -1.43325141 0.10900816
[31] 0.07909953 -1.84283346 -1.00332816 -0.08545431 -0.11801302 0.53622414
[37] 0.91847521 -0.36783705 1.30510570 0.21774839 0.65087389 1.20212092
[43] 0.83891892 0.60250859 0.35428336 -0.58800354 -1.19033068 1.11706653
[49] -0.91929807 1.48259879 0.36454634 1.17825626 1.22151531 -0.74332351
[55] 1.17287356 2.13819881 -0.29780718 -0.23270365 0.35592916 -0.84578915
[61] -0.03538621 -0.41803400 0.59727680 -0.54738087 -0.54733668 -1.28096085
[67] -0.17212148 0.46017763 -1.41068403 2.62003605 -1.00114217 -1.06154245
[73] 0.50358783 0.43360352 1.03624825 2.53530866 -0.20585366 -0.53900360
[79] 0.78928305 0.25169558 -0.58558172 0.45235018 0.41948823 -0.44874770
[85] 2.76169630 -0.24935004 -1.01557758 -0.05474929 1.96215879 0.87070931
[91] 0.71579194 -0.09794411 1.49982538 0.34667396 1.28721787 -0.27315328
[97] 0.31800545 -0.65024856 -0.36434129 -0.85638512
> rowVars(tmp2)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> rowSd(tmp2)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> rowMax(tmp2)
[1] -0.54110957 -0.30100102 0.74403409 0.35014434 0.43705484 0.15357140
[7] -0.16667617 0.07244208 1.34557979 0.04062895 -0.64630183 1.27655576
[13] -0.21650807 -0.38734423 1.69006151 -1.48207001 0.79535392 -0.26373352
[19] -1.29135600 0.91355821 -0.65552499 0.07182836 -0.87529597 1.73588984
[25] -0.71899309 -1.57852559 0.89129367 -0.73922932 -1.43325141 0.10900816
[31] 0.07909953 -1.84283346 -1.00332816 -0.08545431 -0.11801302 0.53622414
[37] 0.91847521 -0.36783705 1.30510570 0.21774839 0.65087389 1.20212092
[43] 0.83891892 0.60250859 0.35428336 -0.58800354 -1.19033068 1.11706653
[49] -0.91929807 1.48259879 0.36454634 1.17825626 1.22151531 -0.74332351
[55] 1.17287356 2.13819881 -0.29780718 -0.23270365 0.35592916 -0.84578915
[61] -0.03538621 -0.41803400 0.59727680 -0.54738087 -0.54733668 -1.28096085
[67] -0.17212148 0.46017763 -1.41068403 2.62003605 -1.00114217 -1.06154245
[73] 0.50358783 0.43360352 1.03624825 2.53530866 -0.20585366 -0.53900360
[79] 0.78928305 0.25169558 -0.58558172 0.45235018 0.41948823 -0.44874770
[85] 2.76169630 -0.24935004 -1.01557758 -0.05474929 1.96215879 0.87070931
[91] 0.71579194 -0.09794411 1.49982538 0.34667396 1.28721787 -0.27315328
[97] 0.31800545 -0.65024856 -0.36434129 -0.85638512
> rowMin(tmp2)
[1] -0.54110957 -0.30100102 0.74403409 0.35014434 0.43705484 0.15357140
[7] -0.16667617 0.07244208 1.34557979 0.04062895 -0.64630183 1.27655576
[13] -0.21650807 -0.38734423 1.69006151 -1.48207001 0.79535392 -0.26373352
[19] -1.29135600 0.91355821 -0.65552499 0.07182836 -0.87529597 1.73588984
[25] -0.71899309 -1.57852559 0.89129367 -0.73922932 -1.43325141 0.10900816
[31] 0.07909953 -1.84283346 -1.00332816 -0.08545431 -0.11801302 0.53622414
[37] 0.91847521 -0.36783705 1.30510570 0.21774839 0.65087389 1.20212092
[43] 0.83891892 0.60250859 0.35428336 -0.58800354 -1.19033068 1.11706653
[49] -0.91929807 1.48259879 0.36454634 1.17825626 1.22151531 -0.74332351
[55] 1.17287356 2.13819881 -0.29780718 -0.23270365 0.35592916 -0.84578915
[61] -0.03538621 -0.41803400 0.59727680 -0.54738087 -0.54733668 -1.28096085
[67] -0.17212148 0.46017763 -1.41068403 2.62003605 -1.00114217 -1.06154245
[73] 0.50358783 0.43360352 1.03624825 2.53530866 -0.20585366 -0.53900360
[79] 0.78928305 0.25169558 -0.58558172 0.45235018 0.41948823 -0.44874770
[85] 2.76169630 -0.24935004 -1.01557758 -0.05474929 1.96215879 0.87070931
[91] 0.71579194 -0.09794411 1.49982538 0.34667396 1.28721787 -0.27315328
[97] 0.31800545 -0.65024856 -0.36434129 -0.85638512
>
> colMeans(tmp2)
[1] 0.1487732
> colSums(tmp2)
[1] 14.87732
> colVars(tmp2)
[1] 0.9326063
> colSd(tmp2)
[1] 0.9657155
> colMax(tmp2)
[1] 2.761696
> colMin(tmp2)
[1] -1.842833
> colMedians(tmp2)
[1] 0.07213522
> colRanges(tmp2)
[,1]
[1,] -1.842833
[2,] 2.761696
>
> dataset1 <- matrix(dataset1,1,100)
>
> agree.checks(tmp,dataset1)
>
> dataset2 <- matrix(dataset2,100,1)
> agree.checks(tmp2,dataset2)
>
>
> tmp <- createBufferedMatrix(10,10)
>
> tmp[1:10,1:10] <- rnorm(100)
> colApply(tmp,sum)
[1] 1.71333098 3.63714795 0.04660685 -0.12954366 -3.92497569 -2.05584503
[7] 2.23952296 -2.74234278 0.30381757 2.83513707
> colApply(tmp,quantile)[,1]
[,1]
[1,] -1.0562353
[2,] -0.3394786
[3,] 0.2324410
[4,] 0.4658813
[5,] 1.2251002
>
> rowApply(tmp,sum)
[1] 1.92629881 -2.53140845 0.74858321 -1.95580127 1.61633013 -0.07224374
[7] 2.16058588 -2.47242804 5.92495286 -3.42201317
> rowApply(tmp,rank)[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 9 8 9 3 6 2 5 5 3 8
[2,] 4 6 5 10 8 1 9 7 8 10
[3,] 6 9 6 8 2 8 3 8 4 3
[4,] 3 7 10 7 4 4 4 2 2 5
[5,] 2 5 3 4 3 6 1 3 7 6
[6,] 5 1 4 6 5 9 2 10 5 7
[7,] 1 10 7 2 9 10 10 6 6 2
[8,] 10 2 2 5 1 7 7 9 1 1
[9,] 8 3 1 1 10 3 8 4 10 4
[10,] 7 4 8 9 7 5 6 1 9 9
>
> tmp <- createBufferedMatrix(5,20)
>
> tmp[1:5,1:20] <- rnorm(100)
> colApply(tmp,sum)
[1] 3.87850530 -1.75623344 1.44816327 -2.50411341 0.38484359 0.17017328
[7] 1.59089305 0.69335397 1.73397020 -0.48395716 -0.42173497 -0.56596651
[13] -0.91761059 -1.27634493 -0.63246089 -0.32607183 0.63048751 0.20254426
[19] 1.96911269 -0.02193924
> colApply(tmp,quantile)[,1]
[,1]
[1,] -1.16339019
[2,] 0.03307809
[3,] 1.00310541
[4,] 1.89181442
[5,] 2.11389757
>
> rowApply(tmp,sum)
[1] 0.5529831 4.2754243 5.8359453 -3.7770780 -3.0916606
> rowApply(tmp,rank)[1:5,]
[,1] [,2] [,3] [,4] [,5]
[1,] 20 20 3 11 20
[2,] 13 3 5 15 3
[3,] 17 2 7 16 19
[4,] 2 13 11 2 4
[5,] 9 10 8 12 14
>
>
> as.matrix(tmp)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 2.11389757 0.1451653 1.20135356 -1.1568493 -0.42976126 -1.5801987
[2,] 1.89181442 -0.7558521 -0.83432870 0.4169247 0.21953615 -1.1346532
[3,] -1.16339019 -0.6708519 -0.07969253 0.5462287 0.25407131 1.1763919
[4,] 0.03307809 0.2831149 0.35429149 -1.5712747 0.04902839 1.1329054
[5,] 1.00310541 -0.7578097 0.80653944 -0.7391428 0.29196900 0.5757279
[,7] [,8] [,9] [,10] [,11] [,12]
[1,] 0.7848600 -0.5394934 -0.5453129 -0.33361955 -0.8781657 0.1419374
[2,] 0.5080695 0.2664277 0.9485732 0.06731545 0.5838453 0.1736228
[3,] 0.3372767 0.4587429 0.9732150 1.05399810 0.5572982 1.4395589
[4,] 0.9596280 0.1399877 -0.1784176 -0.89892494 -1.0600417 -1.6541318
[5,] -0.9989412 0.3676891 0.5359125 -0.37272622 0.3753289 -0.6669539
[,13] [,14] [,15] [,16] [,17] [,18]
[1,] 0.2362236 0.1225208 -0.8847881 -0.43592714 1.3902548 0.5586087
[2,] 0.6013456 -0.1491908 -0.4102883 -0.03517311 -0.2882337 0.9083746
[3,] -2.3431941 -1.2940521 1.7347951 1.07182120 1.0539331 -0.5070704
[4,] 0.8979051 0.2045195 -0.8744791 -0.86074579 0.5530728 -0.1668387
[5,] -0.3098909 -0.1601424 -0.1977005 -0.06604699 -2.0785395 -0.5905300
[,19] [,20]
[1,] -0.6278066 1.2700841
[2,] 0.9738401 0.3234546
[3,] 2.2338349 -0.9969696
[4,] -0.7773737 -0.3423816
[5,] 0.1666180 -0.2761268
>
>
> is.BufferedMatrix(tmp)
[1] TRUE
>
> as.BufferedMatrix(as.matrix(tmp))
BufferedMatrix object
Matrix size: 5 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 800 bytes.
>
>
>
> subBufferedMatrix(tmp,1:5,1:5)
BufferedMatrix object
Matrix size: 5 5
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 674 bytes.
Disk usage : 200 bytes.
> subBufferedMatrix(tmp,,5:8)
BufferedMatrix object
Matrix size: 5 4
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 582 bytes.
Disk usage : 160 bytes.
> subBufferedMatrix(tmp,1:3,)
BufferedMatrix object
Matrix size: 3 20
Buffer size: 1 1
Directory: C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64
Prefix: BM
Mode: Col mode
Read Only: FALSE
Memory usage : 2 Kilobytes.
Disk usage : 480 bytes.
>
>
> rm(tmp)
>
>
> ###
> ### Testing colnames and rownames
> ###
>
> tmp <- createBufferedMatrix(5,20)
> tmp[1:5,1:20] <- rnorm(100)
>
>
> colnames(tmp)
NULL
> rownames(tmp)
NULL
>
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
> colnames(tmp)
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
> rownames(tmp)
[1] "row1" "row2" "row3" "row4" "row5"
>
>
> tmp["row1",]
col1 col2 col3 col4 col5 col6 col7
row1 -0.3182312 1.551165 -1.761286 -0.9777532 -0.4132679 -0.1959884 0.7349727
col8 col9 col10 col11 col12 col13 col14
row1 0.9662979 0.02316222 0.07376797 -0.5287092 -0.2029006 -0.5059467 -1.206568
col15 col16 col17 col18 col19 col20
row1 -0.1398702 -1.124775 -1.32055 -1.241582 0.7514015 0.439114
> tmp[,"col10"]
col10
row1 0.07376797
row2 -0.25867555
row3 0.53762952
row4 0.56723102
row5 1.88909670
> tmp[c("row1","row5"),]
col1 col2 col3 col4 col5 col6 col7
row1 -0.3182312 1.551165 -1.761286 -0.9777532 -0.4132679 -0.1959884 0.7349727
row5 -1.8025018 -2.052312 -1.378753 0.1168533 1.3935672 -0.2032664 1.2647023
col8 col9 col10 col11 col12 col13
row1 0.9662979 0.02316222 0.07376797 -0.5287092 -0.2029006 -0.5059467
row5 -0.4615213 0.91250157 1.88909670 0.1959844 -0.1250386 1.2779135
col14 col15 col16 col17 col18 col19
row1 -1.206568 -0.1398702 -1.1247750 -1.3205503 -1.24158198 0.7514015
row5 0.461297 0.4900971 0.4869809 0.7099458 -0.09761395 -0.3231884
col20
row1 0.439114
row5 -1.659393
> tmp[,c("col6","col20")]
col6 col20
row1 -0.1959884 0.4391140
row2 -0.6238749 2.5539791
row3 0.8824383 -1.3446810
row4 0.9176877 -0.7121411
row5 -0.2032664 -1.6593928
> tmp[c("row1","row5"),c("col6","col20")]
col6 col20
row1 -0.1959884 0.439114
row5 -0.2032664 -1.659393
>
>
>
>
> tmp["row1",] <- rnorm(20,mean=10)
> tmp[,"col10"] <- rnorm(5,mean=30)
> tmp[c("row1","row5"),] <- rnorm(40,mean=50)
> tmp[,c("col6","col20")] <- rnorm(10,mean=75)
> tmp[c("row1","row5"),c("col6","col20")] <- rnorm(4,mean=105)
>
> tmp["row1",]
col1 col2 col3 col4 col5 col6 col7 col8
row1 50.17727 49.00115 49.32544 49.48022 50.08279 104.9172 49.84462 49.99938
col9 col10 col11 col12 col13 col14 col15 col16
row1 48.61625 51.32741 50.20619 48.81613 51.45216 50.32322 48.87047 52.11355
col17 col18 col19 col20
row1 49.3125 49.06843 48.74378 103.9354
> tmp[,"col10"]
col10
row1 51.32741
row2 28.83171
row3 31.80423
row4 29.91776
row5 48.07290
> tmp[c("row1","row5"),]
col1 col2 col3 col4 col5 col6 col7 col8
row1 50.17727 49.00115 49.32544 49.48022 50.08279 104.9172 49.84462 49.99938
row5 50.08419 50.80524 50.58879 49.14559 50.35588 105.2533 49.72862 50.90850
col9 col10 col11 col12 col13 col14 col15 col16
row1 48.61625 51.32741 50.20619 48.81613 51.45216 50.32322 48.87047 52.11355
row5 52.02641 48.07290 47.30855 49.91084 52.17563 50.90287 49.07355 51.14483
col17 col18 col19 col20
row1 49.31250 49.06843 48.74378 103.9354
row5 48.55242 50.84362 50.00208 103.4171
> tmp[,c("col6","col20")]
col6 col20
row1 104.91725 103.93540
row2 74.16633 75.12045
row3 76.17169 75.25293
row4 75.51701 73.92334
row5 105.25332 103.41711
> tmp[c("row1","row5"),c("col6","col20")]
col6 col20
row1 104.9172 103.9354
row5 105.2533 103.4171
>
>
> subBufferedMatrix(tmp,c("row1","row5"),c("col6","col20"))[1:2,1:2]
col6 col20
row1 104.9172 103.9354
row5 105.2533 103.4171
>
>
>
>
>
> tmp <- createBufferedMatrix(5,20)
> tmp[1:5,1:20] <- rnorm(100)
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
>
> tmp[,"col13"]
col13
[1,] -0.2910202
[2,] -0.6234108
[3,] -0.4899663
[4,] 0.5852812
[5,] 2.4798128
> tmp[,c("col17","col7")]
col17 col7
[1,] 0.4460464 -0.24506779
[2,] -0.8656314 0.20056765
[3,] -0.9446119 -0.88360054
[4,] 0.2060806 -0.09149548
[5,] -0.2339242 -0.09780914
>
> subBufferedMatrix(tmp,,c("col6","col20"))[,1:2]
col6 col20
[1,] 1.2400361 -0.1467855
[2,] 2.6615756 -0.1702201
[3,] -0.6887872 1.7771379
[4,] 0.3362451 0.8642820
[5,] -0.3650973 0.3036465
> subBufferedMatrix(tmp,1,c("col6"))[,1]
col1
[1,] 1.240036
> subBufferedMatrix(tmp,1:2,c("col6"))[,1]
col6
[1,] 1.240036
[2,] 2.661576
>
>
>
> tmp <- createBufferedMatrix(5,20)
> tmp[1:5,1:20] <- rnorm(100)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
>
>
>
> subBufferedMatrix(tmp,c("row3","row1"),)[,1:20]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
row3 -1.102090 -1.279875 0.7452431 0.7090622 -0.5066933 0.709247 -0.4625628
row1 -1.791081 1.339801 -1.1620896 0.5841173 0.8897847 -1.098219 1.0316304
[,8] [,9] [,10] [,11] [,12] [,13] [,14]
row3 -1.4674241 0.8779504 1.222754 -0.2595237 0.6626935 0.7084339 -0.3415451
row1 0.6886862 -3.0543348 -1.348795 1.9897896 -0.8116146 0.3491919 2.6428995
[,15] [,16] [,17] [,18] [,19] [,20]
row3 -1.697411 -0.3151385 1.7990457 0.6999546 0.5388073 -0.03731641
row1 -1.985572 1.4847324 -0.1497834 -0.3283036 0.7886673 -1.71853926
> subBufferedMatrix(tmp,c("row2"),1:10)[,1:10]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
row2 -0.8722265 0.5541618 -0.2200709 0.867629 0.6295186 1.115174 -0.4750283
[,8] [,9] [,10]
row2 -0.007176191 -1.006968 1.805172
> subBufferedMatrix(tmp,c("row5"),1:20)[,1:20]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
row5 0.5213529 0.9749165 -0.04528449 -0.8415824 1.104936 -0.5464643 -1.038093
[,8] [,9] [,10] [,11] [,12] [,13] [,14]
row5 -0.686505 0.5984718 -0.3082669 -0.3018327 0.8464151 0.199319 -0.8442525
[,15] [,16] [,17] [,18] [,19] [,20]
row5 0.8079401 -0.5319679 1.319605 -0.4961944 0.4522856 -0.3419244
>
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
> colnames(tmp)
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
> rownames(tmp)
[1] "row1" "row2" "row3" "row4" "row5"
>
>
> colnames(tmp) <- NULL
> rownames(tmp) <- NULL
>
> colnames(tmp)
NULL
> rownames(tmp)
NULL
>
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
>
> dimnames(tmp)
[[1]]
[1] "row1" "row2" "row3" "row4" "row5"
[[2]]
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
>
> dimnames(tmp) <- NULL
>
> colnames(tmp) <- colnames(tmp,do.NULL=FALSE)
> dimnames(tmp)
[[1]]
NULL
[[2]]
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
>
>
> dimnames(tmp) <- NULL
> rownames(tmp) <- rownames(tmp,do.NULL=FALSE)
> dimnames(tmp)
[[1]]
[1] "row1" "row2" "row3" "row4" "row5"
[[2]]
NULL
>
> dimnames(tmp) <- list(NULL,c(colnames(tmp,do.NULL=FALSE)))
> dimnames(tmp)
[[1]]
NULL
[[2]]
[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
[10] "col10" "col11" "col12" "col13" "col14" "col15" "col16" "col17" "col18"
[19] "col19" "col20"
>
>
>
> ###
> ### Testing logical indexing
> ###
> ###
>
> tmp <- createBufferedMatrix(230,15)
> tmp[1:230,1:15] <- rnorm(230*15)
> x <-tmp[1:230,1:15]
>
> for (rep in 1:10){
+ which.cols <- sample(c(TRUE,FALSE),15,replace=T)
+ which.rows <- sample(c(TRUE,FALSE),230,replace=T)
+
+ if (!all(tmp[which.rows,which.cols] == x[which.rows,which.cols])){
+ stop("No agreement when logical indexing\n")
+ }
+
+ if (!all(subBufferedMatrix(tmp,,which.cols)[,1:sum(which.cols)] == x[,which.cols])){
+ stop("No agreement when logical indexing in subBufferedMatrix cols\n")
+ }
+ if (!all(subBufferedMatrix(tmp,which.rows,)[1:sum(which.rows),] == x[which.rows,])){
+ stop("No agreement when logical indexing in subBufferedMatrix rows\n")
+ }
+
+
+ if (!all(subBufferedMatrix(tmp,which.rows,which.cols)[1:sum(which.rows),1:sum(which.cols)]== x[which.rows,which.cols])){
+ stop("No agreement when logical indexing in subBufferedMatrix rows and columns\n")
+ }
+ }
>
>
> ##
> ## Test the ReadOnlyMode
> ##
>
> ReadOnlyMode(tmp)
> is.ReadOnlyMode(tmp)
[1] TRUE
>
> filenames(tmp)
[1] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c39491de2"
[2] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c648b1cc"
[3] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c27ac2229"
[4] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c2ec34c39"
[5] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c6355845"
[6] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c5e001a92"
[7] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c165750f2"
[8] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c4a9429ac"
[9] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c261f6d3"
[10] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c24f07951"
[11] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c63574920"
[12] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c44af4c92"
[13] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c710a6e99"
[14] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c68d745e"
[15] "C:/Users/biocbuild/bbs-3.9-bioc/meat/BufferedMatrix.Rcheck/tests_x64\\BMc0c270954be"
>
>
> ### testing coercion functions
> ###
>
> tmp <- as(tmp,"matrix")
> tmp <- as(tmp,"BufferedMatrix")
>
>
>
> ### testing whether can move storage from one location to another
>
> MoveStorageDirectory(tmp,"NewDirectory",full.path=FALSE)
> MoveStorageDirectory(tmp,getwd(),full.path=TRUE)
Warning message:
In dir.create(new.directory) :
'C:\Users\biocbuild\bbs-3.9-bioc\meat\BufferedMatrix.Rcheck\tests_x64' already exists
>
>
> RowMode(tmp)
> rowMedians(tmp)
[1] -0.1355695387 -0.2515188598 0.5319167953 0.3314810851 -0.4792474078
[6] -0.2846786773 -0.1307735889 -0.0705983584 -0.1003683505 -0.3455640950
[11] -0.0456238334 0.1546870150 -0.5906800595 -0.0255438921 0.4781102422
[16] -0.0119345622 0.3194480580 -0.1346761351 -0.1787860189 -0.1678892422
[21] 0.2445294554 -0.3624165811 -0.1573709115 0.4970755820 -0.2785429757
[26] 0.4863833522 0.2406029714 -0.2573104344 -0.1537001999 -0.5130728626
[31] -0.2529777493 0.0400472276 -0.1518358691 -0.1510897634 -0.0444977577
[36] -0.3646863052 0.3544164543 0.7468432206 -0.0888295538 -0.1063687880
[41] 0.1007268083 0.1001994422 0.0156518842 -0.0570417306 0.5608891281
[46] -0.3265942094 -0.1341651777 0.2558573412 -0.0660521518 -0.0896312878
[51] -0.2982371176 -0.0034584146 -0.3715734970 0.0931818380 -0.1462625740
[56] 0.7493269503 -0.2566749343 0.2178412581 0.0734478096 0.1214737501
[61] -0.2136176291 -0.5333808215 -0.1936018707 -0.4417821793 0.0277822707
[66] -0.1904140785 -0.1660781033 0.2612398496 -0.3447992251 -0.0023609158
[71] -0.6086350900 -0.6881587632 -0.4929542481 -0.1055263999 -0.2894615897
[76] -0.0941466205 0.1020201046 0.4136212967 -0.0306827237 -0.1366840400
[81] 0.1252021059 -0.0042322053 0.1902510257 -0.2282777812 -0.2403516272
[86] -0.1811706192 -0.2874024291 -0.6375921079 -0.2072020431 0.3264911204
[91] 0.2715155087 0.0829870576 -0.4877538825 0.1445492485 0.0337212083
[96] 0.0485696623 -0.0476306550 -0.0870138501 -0.0823306158 -0.1918788705
[101] 0.3969628211 0.3608820264 0.5093275217 0.1217179796 0.0132535506
[106] 0.0147108373 0.2026681625 0.0478752032 -0.3030417463 0.0884831680
[111] -0.2605425792 -0.3460105614 0.0987434245 -0.0119421263 -0.3506215873
[116] 0.1641830136 -0.2019873941 -0.3076420859 -0.1040112938 -0.0053296278
[121] -0.3426826094 0.0165140423 0.3003496904 0.0008154089 -0.4412530380
[126] -0.6305316077 -0.3797552429 -0.0398418831 -0.2276904712 0.0354649765
[131] 0.2548112040 -0.1798621149 -0.0395202357 -0.6231455011 -0.3076746805
[136] 0.0880706333 0.3945521766 -0.1571576662 0.2548061476 0.0337654099
[141] 0.4511344876 0.1591338147 0.1805507892 -0.3922704955 -0.2752951537
[146] 0.0089680470 0.3928421670 0.0037276088 -0.3567672236 -0.4797217211
[151] -0.6521975338 0.3629430663 -0.3637012307 -0.5026111162 0.2788580472
[156] 0.0240550592 -0.1364253300 -0.2448789284 -0.2513330729 0.0318456555
[161] -0.2906880648 0.2212166582 0.0115920710 -0.3401504909 -0.1466516150
[166] -0.1715000152 0.5656846670 -0.2049311858 0.0044941433 -0.1130012409
[171] 0.4206828565 -0.1826850427 0.4846733886 0.3795588788 0.0146732767
[176] 0.2894721431 -0.6967385245 -0.3773017950 -0.4401088706 0.0178568361
[181] -0.8583406081 0.0186956037 0.0056740712 0.6645578916 -0.4734433516
[186] -0.0789015164 -0.1808876131 -0.5713952833 0.2588460299 -0.1363102955
[191] 0.0977366827 0.3851158029 0.3890276610 -0.1056545842 0.3791519436
[196] -0.2581837212 0.3934584868 0.0888069254 0.0542552225 0.1064730074
[201] 0.0045263936 0.3055817143 -0.2005964953 1.1668732256 0.0079146207
[206] -0.2124072975 0.3487224053 0.2722292148 -0.2302963479 -0.0727042029
[211] 0.0608696673 -0.0686049100 0.7670759660 -0.0031805051 -0.1775202919
[216] 0.0640513255 -0.0047908434 0.1359899500 0.2705057171 -0.1119204135
[221] 0.0469690156 0.4169497908 -0.3672806926 0.2980080757 0.3530831358
[226] 0.1149294024 0.1670436678 0.3523119282 0.1261748469 0.2145594102
>
> proc.time()
user system elapsed
3.03 8.15 11.67
|