cofVar | R Documentation |
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).
cofVar(expData, complete = TRUE, treatment = NULL, type = NULL)
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. |
The expression matrix with two new columns, the first one with the averages and the other one with the coefficient of variation values.
Juan David Henao <judhenaosa@unal.edu.co>
## 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) head(complete) # For the case samples case <- cofVar(expData = norm,complete = FALSE,treatment = treat,type = "case") head(case)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.