Skip to content

Commit 3d3aea9

Browse files
committed
Fix infinite range for histplot td score
1 parent dd14c6c commit 3d3aea9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

magnipore/magnipore.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,6 @@ def plotStatistics(plotting_data : pd.DataFrame, working_dir : str, first_sample
394394

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

397-
dataframe = dataframe[dataframe['TD Score']>0] # otherwise logscale range is infinite with lower bound: -infinity
398-
399397
colors = {
400398
'False, False':'wheat',
401399
'False, True':'darkorange',
@@ -405,7 +403,8 @@ def plotScores(dataframe : pd.DataFrame, working_dir : str, first_sample_label :
405403

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

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

0 commit comments

Comments
 (0)