Skip to contents

Returns the p-value from a t-test with useful default parameters and calculates the foldchange. Returns NA if the t-test is uncalculable (i.e. does try() handling).

Usage

get.ttest.p.and.foldchange(x, group1, group2, paired = FALSE, var.equal = FALSE,
    alternative = 'two.sided', logged = TRUE);

Arguments

x

Vector of numbers to analyze

group1

Vector of TRUE/FALSE indicating which are the x samples for the t-test

group2

Vector of TRUE/FALSE indicating which are the y samples for the t-test

paired

Do a paired t-test?

var.equal

Assume Welch's correction?

alternative

What's the null-hypothesis?

logged

Indicate whether data is log-transformed or not

Details

Calculates fold-changes as mean(group2)/mean(group1) in normal-space and mean(group2) - mean(group1) in log-space, with appropriate NA-handling.

Value

Returns a two-element vector containing the p-value and fold-change, or NAs if an error occurs.

Author

Paul C. Boutros

See also

Examples

get.ttest.p.and.foldchange(
  x = rnorm(100),
  group1 = c( rep(TRUE, 50), rep(FALSE, 50) ),
  group2 = c( rep(FALSE, 50), rep(TRUE, 50) ),
  logged = FALSE
  );
#> [1]  0.1798893 -0.5411238