# proportionsInAdmixture: Estimate the proportion of pure populations in an admixed... In WGCNA: Weighted Correlation Network Analysis

## Description

Assume that `datE.Admixture` provides the expression values from a mixture of cell types (admixed population) and you want to estimate the proportion of each pure cell type in the mixed samples (rows of `datE.Admixture`). The function allows you to do this as long as you provide a data frame `MarkerMeansPure` that reports the mean expression values of markers in each of the pure cell types.

## Usage

 ```1 2 3 4 5``` ```proportionsInAdmixture( MarkerMeansPure, datE.Admixture, calculateConditionNumber = FALSE, coefToProportion = TRUE) ```

## Arguments

 `MarkerMeansPure` is a data frame whose first column reports the name of the marker and the remaining columns report the mean values of the markers in each of the pure populations. The function will estimate the proportion of pure cells which correspond to columns 2 through of `dim(MarkerMeansPure)[[2]]` of `MarkerMeansPure`. Rows that contain missing values (NA) will be removed. `datE.Admixture` is a data frame of expression data, e.g. the columns of `datE.Admixture` could correspond to thousands of genes. The rows of `datE.Admixture` correspond to the admixed samples for which the function estimates the proportions of pure populations. Some of the markers specified in the first column of `MarkerMeansPure` should correspond to column names of `datE.Admixture`. `calculateConditionNumber` logical. Default is FALSE. If set to TRUE then it uses the `kappa` function to calculates the condition number of the matrix `MarkerMeansPure[,-1]`. This allows one to determine whether the linear model for estimating the proportions is well specified. Type `help(kappa)` to learn more. `kappa()` computes by default (an estimate of) the 2-norm condition number of a matrix or of the R matrix of a QR decomposition, perhaps of a linear fit. `coefToProportion` logical. By default, it is set to TRUE. When estimating the proportions the function fits a multivariate linear model. Ideally, the coefficients of the linear model correspond to the proportions in the admixed samples. But sometimes the coefficients take on negative values or do not sum to 1. If `coefToProportion=TRUE` then negative coefficients will be set to 0 and the remaining coefficients will be scaled so that they sum to 1.

## Details

The methods implemented in this function were motivated by the gene expression deconvolution approach described by Abbas et al (2009), Lu et al (2003), Wang et al (2006). This approach can be used to predict the proportions of (pure) cells in a complex tissue, e.g. the proportion of blood cell types in whole blood. To define the markers, you may need to have expression data from pure populations. Then you can define markers based on a significant t-test or ANOVA across the pure populations. Next use the pure population data to estimate corresponding mean expression values. Hopefully, the array platforms and normalization methods for `datE.MarkersAdmixtureTranspose` and `MarkerMeansPure` are comparable. When dealing with Affymetrix data: we have successfully used it on untransformed MAS5 data. For statisticians: To estimate the proportions, we use the coefficients of a linear model. Specifically: `datCoef= t(lm(datE.MarkersAdmixtureTranspose ~MarkerMeansPure[,-1])\$coefficients[-1,])` where `datCoef` is a matrix whose rows correspond to the mixed samples (rows of `datE.Admixture`) and the columns correspond to pure populations (e.g. cell types), i.e. the columns of `MarkerMeansPure[,-1]`. More details can be found in Abbas et al (2009).

## Value

A list with the following components

 `PredictedProportions` data frame that contains the predicted proportions. The rows of `PredictedProportions` correspond to the admixed samples, i.e. the rows of `datE.Admixture`. The columns of `PredictedProportions` correspond to the pure populations, i.e. the columns of `MarkerMeansPure[,-1].` `datCoef=datCoef` data frame of numbers that is analogous to `PredictedProportions`. In general, `datCoef` will only be different from `PredictedProportions` if `coefToProportion=TRUE`. See the description of `coefToProportion` `conditionNumber` This is the condition number resulting from the `kappa` function. See the description of calculateConditionNumber. `markersUsed` vector of character strings that contains the subset of marker names (specified in the first column of `MarkerMeansPure`) that match column names of `datE.Admixture` and that contain non-missing pure mean values.

## Note

This function can be considered a wrapper of the `lm` function.

## Author(s)

Steve Horvath, Chaochao Cai

## References

Abbas AR, Wolslegel K, Seshasayee D, Modrusan Z, Clark HF (2009) Deconvolution of Blood Microarray Data Identifies Cellular Activation Patterns in Systemic Lupus Erythematosus. PLoS ONE 4(7): e6098. doi:10.1371/journal.pone.0006098

Lu P, Nakorchevskiy A, Marcotte EM (2003) Expression deconvolution: a reinterpretation of DNA microarray data reveals dynamic changes in cell populations. Proc Natl Acad Sci U S A 100: 10370-10375.

Wang M, Master SR, Chodosh LA (2006) Computational expression deconvolution in a complex mammalian organ. BMC Bioinformatics 7: 328.

`lm`, `kappa`