Hello to all,
I am very new in the shell scripting and I need help. I have data for several individuals in several rows followed by a tag and by 5 values per row, with the name of the individual in the first column, e.g.:
IND1 H1 12 13 12 15 14
IND2 H2 12 12 15 14 14
IND3 H1 12 15 12 14 11
I would like to calculate the sum of the absolute values of the pairwise differences between individuals. For instance:
Distance between IND1 and IND2=|12-12|+|13-12|+|12-15|+|15-14|+|14-14|= 5
Distance between IND1 and IND3=|12-12|+|13-15|+|12-12|+|15-14|+|14-11|= 6
Distance between IND2 and IND3=|12-12|+|12-15|+|15-12|+|14-14|+|14-11|= 9
Additionally, if the tags of two individuals are different, I would like to sum 100 to the final number. So finally the distance between:
IND1 and IND2 would be = 5 + 100 = 105
IND1 and IND3 would be = 6 + 0 = 6
IND2 and IND3 would be = 9 + 100 = 109
After this, I would like to transform this list of distances into a matrix:
IND1 IND2 IND3
IND1
IND2 105
IND3 6 109
Could some one help me with this? Thanks a lot in advance! Best!