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, ...@@ -1415,10 +1415,34 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode,
colorMap=colormap, offSet=offset, pixelType='square',\ colorMap=colormap, offSet=offset, pixelType='square',\
sequence=prot+".fasta", interactive=False, isColorBarOn=True) sequence=prot+".fasta", interactive=False, isColorBarOn=True)
#Convert standard combined output to a transposed format to increase #Convert standard combined output to (1 minus) ranksorted transposed format to increase
#legibility. #legibility and interpretibility.
gemmeDF = pd.read_table(prot+"_normPred_evolCombi.txt", sep="\s+") 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) # print(gemmeDF)
gemmeDFtrans.columns = gemmeDFtrans.columns.str.upper() gemmeDFtrans.columns = gemmeDFtrans.columns.str.upper()
aaAndPosition = [] aaAndPosition = []
...@@ -1431,7 +1455,7 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode, ...@@ -1431,7 +1455,7 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode,
# gemmeDFtrans.rename(index=aaAndPosition, inplace=True) # gemmeDFtrans.rename(index=aaAndPosition, inplace=True)
# gemmeDFtrans['pos'] = aaAndPosition # gemmeDFtrans['pos'] = aaAndPosition
#print(df['pos']) #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) #sys.exit(-1)
else: else:
...@@ -1443,7 +1467,7 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode, ...@@ -1443,7 +1467,7 @@ def doit(inAli,mutFile,retMet,bFile,fFile,n,N, jetfile, pdbfile, normWeightMode,
def main(): 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() 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