This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Finding Min Value In Array - Python - Without Numpy

I need to find the min value in a matrix or array. The matrix was in the lower triangular.

410488935     410488927     410488931     410488939     410488937     410488923     410488933     
410488935     0.0000
410488927     0.0065 0.0000
410488931     0.0098 0.0098 0.0000
410488939     0.0850 0.0850 0.0784 0.0000
410488937     0.0817 0.0817 0.0752 0.0033 0.0000
410488923     0.0817 0.0817 0.0752 0.0033 0.0065 0.0000
410488933     0.1340 0.1340 0.1275 0.1340 0.1307 0.1307 0.0000

I removed the row and column labels and placed them into separate lists. Then I replaced the "0" diagonal with X's, to assist in find the lowest value. How can I get the position, row and column number, for the minimum value in the matrix. As well as the min value itself? The labels list and array look like this now:

[['410488935', '410488927', '410488931', '410488939', '410488937', '410488923', '410488933']] 

[[['X'], ['0.0065', 'X'], ['0.0098', '0.0098', 'X'], ['0.0850', '0.0850', '0.0784', 'X'], ['0.0817', '0.0817', '0.0752', '0.0033', 'X'], ['0.0817', '0.0817', '0.0752', '0.0033', '0.0065', 'X'], ['0.1340', '0.1340', '0.1275', '0.1340', '0.1307', '0.1307', 'X']]]
python array

closing as not bioinformatics.

1 answer

Why don't you write a function that passes each list as a parameter? For example...

function getMin(list):
    toLoop = len(list)-1

    tempList = []
    for x in range(0, toLoop):
        tempList.append(list[x])

    print min(tempList)

That should help you get at least the minimum value for each list.

Log in to answer this question.