Followed by: http://www.cnblogs.com/emanlee/archive/2012/12/05/2803144.html
We already know that the data to be analyzed has three repeated measurement values for each gene. After missing values are filled, each gene has three available values.
This step is very simple. It is to take the median of the three values, that is, median.
There are many methods. You can use the median function in Excel;
Below in RCodePerform the following operations:
Get_median <-function (I, j ){
Num_vec <-C (imputeddata [I * 3-2, J], imputeddata [I * 3-1, J], imputeddata [I * 3, J])
Median (num_vec)
}
# A simple function to calculate median value of three replicates
Dimrow <-(DIM (imputeddata) [1])/3
Mediandata <-matrix (Data = Na, nrow = dimrow, ncol = dim (imputeddata) [2], byrow = true, dimnames = NULL)
# Create a blank matrix to store median values
For (I in 1: dimrow ){
For (J in 1: dim (imputeddata) [2]) {
Mediandata [I, j] <-get_median (I, j)
}
}
# Assign median value using the function get_median ()
Now we get the median data, which is stored in the mediandata object. The number of rows is 1/3 of imputeddata filled with missing values. Double check:
> Dim (imputeddata)
[1] 11571 20
> Dim (mediandata)
[1] 3857 20
From: http://azaleasays.com/tag/r/