File: effectiveLibSizes.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 (38 lines) | stat: -rw-r--r-- 904 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
effectiveLibSizes <- function(y, log=FALSE, ...)
UseMethod("effectiveLibSizes")

effectiveLibSizes.DGEList <- function(y, log=FALSE, ...)
#	Effective (normalized) library size
#	Gordon Smyth.
#	Created 19 Apr 2020. Last modified.
{
	if(is.null(y$offset)) {
		els <- y$samples$lib.size*y$samples$norm.factors
		if(log) els <- log(els)
	} else {
		els <- y$offset[1,]
		if(!log) els <- exp(els)
	}
	els
}

effectiveLibSizes.DGELRT <- effectiveLibSizes.DGEGLM <- function(y, log=FALSE, ...)
#	Effective (normalized) library size from DGEGLM fit.
#	Gordon Smyth.
#	Created 19 Apr 2020. Last modified.
{
	els <- y$offset[1,]
	if(!log) els <- exp(els)
	els
}

effectiveLibSizes.default <- function(y, log=FALSE, ...)
#	Effective library sizes for a matrix, i.e., just the column sums
#	Gordon Smyth.
#	Created 19 Apr 2020. Last modified.
{
	y <- as.matrix(y)
	els <- colSums(y)
	if(log) els <- log(els)
	els
}