Skip to contents

Estimate the log fold changes based on a contrast matrix, requires the LFC package.

Usage

LFC(
  data,
  name.prefix = mode,
  contrasts,
  slot = "count",
  LFC.fun = lfc::PsiLFC,
  mode = "total",
  normalization = NULL,
  compute.M = TRUE,
  genes = NULL,
  verbose = FALSE,
  ...
)

Arguments

data

the grandR object

name.prefix

the prefix for the new analysis name; a dot and the column names of the contrast matrix are appended; can be NULL (then only the contrast matrix names are used)

contrasts

contrast matrix that defines all pairwise comparisons, generated using GetContrasts

slot

the slot of the grandR object to take the data from; for PsiLFC, this really should be "count"!

LFC.fun

function to compute log fold changes (default: PsiLFC, other viable option: NormLFC)

mode

compute LFCs for "total", "new", or "old" RNA

normalization

normalize on "total", "new", or "old" (see details)

compute.M

also compute the mean expression (in log10 space)

genes

restrict analysis to these genes; NULL means all genes

verbose

print status messages?

...

further arguments forwarded to LFC.fun

Value

a new grandR object including a new analysis table. The columns of the new analysis table are

"LFC"

the log2 fold change

Details

Both PsiLFC and NormLFC) by default perform normalization by subtracting the median log2 fold change from all log2 fold changes. When computing LFCs of new RNA, it might be sensible to normalize w.r.t. to total RNA, i.e. subtract the median log2 fold change of total RNA from all the log2 fold change of new RNA. This can be accomplished by setting mode to "new", and normalization to "total"!

Normalization can also be a mode.slot! Importantly, do not specify a slot containing normalized values, but specify a slot of unnormalized values (which are used to compute the size factors for normalization!) Can also be a numeric vector of size factors with the same length as the data as columns. Then each value is divided by the corresponding size factor entry.

Examples

sars <- ReadGRAND(system.file("extdata", "sars.tsv.gz", package = "grandR"),
                  design=c(Design$Condition,Design$dur.4sU,Design$Replicate))
#> Warning: Duplicate gene symbols (n=1, e.g. MATR3) present, making unique!
sars <- subset(sars,Coldata(sars,Design$dur.4sU)==2)
sars<-LFC(sars,mode="total",contrasts=GetContrasts(sars,contrast=c("Condition","Mock")))
sars<-LFC(sars,mode="new",normalization="total",
                            contrasts=GetContrasts(sars,contrast=c("Condition","Mock")))
head(GetAnalysisTable(sars))
#>                    Gene  Symbol Length     Type total.SARS vs Mock.LFC
#> UHMK1   ENSG00000152332   UHMK1   8478 Cellular             -0.4395433
#> ATF3    ENSG00000162772    ATF3   2103 Cellular              2.4486712
#> PABPC4  ENSG00000090621  PABPC4   3592 Cellular             -0.1344397
#> ROR1    ENSG00000185483    ROR1   5832 Cellular             -0.1936823
#> ZC3H11A ENSG00000058673 ZC3H11A  11825 Cellular              0.7000287
#> ZBED6   ENSG00000257315   ZBED6  12481 Cellular              0.6889175
#>         total.SARS vs Mock.M new.SARS vs Mock.LFC new.SARS vs Mock.M
#> UHMK1              4511.7770            1.1881622          1118.9972
#> ATF3                397.5641            2.8216633           341.9156
#> PABPC4             6301.4993            1.1819850          2062.9733
#> ROR1               2643.8914            0.6859184          1073.7033
#> ZC3H11A            3028.9232            1.1289929          1538.0788
#> ZBED6              2976.2018            1.1362473          1534.1663