Changeset 4318
- Timestamp:
- May 27, 2008, 10:08:15 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.7-stable/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java
r4235 r4318 4 4 Copyright (C) 2006 Johan Enell, Jari Hakkinen, Nicklas Nordborg, Martin Svensson 5 5 Copyright (C) 2007 Johan Enell, Jari Hakkinen, Peter Johansson, Nicklas Nordborg, Martin Svensson 6 Copyright (C) 2008 Jari Hakkinen, Nicklas Nordborg 6 7 7 8 This file is part of BASE - BioArray Software Environment. … … 105 106 use in MeV (available from http://www.tm4.org). 106 107 - BASEfile. 107 - Plain Matrix 108 - Plain Matrix, see documentation for exportPlainMatrix method for 109 a description of the format. 108 110 109 111 @author enell, jari, peter … … 602 604 603 605 /** 604 Export bioassayset data in MeV format. The export includes 605 all reporter information and all experimental factor information. If the 606 expriment is a two-channel experiment the log ratio is exported as the 607 expression value otherwise the raw intensity of channel 1 is exported. 606 Export bioassayset data in MeV format. The export includes all 607 reporter information and all experimental factor information. If 608 the expriment is a two-channel experiment the ch1/ch2 ratio 609 (non-log value!) is exported as the expression value otherwise the 610 raw intensity of channel 1 is exported. 608 611 609 612 @param bioassayset The bioassayset to export … … 708 711 int position=-1; 709 712 short column=nof_bioassays; 710 double log2=Math.log(2.0);711 713 int nof_reporters=bioassayset.getNumReporters(); 712 714 int progress_report_interval=nof_reporters/10; … … 771 773 772 774 775 /** 776 Export bioassayset data in plain matrix format. 777 778 Plain matrix format is simply a matrix with no header nor reporter 779 information. Each column in the matrix corresponds to an assay, 780 and each row corresponds to a reporter. 781 782 Missing values are reported as entries with no number and 'NaN' is 783 reported for undefined values (such as division with zero). Note, 784 reporters with no measurement within a bioassay set are not 785 reported at all, i.e., a row is not exported with misssing values 786 only. To be clear, we state this once more: Rows (reporters) are 787 only exported if one or more columns (assays) have a value. The 788 value can be 'NaN'. 789 790 The data exported depends on the underlying microarray platform; 791 - 1-channel: raw ch1 intensity 792 - 2-channel: the fraction ch1/ch2, note! non-log value 793 The justification for exporting non-log values for 2-channel data 794 is to follow the MeV export format where non-log data is exported 795 for 2-channel data. 'NaN' is returned for zero ch2 values. 796 797 The plug-in or user that uses this method must keep track of the 798 row and column information themselves. The row is sorted in 799 ascending position order, the columns are sorted in ascending 800 column order. 801 802 @param bioassayset The bioassayset to export 803 @param os The stream to write the exported data to 804 @param progress An optional progress reporter 805 @throws IOException If there is an IO error 806 @throws SQLException If there is an error reading from the database 807 */ 773 808 public void exportPlainMatrix(BioAssaySet bioassayset, OutputStream os, 774 809 ProgressReporter progress) … … 778 813 DbControl dc=bioassayset.getDbControl(); 779 814 PrintWriter out = new PrintWriter(os); 780 List<ExtendedProperty> reporterProperties =781 ExtendedProperties.getProperties("ReporterData");782 815 783 816 int nof_bioassays=0; 784 817 nof_bioassays=bioassayset.getBioAssays().list(dc).size(); 818 int nof_channels=bioassayset.getRawDataType().getChannels(); 785 819 786 820 if (progress != null) … … 792 826 query.select(Dynamic.select(VirtualColumn.POSITION)); 793 827 query.select(Dynamic.select(VirtualColumn.COLUMN)); 794 query.select(Dynamic.select(VirtualColumn.channel(1))); 795 828 for (int i=1; i<=nof_channels; ++i) 829 { 830 query.select(Dynamic.select(VirtualColumn.channel(i))); 831 } 832 796 833 query.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION))); 797 834 query.order(Orders.asc(Dynamic.column(VirtualColumn.COLUMN))); … … 801 838 int column_position=spotData.getIndex(VirtualColumn.POSITION.getName()); 802 839 int column_column=spotData.getIndex(VirtualColumn.COLUMN.getName()); 803 int column_channel=spotData.getIndex(VirtualColumn.channel(1).getName()); 804 840 int[] column_channel=new int[nof_channels]; 841 for (int i=0; i<nof_channels; ++i) 842 { 843 column_channel[i]=spotData.getIndex(VirtualColumn.channel(i+1).getName()); 844 } 845 805 846 int position=-1; 806 847 int column=nof_bioassays; 807 //double log2=Math.log(2.0);808 848 int nof_spots=bioassayset.getNumSpots(); 809 849 int progress_spot_interval=nof_spots/10; … … 848 888 849 889 // Calculate expression value 850 String ch1=item.getString(column_channel); 851 out.write(ch1); 852 } 853 out.flush(); 890 double exValue=item.getFloat(column_channel[0]); 891 boolean goodvalue=true; 892 if (nof_channels==2) 893 { 894 double ch2=item.getFloat(column_channel[1]); 895 if (ch2!=0) 896 { 897 exValue/=ch2; 898 } 899 else 900 { 901 goodvalue=false; 902 } 903 } 904 905 out.write( "\t" + (goodvalue ? exValue : "NaN")); 906 } 907 out.close(); 854 908 } 855 909 … … 1095 1149 formats.add(FORMAT_MEV, "MultiExperiment Viewer (MeV)"); 1096 1150 formats.add(FORMAT_BASEFILE, "BASEfile"); 1097 // formats.add(FORMAT_PLAIN_MATRIX, "Plain Matrix"); 1151 /** 1152 Plain matrix export is currently not supported from the web 1153 interface. Simply move the code line below outside this 1154 comment block to enable plain matrix export in the web 1155 interface. If the export is enabled the About information 1156 should be updated to reflect the change. 1157 1158 formats.add(FORMAT_PLAIN_MATRIX, "Plain Matrix"); 1159 */ 1098 1160 formatParameter = new PluginParameter<String> 1099 1161 ( "fileformat", … … 1292 1354 "- Tab Delimited, Multiple Sample Files (TDMS Format) for " + 1293 1355 "use in MeV (available from http://www.tm4.org).\n"+ 1294 "- BASEfile ",1356 "- BASEfile\n", 1295 1357 "2.0", 1296 1358 "2006, Base 2 development team",
Note: See TracChangeset
for help on using the changeset viewer.