Filling in missing values to make an array a set size.

2 views (last 30 days)
I have written some code to detect retention times in the analysis of amino acids. Our current software is useless for this task. Using “for” and “if – else” loops, the code interrogates arrays and sequentially fills rows of data found at the right retention time into empty arrays full of NaN’s. Once done, if there are any rows of data that don’t belong to my target list, I remove those rows using “isnan”. My problem is that the reverse is also true; i.e. I sometimes have missing peaks. In order to export the data back to Excel for other colleagues I need to end up with a matrix which consistently has 22 “peak names” for each sample whether there is data in the row or not. I previously tried using “isempty” in the section of code that searches for the retention times. However, this didn’t work because I rely on an index assignment to fill my “NaN” template arrays an “isempty” returns an empty index. I can’t see how to directly index into the “NaN” template arrays during the retention time interrogation step because the “NaN” template arrays are shorter than the original data. I have tried using “intersect” comparing the array that I get after using “isnan” (which is shorter than the “NaN” template arrays) with a contrived array that contains the sample names and peak list that I want to end up with. But the index only gives perfect matches whereas I’m trying to find where there is a missing peak and insert a row with something like “not found” in it. I’ve also had a look at “ismember”, but the same thing applies. You get an index that is shorter than the “target, 22 x no. of samples” array and as such can’t be used.
ANY IDEAS?
BT 42936_-2339.dxf BT 42936 CO2-1 1 126.4 22.4 753
BT 42936_-2339.dxf BT 42936 CO2-2 2 225.9 22.4 753
BT 42936_-2339.dxf BT 42936 CO2-3 3 325.4 22.4 754
BT 42936_-2339.dxf BT 42936 CO2-5 6 614 22.6 755
BT 42936_-2339.dxf BT 42936 Ala 7 702.9 29.7 252
BT 42936_-2339.dxf BT 42936 Gly 8 741.3 41.8 332
BT 42936_-2339.dxf BT 42936 Thr 9 799 23.2 265
BT 42936_-2339.dxf BT 42936 Ser 10 822.8 20.9 347
BT 42936_-2339.dxf BT 42936 Val 11 837.3 23.4 397
BT 42936_-2339.dxf BT 42936 Leu 12 912.9 18.2 733
BT 42936_-2339.dxf BT 42936 Ile 13 924.2 23.8 450
BT 42936_-2339.dxf BT 42936 Nle 14 959.1 24.5 494
BT 42936_-2339.dxf BT 42936 Pro 15 1051.7 21.5 481
BT 42936_-2339.dxf BT 42936 Asp 17 1121.3 29.7 1216
BT 42936_-2339.dxf BT 42936 Met 20 1167.9 21.1 225
BT 42936_-2339.dxf BT 42936 Phe 23 1318 37.6 312
BT 42936_-2339.dxf BT 42936 Tyr 24 1477 17.8 168
BT 42936_-2339.dxf BT 42936 Lys 25 1505.4 44.7 923
BT 42936_-2339.dxf BT 42936 CO2-6 29 1916.7 23.2 754
BT 42936_-2339.dxf BT 42936 CO2-7 30 1953.9 22.6 758
BT 42936_-2340.dxf BT 42936 CO2-1 1 126.4 22.4 754
BT 42936_-2340.dxf BT 42936 CO2-2 2 225.9 22.4 754
BT 42936_-2340.dxf BT 42936 CO2-3 3 325.4 22.4 754
BT 42936_-2340.dxf BT 42936 CO2-4 5 574.3 22.8 759
BT 42936_-2340.dxf BT 42936 CO2-5 6 614 22.6 755
BT 42936_-2340.dxf BT 42936 Ala 7 702.2 28.2 260
BT 42936_-2340.dxf BT 42936 Gly 8 740.5 44.3 336
BT 42936_-2340.dxf BT 42936 Thr 9 798.2 23 267
BT 42936_-2340.dxf BT 42936 Ser 10 822 21.1 327
BT 42936_-2340.dxf BT 42936 Val 11 836.4 22.8 389
BT 42936_-2340.dxf BT 42936 Leu 12 912.3 19 712
BT 42936_-2340.dxf BT 42936 Ile 13 923.8 22.2 435
BT 42936_-2340.dxf BT 42936 Nle 14 958.9 25.5 512
BT 42936_-2340.dxf BT 42936 Pro 15 1051.3 21.3 482
BT 42936_-2340.dxf BT 42936 Asp 16 1120.7 29.5 1188
BT 42936_-2340.dxf BT 42936 Met 19 1167.3 26.3 221
BT 42936_-2340.dxf BT 42936 Glu 20 1270.7 51.8 877
BT 42936_-2340.dxf BT 42936 Phe 22 1317.5 36.6 279
BT 42936_-2340.dxf BT 42936 Tyr 23 1476.2 20.1 160
BT 42936_-2340.dxf BT 42936 Lys 24 1504.6 44.7 884
BT 42936_-2340.dxf BT 42936 CO2-6 27 1915.5 22.2 756
BT 42936_-2340.dxf BT 42936 CO2-7 28 1957.7 24.2 755
  2 Comments
Ashish Uthama
Ashish Uthama on 2 Nov 2011
Rhys, I cant seem to tie your explanation to the data posted (maybe its a 'domain' thing). Breaking down your processing into steps and posting data, with column headings, at each step might help us understand better.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!