Search code examples
matlabmatrixbioinformatics

Find row index of elements in a matrix <0.001, excluding certain rows


I am using the Cobra Toolbox in MATLAB to perform a double gene knockout study and output for growth ratios is a 100 by 100 matrix called grRatioDble. I need to find the row and column index for elements of this matrix which are <0.001, excluding the rows which were essential on single gene knockout. I have a one-column matrix of the row indexes that I want to exclude. Is there an easy way to do this?

(NB: I cannot just remove the unwanted rows from the matrix as then row, column index changes for the remaining cells)


Solution

  • This piece of code should do the work:

    1. Get all row/col indexes where grRatioDble<0.001:

      [row,col] = find(grRatioDble<0.001);
      
    2. Exclude unwanted rows (say the vector containing unwanted rows is rows2exclude):

      row = row(~ismember(row, rows2exclude));
      col = col(~ismember(row, rows2exclude));