ref_compare: Compare expression changes between sample groups to a...

View source: R/ref_compare.R

ref_compareR Documentation

Compare expression changes between sample groups to a matching developmental reference.

Description

ref_compare computes log2-fold changes (logFCs) between given sample groups and logFCs between matching expression profiles of a developmental reference. By comparing the logFCs of the samples and those of the reference, we can quantify expression changes caused by developmental differences between sample groups rather than by the variable of interest.

Usage

ref_compare(X, ref, group, ae_obj = NULL, ae_values = NULL)

Arguments

X

sample gene expression matrix (should be comparable to reference, usually log(TPM+1)).

ref

a ref object (as returned by make_ref)

group

a factor defining sample groups to compare (e.g. wild-type & mutant), the first factor level is used as control.

ae_obj

an ae object (as returned by ae)

ae_values

age estimate values (used if ae_obj is NULL).

Details

We use TPM instead of raw counts to compute logFCs because TPM are more comparable across datasets, and because reference data is interpolated from and to log(TPM+1). Because of this, our logFCs may differ from those computed by differential expression (DE) analysis tools that use raw counts (e.g. DESeq2, edgeR)

Value

an rcmp object.

Examples


requireNamespace('wormRef', quietly = TRUE)

# get sample gene expression data
X <- wormRef::Cel_larval$g[,1:9]

# get reference
ref <- prepare_refdata(ref = 'Cel_larval', datapkg = 'wormRef' , n.inter = 200)

# define groups
fac <- factor(c('a', 'a', 'b', 
                'a', 'b', 'b',
                'c', 'c', 'c'))

# estimate sample age
ae_X <- ae(X, ref)

# compare group diff. expr. with matching reference
rc <- ref_compare(X, ref, fac, ae_X)
print(rc)

# get sample and reference (ie. development) logFCs between groups
lfc_a_vs_b <- get_logFC(rc)
lfc_a_vs_c <- get_logFC(rc, l = 'c')
lfc_b_vs_c <- get_logFC(rc, l0='b', l = 'c')

# plot sample vs. reference logFCs
par(mfrow = c(2,2))
plot(ae_X, groups = fac)
plot(lfc_a_vs_b, main = 'a vs. b logFC')
plot(lfc_a_vs_c, main = 'a vs. c logFC')
plot(lfc_b_vs_c, main = 'b vs. c logFC')



LBMC/wormAge documentation built on April 6, 2023, 3:52 a.m.