# cofVar: Calculating the coefficient of variation for expression... In jdhenaos/coexnet: coexnet: An R package to build CO-EXpression NETworks from Microarray Data

 cofVar R Documentation

## Calculating the coefficient of variation for expression matrix.

### Description

This function calculates the mean and the coefficient of variation to each row (genes or probesets) in an expression matrix in two ways: i) in the whole matrix ii) for the specific phenotype (case or control).

### Usage

```cofVar(expData, complete = TRUE, treatment = NULL, type = NULL)
```

### Arguments

 `expData` The whole normalized expression matrix, rows: genes or probeset, columns: samples, it may be stored in a SummarizedExperiment object. `complete` Boolean to define if the function uses the whole expression matrix, by default TRUE. `treatment` A numeric vector with 0s and 1s for each sample in the expression matrix, the 0 expresses the control samples and 1 expresses the case samples, by default is NULL. `type` It can be "case" to calculate the mean and the coefficient of variation for the case samples or, otherwise, "control" to obtain these two values for the control samples.

### Value

The expression matrix with two new columns, the first one with the averages and the other one with the coefficient of variation values.

### Author(s)

Juan David Henao <judhenaosa@unal.edu.co>

### Examples

```
## Creating the expression matrix

# The matrix have 200 genes and 20 samples

n <- 200
m <- 20

# The vector with treatment and control samples

treat <- c(rep(0,10),rep(1,10))

# Calculating the expression values normalized

mat <- as.matrix(rexp(n, rate = 1))
norm <- t(apply(mat, 1, function(nm) rnorm(m, mean=nm, sd=1)))

## Calculating the mean and the coefficient of variation

# For the whole expression matrix

complete <- cofVar(norm)