File: quantile_extensions.R

package info (click to toggle)
r-bioc-preprocesscore 1.68.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 988 kB
  • sloc: ansic: 9,605; sh: 3; makefile: 2
file content (106 lines) | stat: -rw-r--r-- 2,294 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106


normalize.quantiles.determine.target <- function(x,target.length=NULL,subset=NULL){

  if (!is.matrix(x)){
    stop("This function expects supplied argument to be matrix")
  }
  if (!is.numeric(x)){
    stop("Supplied argument should be a numeric matrix")
  }
  rows <- dim(x)[1]
  cols <- dim(x)[2]

  if (is.integer(x)){
    x <- matrix(as.double(x), rows, cols)
  }
  
  if (is.null(target.length)){
    target.length <- rows
  }
  
  if (target.length <= 0){
    stop("Need positive length for target.length")
  }

  if (is.null(subset)){
    return(.Call("R_qnorm_determine_target",x,target.length,PACKAGE="preprocessCore"))
  } else {
    if (length(subset) != rows){
       stop("subset should have same length as nrows(x)")
    }
    subset <- as.integer(subset)
    return(.Call("R_qnorm_determine_target_via_subset",x, subset,target.length,PACKAGE="preprocessCore"))			
  }

}



normalize.quantiles.use.target <- function(x,target,copy=TRUE,subset=NULL){

  if (!is.matrix(x)){
    stop("This function expects supplied argument to be matrix")
  }
  if (!is.numeric(x)){
    stop("Supplied argument should be a numeric matrix")
  }
  rows <- dim(x)[1]
  cols <- dim(x)[2]

  if (is.integer(x)){
    x <- matrix(as.double(x), rows, cols)
  }
  
  if (!is.vector(target)){
     stop("This function expects target to be vector")
  }
  if (!is.numeric(target)){
    stop("Supplied target argument should be a numeric vector")
  }

  if (is.integer(target)){
     target <- as.double(target)
  }
  if (is.null(subset)){	
     return(.Call("R_qnorm_using_target",x,target,copy,PACKAGE="preprocessCore"))
  } else {
    if (length(subset) != rows){
       stop("subset should have same length as nrows(x)")
    }
    subset <- as.integer(subset)
    return(.Call("R_qnorm_using_target_via_subset",x, subset, target, copy, PACKAGE="preprocessCore"))			
  }


}



normalize.quantiles.in.blocks <- function(x,blocks,copy=TRUE){

  rows <- dim(x)[1]
  cols <- dim(x)[2]

  if (rows != length(blocks)){
    stop("blocks is not vector of correct length")
  }

  if (is.factor(blocks)){
    blocks <- as.integer(blocks)
  }

  if (!is.numeric(blocks)){
    stop("non-numeric vector used for blocks")
  }


  return(.Call("R_qnorm_within_blocks",x,blocks,copy,PACKAGE="preprocessCore"))



}