File: getOffset.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 (19 lines) | stat: -rw-r--r-- 520 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
getOffset <- function(y)
#	Extract offset vector or matrix from data object and optional arguments.
#	By default, offset is constructed from the lib.size and norm.factors
#	but offset supplied explicitly takes precedence

#	Gordon Smyth
#	26 Jan 2011. Last modified 11 Jan 2012.
{
	offset <- y$offset
	lib.size <- y$samples$lib.size
	norm.factors <- y$samples$norm.factors
	
	if(!is.null(offset)) {
		return(offset)
	} else {		
		if(!is.null(norm.factors)) lib.size <- lib.size*norm.factors
		return(log(lib.size))
	}
}