Using R and biocondufor gene chip data analysis (3): computing Median

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.