File: maximizeInterpolant.R

package info (click to toggle)
r-bioc-edger 3.40.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,484 kB
  • sloc: cpp: 1,425; ansic: 1,109; sh: 21; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 944 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
maximizeInterpolant <- function( x, y ) 
# maximizeInterpolant: written by Aaron Lun
#
# This function takes an ordered set of spline points and a likelihood matrix where each row 
# corresponds to a tag and each column corresponds to a spline point. It then calculates the 
# position at which the maximum interpolated likelihood occurs for each by solving the derivative
# of the spline function.
{
    if (is.vector(y)) {
        y<-rbind(y)
        warning("coverting vector of likelihoods to matrix format for interpolation")
    }
    if (length(x)!=ncol(y)) { 
        stop("number of columns must equal number of spline points")
    } else if (is.unsorted(x) || anyDuplicated(x)) {
        stop("spline points must be unique and sorted")
    }

#	Performing some type checking.
	if (!is.double(x)) storage.mode(x)<-"double"
	if (!is.double(y)) storage.mode(y)<-"double"
    out<-.Call(.cxx_maximize_interpolant, x, y)
    return(out)
}