Helper function to calculate the correlation matrix.
eset_cor(x, with.pvalues = TRUE, order.list = TRUE, verbose = FALSE)
(ExpressionSet
, data.frame
or numeric
). A numeric data frame, matrix or an ExpressionSet object.
(logical
). Should P-Values be calculated for the correlations? If TRUE
P-Values will be
depicted in the heatmap by significance asterisks. See 'Details'. Defaults to FALSE
.
(logical
). Is the input matrix column order reversed? Only applicable if input is correlation matrix.
Defaults to TRUE
.
(logical
). Should verbose output be written to the console? Defaults to FALSE
.
A correlation matrix
or a list
with three slots: the correlation matrix, the number of samples with no
missing value for each gene and the P-Values matrix.
P-Values are calculated from the t-test value of the correlation coefficient: \(t = r x sqrt(n-2) / sqrt(1-r^2)\),
where r is the correlation coefficient, n is the number of samples with no missing values for each gene (row-wise
ncol(eset)
minus the number of columns that have an NA). P-Values are then calculated using pt
and
corrected account for the two-tailed nature of the test, i.e., the possibility of positive as well as negative correlation.
The approach to calculate correlation significance was adopted from Miles, J., & Banyard, P. (2007) on
"Calculating the exact significance of a Pearson correlation in MS Excel".
Miles, J., & Banyard, P. (2007). Understanding and using statistics in psychology: A practical introduction. Sage Publications Ltd. https://psycnet.apa.org/record/2007-06525-000.