corrSeq_summary: Function to summarize individual regression coefficients

View source: R/corrSeq_summary.R

corrSeq_summaryR Documentation

Function to summarize individual regression coefficients

Description

Conducts hypothesis testing on models fit using the corrSeq_fit function.

Usage

corrSeq_summary(
  corrSeq_results = NULL,
  corrSeq_results_reduced = NULL,
  coefficient = NULL,
  contrast = NULL,
  p_adj_method = "BH",
  df = "residual",
  sort_results = T
)

Arguments

corrSeq_results

Results object from corrSeq_fit.

corrSeq_results_reduced

Results object from corrSeq_fit containing reduced models for LRT tests. Only applicable for nbmm_agq models or when using multi-row contrasts (matrix) for nbmm_lp models.

coefficient

Character string or numeric indicator of which coefficient to summarize. Ignored if contrast is specified.

contrast

Numeric vector or matrix specifying a contrast of the linear model coefficients to be tested. Number of columns must equal the number of coefficients in the model. If specified, then takes precedence over coefficient.

p_adj_method

Method for adjusting for multiple comparisons (default is Benjamini-Hochberg). See p.adjust.methods.

df

Method for computing degrees of freedom for t- and F-tests. The options "Satterthwaite" and "Kenward-Roger" can only be used for models fit using nbmm_pl or lmm. Options "containment" and "residual" can be used for models fit using any method except nbmm_agq (which does not use degrees of freedom, so use df=NA). Alternatively, a single numeric value representing the df for all tests can also be given. If testing a multi-row contrast for nbmm_lp, nbmm_agq, or gee, use df=NA since these tests do not use degrees of freedom. If using a multi-row contrast for nbmm_pl or lmm, only df="Satterthwaite" and df="Kenward-Roger" are available.

sort_results

Should the results table be sorted by adjusted p-value?

Details

For single DF tests (single line contrasts or testing a single coefficient) all methods use a t-test except nbmm_agq. For multiple DF tests (multi-row contrasts), nbmm_pl and lmm use an F-test, nbmm_lp uses a likelihood ratio test, and gee uses a Wald test. For both single DF and multiple DF tests, nbmm_agq will perform a Wald test if no reduced model is provided. Otherwise a LRT is used.

No DF is required for Wald of LRT tests, so df=NA should be used. Satterthwaite and Kenward-Rogers are only available for lmm and nbmm_pl. For multi-row contrasts for nbmm_pl and lmm, only Satterthwaite and Kenward-Rogers can be used.

Value

This function returns a list object with the following components:

coefficient

Name of the coefficient being summarized (if given).

contrast_mat

Contrast matrix (if given)

summary_table

A summary table including the gene name, estimate, standard error, degrees of freedom, test statistic, and raw and adjusted p-value.

df

Method for computing the degrees of freedom.

p_adj_method

Method for adjusting the raw p-values.

singular_fits

Gene names for genes that resulted in singular model fits. The summary information for these genes will be NA. Not applicable for models fit using "gee".

method

Method used to fit the models.

Author(s)

Elizabeth Wynn

See Also

corrSeq_fit geeglm_small_samp, glmm_nb_lmer, lmer, glmmadmb, mixed_model

Examples

data("simdata")
sample_meta_data <- simdata$metadata

## Subset down to 10 observation (i.e. gene)
counts=simdata$counts[1:10,]

## Fit NBMM-PL models
## Use log(library size) as an offset
## Note, group and time are factors
nbmm_pl_fit <- corrSeq_fit(formula = ~ group * time+(1|ids)+offset(log_offset),
                           expr_mat = counts,
                           sample_data = sample_meta_data,
                           method="nbmm_pl")



## Test for differential expression between groups at any timepoints
contrast_mat<-rbind(c(0, 1, 0, 0, 0, 0, 0, 0), #Difference in groups at time1
                    c(0, 1, 0, 0, 0, 1, 0, 0), #Difference in groups at time2
                    c(0, 1, 0, 0, 0, 0, 1, 0), #Difference in groups at time3
                    c(0, 1, 0, 0, 0, 0, 0, 1)  #Difference in groups at time4
                    )


group_sum <-corrSeq_summary(corrSeq_results = nbmm_pl_fit,
                             contrast = contrast_mat,
                             p_adj_method = 'BH',
                             df = 'Satterthwaite',
                             sort_results = T)

## Test for differential expression between groups at time 1
group_diff_time1 <-corrSeq_summary(corrSeq_results = nbmm_pl_fit,
                             coefficient = "group1",
                             p_adj_method = 'BH',
                             df = 'Satterthwaite',
                             sort_results = T)



ewynn610/corrRNASeq documentation built on Sept. 29, 2023, 10:37 a.m.