get_logFC: Extract sample or reference log-fold changes from rcmp...

View source: R/ref_compare.R

get_logFCR Documentation

Extract sample or reference log-fold changes from rcmp object.

Description

Fetches the log2-fold change (logFC) values for a given group comparison in the samples or in the reference.

Usage

get_logFC(rc, l = levels(rc$group)[2], l0 = levels(rc$group)[1], verbose = T)

Arguments

rc

an rcmp object, as returned by ref_compare

l, l0

sample groups to compare. l0 and l defaults to the first and second levels of group respectively.

verbose

if TRUE (default), prints warnings and selected factor levels.

Value

a dataframe with sample and reference logFCs between groups.

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.