Home > Mobile >  Provide List of Genes with Maximum Value Expression By Condition - Numpy
Provide List of Genes with Maximum Value Expression By Condition - Numpy

Time:12-13

I have a pickle file of three arrays: gene list, condition list, and then expression value. I'm trying to figure out how to produce a list of the of the genes with the maximum value for expression for each condition. Essentially the following:

enter image description here

So in this case, the program would provide a list of: YAL001C, YAL001C, YAL001C, YAL003W The YAL... are the gene labels and the cl... labels are the condition list. I know how to find the maximum value per column, but I'm at a loss for how to output a list of the genes. Can anyone provide any suggestions for me? The code I have so far basically just utilizes the numpy.max() argument with the axis specified as 0.

CodePudding user response:

I think what you want to do is use numpy.argmax with the axis specified as 0, this will return the list of indices where the maximum for each condition is found. You can then index your genes array with the array of indices.

indices = numpy.argmax(expression_value, axis=0)
print(genes[indices])
  • Related