perform_correlation_tests | R Documentation |
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.
perform_correlation_tests(
object,
x,
y = x,
id = NULL,
object2 = NULL,
fdr = TRUE,
all_pairs = TRUE,
duplicates = FALSE,
...
)
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 |
id |
character, column name for subject IDs. If provided, the correlation will be computed using the rmcorr package |
object2 |
optional second MeatboSet object. If provided, x variables will be taken from object and y variables will be taken from object2. Both objects should have the same number of samples. |
fdr |
logical, whether p-values from the correlation test should be adjusted with FDR correction |
all_pairs |
logical, whether all pairs between x and y should be tested. If FALSE, x and y give the exact pairs of variables to test, and should have the same length. |
duplicates |
logical, whether correlations should be dublicated. If |
... |
other parameters passed to |
a data frame with the results of correlation tests: the pair of variables, correlation coefficient and p-value
cor.test
, rmcorr
# 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"
)
# Correlations between variables from two distinct MetaboSets
cross_object_cor <- perform_correlation_tests(hilic_neg_sample,
x = featureNames(hilic_neg_sample),
object2 = hilic_pos_sample,
y = featureNames(hilic_pos_sample),
all_pairs = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.