Skip to content

Commit

Permalink
Fix infinite range for histplot td score
Browse files Browse the repository at this point in the history
  • Loading branch information
JannesSP committed Aug 8, 2023
1 parent dd14c6c commit 3d3aea9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions magnipore/magnipore.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ def plotStatistics(plotting_data : pd.DataFrame, working_dir : str, first_sample

def plotScores(dataframe : pd.DataFrame, working_dir : str, first_sample_label : str, sec_sample_label : str) -> None:

dataframe = dataframe[dataframe['TD Score']>0] # otherwise logscale range is infinite with lower bound: -infinity

colors = {
'False, False':'wheat',
'False, True':'darkorange',
Expand All @@ -405,7 +403,8 @@ def plotScores(dataframe : pd.DataFrame, working_dir : str, first_sample_label :

plt.figure(figsize = (12,8), dpi=300)
plt.title(f'TD score for all positions\n{first_sample_label} vs. {sec_sample_label}')
sns.histplot(data=dataframe, x='TD Score', hue=dataframe['Mutation, Significance'], log_scale=(True, True), multiple="stack", palette=colors)
# otherwise logscale range is infinite with lower bound: -infinity
sns.histplot(data=dataframe[dataframe['TD Score']>0], x='TD Score', hue=dataframe['Mutation, Significance'], log_scale=(True, True), multiple="stack", palette=colors)
plt.grid(True, 'both', 'both', alpha=0.6, linestyle='--')
plt.tight_layout()
plt.savefig(os.path.join(working_dir, f'{first_sample_label}_{sec_sample_label}_td_score.png'))
Expand All @@ -414,7 +413,8 @@ def plotScores(dataframe : pd.DataFrame, working_dir : str, first_sample_label :

plt.figure(figsize = (12,8), dpi=300)
plt.title(f'Kullback-Leibler divergence for all positions\n{first_sample_label} vs. {sec_sample_label}')
sns.histplot(data=dataframe, x='KL Divergence', hue=dataframe['Mutation, Significance'], log_scale=(True, True), multiple="stack", palette=colors)
# otherwise logscale range is infinite with lower bound: -infinity
sns.histplot(data=dataframe[dataframe['KL Divergence']>0], x='KL Divergence', hue=dataframe['Mutation, Significance'], log_scale=(True, True), multiple="stack", palette=colors)
plt.grid(True, 'both', 'both', alpha=0.6, linestyle='--')
plt.tight_layout()
plt.savefig(os.path.join(working_dir, f'{first_sample_label}_{sec_sample_label}_kl_div.png'))
Expand Down

0 comments on commit 3d3aea9

Please sign in to comment.