Major Study./Bioinformatics

Gene expression data Thresholding

sosal 2014. 7. 21. 15:00
반응형

/*

 * http://sosal.kr/

 * made by so_Sal

 */

 

 

Gene_expression.csv

http://genome-www.stanford.edu/cellcycle/

 

Spellman et al., (1998) 에서 raw data - tab / Tab delimited data에서 다운로드 받았습니다.

빈칸(blank or null )인 경우 8888로 미리 채워놓은 데이터이기 때문에,

아래 소스를 그대로 사용하실 경우에는 수정을 해주셔야 합니다.

 

#include<iostream>

#include<fstream>

#include<string>

#include<Windows.h>

#include<math.h>

using namespace std;

 

 

#define TIME_POINTS 81

#define MAX_VALUE 1

#define MIN_VALUE 0

double threshold(double digit);

 

int main(){

        ifstream micro_arr;

        ofstream micro_arr_save;

        char name[BUFSIZ];

        char trash[BUFSIZ];

        double digit;

 

 

        micro_arr.open("gene_expression.csv",ios::in);

        micro_arr_save.open("gene_expression_log2.csv", ios::out);

        //gene expression data input, output

        //8888 NA(NULL) 데이터를 대신함

       

        int count = 0;

        while (!micro_arr.eof()){

               micro_arr.getline(name, BUFSIZ, ','); //raw데이터 첫번째는 DNA 이름

              

               micro_arr_save << name << ",";

              

               for (int i = 0; i < TIME_POINTS; i++){//n-1 타임포인트 연산

                       micro_arr >> digit;

                       digit = threshold(digit);

                       if (digit == 8888){

                              micro_arr_save << ',';

                       }

                       else

                              micro_arr_save << digit << ',';

 

                       micro_arr.getline(trash, BUFSIZ, ',');

               }

               micro_arr >> digit;//마지막 타임포인트

               digit = threshold(digit);

               if (digit == 8888){

                       micro_arr_save << endl;

               }

               else{

                      

                       micro_arr_save << digit << endl;

               }

 

 

               micro_arr.getline(trash, BUFSIZ, '\n');             

              

        }

        micro_arr.close();

        micro_arr_save.close();

       

        return 0;

}

 

 

double threshold(double digit){

        if (digit == 8888)

               return 8888;

        else if (digit > MAX_VALUE)

               return 8888;

        else if (digit <= MIN_VALUE)

               return 8888;

        else

               return digit;

}