Microarray Data Analysis

Spots are analyzed by the adaptive quantification method with local background subtractions

IdentificationNo. dataChannel 1log10Channel 2log10"; foreach($results as $key => $val){ print "$key"; $median1=$results[$key]["median1"]; $log1=round(log10($median1),3); $median1=round($median1,3); // define colors (red and blue) // red will mean over-expresion, and blue under-expresion $red1=255;$blue1=255;$green1=255; if ($log1<0){ $red1=255-(-1)*round($log1*255); if($red1<0){$red1=0;} $green1=$red1; }elseif ($log1>0){ $blue1=255-round($log1*255); if($blue1<0){$blue1=0;} $green1=$blue1; } print "".$results[$key]["n_data"]."$median1$log1"; $median2=$results[$key]["median2"]; $log2=round(log10($median2),3); // definir color rojo y azul $red2=255;$blue2=255;$green2=255; if ($log2<0){ $red2=255-(-1)*round($log2*255); if($red2<0){$red2=0;} $green2=$red2; }elseif ($log2>0){ $blue2=255-round($log2*255); if($blue2<0){$blue2=0;} $green2=$blue2; } $median2=round($median2,3); print "$median2$log2\n"; } print ""; // END PRINT TABLE // ########################################################################################################## // FUNCTIONS // ########################################################################################################## function process_microarray_data_adaptive_quantification_method($file){ // find data for first column and row, and remove all headings; $file= substr($file,strpos($file,"1\t1\t")); // remove from file returns (\r) and (\") $file=preg_replace("/\r|\"/","",$file); // split file into lines ($data_array) $data_array=preg_split ("/\n/",$file, -1, PREG_SPLIT_NO_EMPTY); // compute data-background (save result in $data_array2) and // sum of all data-background ($sum_ch1 and $sum_ch2) $sum_ch1=0;$sum_ch2=0; foreach($data_array as $key => $val){ // example of line to be splitted: // 1 2 G16 1136 159 538 118 // where 1 and 2 define position in the plate // G16 is name of gene/experiment // 1136 is reading of chanel 1, and 159 is the background // 538 is reading of chanel 2, and 159 is the background $line_element=preg_split("/\t/",$val, -1, PREG_SPLIT_NO_EMPTY); if (sizeof ($line_element)<7){continue;} // This is the name of the gene studied $name=$line_element[2]; // For chanel 1 // calculate data obtained in chanel 1 minus background $ch1_bg=$line_element[3]-$line_element[4]; // save data to a element in $data_array2 (separate diferent calculations from the same gene with commas) $data_array2[$name][1].=",".$ch1_bg; // $sum_ch1 will record the sum of all (chanel 1 - background) values $sum_ch1+=$ch1_bg; // For chanel 2 // calculate data obtained in chanel 2 minus background $ch2_bg=$line_element[5]-$line_element[6]; // save data to a element in $data_array2 (separate diferent calculations from the same gene with commas) $data_array2[$name][2].=",".$ch2_bg; // $sum_ch1 will record the sum of all (chanel 2 - background) values $sum_ch2+=$ch2_bg; // count number of total elements $n_data++; } // Compute (data-background)*100/sum(data-background)), // where sum(data-background) is $sum_ch1 or $sum_ch2 // and save data in $data_array3 foreach($data_array2 as $key => $val){ // split data separated by comma (chanel 1) $data_element=preg_split("/,/",$data_array2[$key][1], -1, PREG_SPLIT_NO_EMPTY); foreach ($data_element as $key2 => $value){ // compute ratios $ratio=$value*100/$sum_ch1; // save result to $data_array3 $data_array3[$key][1].=",$ratio"; } // split data separated by comma (chanel 2) $data_element=preg_split("/,/",$data_array2[$key][2], -1, PREG_SPLIT_NO_EMPTY); foreach ($data_element as $key2 => $value){ // compute ratios $ratio=$value*100/$sum_ch2; // save result to $data_array3 $data_array3[$key][2].=",$ratio"; } } // Compute ratios for values in chanel 1 and chanel 2 // chanel 1/chanel 2 and chanel 2/chanel 1 // save results to $data_array4 foreach($data_array3 as $key => $val){ $data_element1=preg_split("/,/",$data_array3[$key][1], -1, PREG_SPLIT_NO_EMPTY); $data_element2=preg_split("/,/",$data_array3[$key][2], -1, PREG_SPLIT_NO_EMPTY); foreach ($data_element1 as $key2 => $value){ //compute ch1/ch2 $ratio=$data_element1[$key2]/$data_element2[$key2]; // and save $data_array4[$key][1].=",$ratio"; //compute ch2/ch1 $ratio=$data_element2[$key2]/$data_element1[$key2]; // and save $data_array4[$key][2].=",$ratio"; } } ksort($data_array4); foreach($data_array4 as $key => $val){ $results[$key]["n_data"]=substr_count($data_array4[$key][1],","); $results[$key]["median1"]=median($data_array4[$key][1]); $results[$key]["median2"]=median($data_array4[$key][2]); } return $results; } // ########################################################################################################## function mean($cadena) { $data=preg_split("/,/",$cadena,-1,PREG_SPLIT_NO_EMPTY); $sum = 0; $numValidElements = 0; foreach($data as $key => $val) { if(isset($val)) { $sum += $val; $numValidElements += 1; } } $mean = $sum / $numValidElements; $mean =round ($mean,3); return $mean; } // ########################################################################################################## function median($cadena) { $data=preg_split("/,/",$cadena,-1,PREG_SPLIT_NO_EMPTY); sort($data); $i=floor(sizeof($data)/2); if (sizeof($data)/2!=$i){ return $data[$i]; } return ($data[$i-1]+$data[$i])/2; } // ########################################################################################################## function variance($cadena) { $mean=mean($cadena); $data=preg_split("/,/",$cadena,-1,PREG_SPLIT_NO_EMPTY); $sum = 0; $numValidElements = 0; foreach($data as $key => $val) { if( isset($val) ) { $tmp = $val - $mean; $sum += $tmp * $tmp; $numValidElements += 1; } } $variance = $sum / ( $numValidElements - 1 ); $variance=round($variance,3); return $variance; } // ########################################################################################################## function print_form(){ ?>

">
Microarray data:
Copy tabulated data to the textarea as shown. First valid data must correspond to Column 1/Row 1.
All lines preceding data for Column 1/Row 1 will be removed previous to calculations.
Computational procedure:
  1. For each spot, the following is computed for both channels (1 and 2): (value-background)*100/sum(value-background))
  2. With previous results, ch1/ch2 and ch2/ch1 are computed
  3. As there are several replicas for ch1/ch2 and ch2/ch1, median and its base 10 logarithm is computed.
  4. In a table, medians and logs are represented. A color code is used to show over-expression (red) or under-expression (blue).

Source code available at biophp.org

Source code available at biophp.org