perform_correlation_tests: Perform correlation tests

Description Usage Arguments Value See Also Examples

View source: R/stats.R

Description

Performs a correlation test between two sets of variables. All the variables must be either feature names or column names of pheno data (sample information). There are two ways to use this function: either provide a set of variables as x, and all correlations between those variables are computed. Or provide two distinct sets of variables x, y and correlations between each x variable and each y variable are computed.

Usage

1
2
perform_correlation_tests(object, x, y = x, fdr = TRUE,
  duplicates = FALSE, ...)

Arguments

object

a MetaboSet object

x

character vector, names of variables to be correlated

y

character vector, either identical to x (the default) or a distinct set of variables to be correlated agains x

fdr

logical, whether p-values from the correlation test should be adjusted with FDR correction

...

other parameters passed to cor.test, such as method

duplicated

logical, whether correlations should be dublicated. If TRUE, each correlation will be included in the results twice, where the order of the variables (which is x and which is y) is changed. Can be useful for e.g. plotting a heatmap of the results, see examples of plot_effect_heatmap

Value

a data frame with the results of correlation tests: the pair of variables, correlation coefficient and p-value

See Also

cor.test

Examples

1
2
3
4
5
6
7
8
9
# Correlations between all features
correlations <- perform_correlation_tests(example_set, x = featureNames(example_set))

# Spearman Correlations between features and sample information variables
# Drop QCs and convert time to numeric
no_qc <- drop_qcs(example_set)
no_qc$Time <- as.numeric(no_qc$Time)
correlations <- perform_correlation_tests(no_qc, x = featureNames(example_set),
                                         y = c("Time", "Injection_order"), method = "spearman")

antonvsdata/amp documentation built on Jan. 8, 2020, 3:15 a.m.