Normalizes data in a grandR object to a baseline and puts the normalized data into a new slot
Usage
NormalizeBaseline(
data,
baseline = FindReferences(data, reference = Condition == levels(Condition)[1]),
name = "baseline",
slot = DefaultSlot(data),
set.to.default = FALSE,
LFC.fun = lfc::PsiLFC,
...
)
Arguments
- data
the grandR object
- baseline
matrix defining the corresponding baseline (row) for each column (sample or cell; see details)
- name
the name of the new slot for the normalized data
- slot
the name of the slot for the data to normalize
- set.to.default
set the new slot as the default slot
- LFC.fun
- ...
forwarded to LFC.fun
Details
Baseline normalization computes the log2 fold change for a column (i.e. sample or cell) to a baseline columns (or several baseline columns). This is by default done using the
PsiLFC
function from the lfc package, which, by default, also normalizes log2 fold changes by adding a constant
such that the median is zero.
Baselines are defined by a square logical matrix, defining for each sample or cell of the grandR object, represented by the column of the matrix,
which samples or cells are indeed the baseline (represented by the rows). Such matrices can conveniently be obtained by FindReferences
.
Examples
sars <- ReadGRAND(system.file("extdata", "sars.tsv.gz", package = "grandR"),
design=c("Cell",Design$dur.4sU,Design$Replicate))
#> Warning: Duplicate gene symbols (n=1, e.g. MATR3) present, making unique!
blmat <- FindReferences(sars,reference = duration.4sU==0, group = "Cell")
# the Mock.no4sU or SARS.no4sU sample are the baselines for each sample
sars <- NormalizeBaseline(sars,baseline=blmat)
head(GetTable(sars,type="baseline"))
#> Mock.no4sU.A Mock.1h.A Mock.2h.A Mock.2h.B Mock.3h.A
#> UHMK1 0 -0.63954251 -0.96985472 -0.159542842 -0.31230382
#> ATF3 0 0.20852970 -0.01829995 0.068804744 -0.01551946
#> PABPC4 0 0.09179389 0.22724842 0.002427543 0.04994632
#> ROR1 0 -0.21890563 -0.43554363 -0.237116796 -0.44121439
#> ZC3H11A 0 -0.67926645 -0.71405596 -0.254790058 -0.43416145
#> ZBED6 0 -0.69496360 -0.72178654 -0.269412027 -0.44680260
#> Mock.4h.A SARS.no4sU.A SARS.1h.A SARS.2h.A SARS.2h.B SARS.3h.A
#> UHMK1 -0.587411928 0 0.04622295 -0.2659515 0.3417656 0.1377603
#> ATF3 -0.058649180 0 -2.60185174 -1.7310073 -1.8025667 -1.1630127
#> PABPC4 0.007155461 0 0.46350346 0.4482102 0.4359896 0.3513580
#> ROR1 -0.522545288 0 -0.36986948 -0.7010989 -0.5053961 -0.4878395
#> ZC3H11A -0.486612130 0 -1.01766277 -0.9280888 -0.4925569 -0.5787870
#> ZBED6 -0.499621887 0 -0.99775155 -0.9093923 -0.4615468 -0.5217733
#> SARS.4h.A
#> UHMK1 0.1574391
#> ATF3 -0.8664132
#> PABPC4 0.2019549
#> ROR1 -0.1147740
#> ZC3H11A -0.4970551
#> ZBED6 -0.4445425