Commit b967a86c by Mustafa Tekpinar

Converted the tranposed escott output to ranksorted format.

parent 885b6e63
......@@ -1415,10 +1415,34 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode,
colorMap=colormap, offSet=offset, pixelType='square',\
sequence=prot+".fasta", interactive=False, isColorBarOn=True)
#Convert standard combined output to a transposed format to increase
#legibility.
#Convert standard combined output to (1 minus) ranksorted transposed format to increase
#legibility and interpretibility.
gemmeDF = pd.read_table(prot+"_normPred_evolCombi.txt", sep="\s+")
gemmeDFtrans = gemmeDF.T
# print(gemmeDF)
######################################################################
# Convert the DataFrame to a NumPy matrix
from scipy.stats import rankdata
import numpy as np
#matrix = gemmeDF.to_numpy()
maxValue =np.nanmax(gemmeDF.to_numpy())
# print(maxValue)
matrix = gemmeDF.to_numpy(na_value=maxValue)
# Use rankdata to get the ranks for all values in the matrix
ranks = 1.0 - rankdata(matrix, method='average')/len(matrix.flatten())
# Reshape the ranks back to the original matrix shape
ranks_matrix = ranks.reshape(matrix.shape)
# Convert the ranks matrix back to a DataFrame
df_ranks = pd.DataFrame(ranks_matrix, columns=gemmeDF.columns, index=gemmeDF.index)
# df_ranks.set_index(gemmeDF.index.tolist(), inplace=True)
# print(df_ranks)
gemmeDFtrans = df_ranks.T
######################################################################
# gemmeDFtrans = gemmeDF.T
# print(gemmeDF)
gemmeDFtrans.columns = gemmeDFtrans.columns.str.upper()
aaAndPosition = []
......@@ -1431,7 +1455,7 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode,
# gemmeDFtrans.rename(index=aaAndPosition, inplace=True)
# gemmeDFtrans['pos'] = aaAndPosition
#print(df['pos'])
gemmeDFtrans.to_csv(prot+"_normPred_evolCombiTransposed.txt", sep='\t', float_format='%.2f', na_rep='NaN')
gemmeDFtrans.to_csv(prot+"_normPred_evolCombiTransposedRanksorted.txt", sep='\t', float_format='%.2f', na_rep='NaN')
#sys.exit(-1)
else:
......@@ -1443,7 +1467,7 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode,
def main():
"""
Main function (and yes, I know. The name and the documentation are ingenious :).
Main function (and yes, I know. The name and the function documentation are ingenious :).
"""
tic = time.perf_counter()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment