# partialCorrelation: Calculate the partial correlation and p-values In tnaake/MetNet: Inferring metabolic networks from untargeted high-resolution mass spectrometry data

 partialCorrelation R Documentation

## Calculate the partial correlation and p-values

### Description

'partialCorrelation' infers an adjacency matrix of partial correlation values and associated p-values using using the 'cor2pcor' function (from the 'corpcor' package). 'partialCorrelation' calculates the p-values from the number of samples ('n') and the number of controlling variables ('g'). The function will return a list containing the weighted adjacency matrix of the correlation values, together with the associated p-values.

### Usage

partialCorrelation(x, method = "pearson", ...)


### Arguments

 x 'matrix', where columns are the features (metabolites) and the rows are samples, cell entries are intensity values method 'character', either "pearson", "spearman" ... further arguments passed to 'cor' from 'base' or 'cor2pcor' from 'corpcor'

### Details

The correlation coefficients $r_ij|S$ are obtained from 'cor2pcor' ('corpcor' package).

The t-values are calculated via

t_{ij|S} = r_{ij|S} \cdot √{\frac{n-2-g}{1-r_{ij|S}^2}}, where $n$ are the number of samples and $g$ the number of controlling variables (number of features - 2).

The p-values are calculated as follows p_{ij|S} = 2 \cdot pt(-abs(t_{ij|S}), df = n - 2 - g)

### Value

'list' containing two matrices, the first matrix contains correlation coefficients and the second matrix contains the corresponding p-values

### Examples

data("x_test", package = "MetNet")
x <- x_test[, 3:ncol(x_test)]
x <- as.matrix(x)
x <- t(x)
partialCorrelation(x, use = "pairwise", method = "pearson")



tnaake/MetNet documentation built on June 30, 2022, 10:50 a.m.