Skip to content

Commit f658c94

Browse files
committed
Closing plots
1 parent ea82c3a commit f658c94

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ a framework written in Python 3 for performing sequence-based machine learning-a
3333
- Direct coupling analysis (amino acid coevolution based on multiple sequence alignments) encoding
3434
- LLM embeddings (currently, [ESM1v](https://github.com/facebookresearch/esm) and [ProSST](https://github.com/ai4protein/ProSST))
3535

36-
Written by Niklas Siedhoff and Alexander-Maurice Illig.
37-
3836
<p align="center">
3937
<img src=".github/imgs/ML_Model_Performance_DCA_GREMLIN.png" alt="drawing" width="500"/>
4038
</p>
@@ -68,12 +66,16 @@ pypef --help
6866
<a name="gui"></a>
6967
### GUI
7068

69+
```
70+
pip install -U pypef[gui]
71+
```
72+
7173
After installation, a rudimentary graphical user interface (GUI) can be invoked using the command
7274

7375
```bash
7476
pypef-gui # loading takes some seconds
7577
# or
76-
pypef-gui-cli # command for keeping background debug/tqdm progress information in terminal on Windows
78+
pypef-gui-cli # command for keeping background debug/tqdm progress information in terminal (only Windows OS-specific)
7779
```
7880

7981
<p align="center">

pypef/dca/gremlin_inference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(
8484
else "cpu"
8585
)
8686
self.device = device
87-
logger.info(f'Using {self.device.upper()} for GREMLIN computations...')
87+
logger.info(f'Using {self.device.upper()} device for GREMLIN computations...')
8888
self.char_alphabet = char_alphabet
8989
self.allowed_chars = "ARNDCQEGHILKMFPSTWYV-"
9090
self.allowed_chars += self.allowed_chars.lower()
@@ -734,6 +734,8 @@ def plot_predicted_ssm(gremlin: GREMLIN):
734734
ax.set_yticks(range(len(aas)), aas, size=6)
735735
plt.tight_layout()
736736
plt.savefig('SSM_landscape.png', dpi=500)
737+
plt.clf()
738+
plt.close('all')
737739
pd.DataFrame(
738740
{
739741
'Variant': np.array(variantss).flatten(),

pypef/gui/qt_window.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,12 @@ def work(self):
119119
from such long working thread job during run, e.g.,
120120
every trained epoch from the executed imported function.
121121
"""
122-
thread_name = QThread.currentThread().objectName()
123-
#self.sig_msg.emit(
124-
# f'Running worker #{self.__id} from thread "{thread_name}" '
125-
# f'executing command: "{self.cmd}"'
126-
#)
127122
print(f"Executing command: {self.cmd}")
128-
129123
run_main(argv=self.cmd)
130124
self.sig_done.emit(f"Done: {self.__id}")
131125

132126
def abort(self):
133127
self.sig_msg.emit(f'Worker #{self.__id} notified to abort')
134-
#self.__abort = True
135128

136129

137130
class SecondWindow(QWidget):
@@ -162,7 +155,6 @@ def __init__(self):
162155
# Texts #########################################################################
163156
layout = QGridLayout(self) # MAIN LAYOUT: QGridLayout
164157
self.version_text = QLabel(f"PyPEF v. {__version__}", alignment=Qt.AlignRight)
165-
#self.ncores_text = QLabel("Single-/multiprocessing")
166158
self.llm_text = QLabel("LLM")
167159
self.regression_model_text = QLabel("Regression model")
168160
self.utils_text = QLabel("Utilities")

pypef/utils/directed_evolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ def plot_trajectories(self):
377377
plt.tight_layout()
378378
plt.savefig(str(self.model) + '_DE_trajectories.png', dpi=500)
379379
plt.clf()
380+
plt.close('all')
380381

381382
with open(os.path.join('EvoTraj', 'Trajectories.csv'), 'w') as file:
382383
file.write('Trajectory;Variant;Sequence;Fitness\n')

pypef/utils/low_n_mutation_extrapolation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def plot_low_n(
5858

5959
plt.savefig(plt_name.split(os.sep)[-1] + '.png', dpi=500)
6060
plt.clf()
61+
plt.close('all')
6162

6263

6364
def low_n(
@@ -386,3 +387,4 @@ def plot_extrapolation(
386387
name = name.split(os.sep)[-1] + '_extrapolation.png'
387388
plt.savefig(name, dpi=500)
388389
plt.clf()
390+
plt.close('all')

pypef/utils/plot.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ def plot_y_true_vs_y_pred(
4242
y_true=y_true, y_pred=y_pred
4343
)
4444
plt.scatter(
45-
y_true, y_pred, marker='o', s=20, linewidths=0.5, edgecolor='black', alpha=0.7, c=y_true, vmin=min(y_true), vmax=max(y_true),
46-
label=r'$R^2$' + f' = {r_squared:.3f}' + f'\nRMSE = {rmse:.3f}' + f'\nNRMSE = {nrmse:.3f}'
47-
+ f'\nPearson\'s ' + r'$r$'+f' = {pearson_r:.3f}'
48-
+ f'\nSpearman\'s ' + fr'$\rho$ = {spearman_rho:.3f}' + '\n'
49-
+ r'Recall$_\mathrm{top 10 \%}$' + f' = {rec:.3f}\n'
50-
+ fr'($N$ = {len(y_true)})'
45+
y_true, y_pred, marker='o', s=20, linewidths=0.5,
46+
edgecolor='black', alpha=0.7, c=y_true,
47+
vmin=min(y_true), vmax=max(y_true),
48+
label=r'$R^2$' + f' = {r_squared:.3f}' + f'\nRMSE = {rmse:.3f}' + f'\nNRMSE = {nrmse:.3f}'
49+
+ f'\nPearson\'s ' + r'$r$'+f' = {pearson_r:.3f}' + f'\nSpearman\'s '
50+
+ fr'$\rho$ = {spearman_rho:.3f}' + '\n' + r'Recall$_\mathrm{top 10 \%}$'
51+
+ f' = {rec:.3f}\n' + fr'($N$ = {len(y_true)})'
5152
)
5253
if name != '':
5354
file_name = f'ML_Model_Performance_{name}.png'
@@ -77,5 +78,6 @@ def plot_y_true_vs_y_pred(
7778
# file_name = f'DCA_Hybrid_Model_LS_TS_Performance({i}).png'
7879
plt.colorbar()
7980
plt.savefig(file_name, dpi=500)
81+
plt.clf()
8082
plt.close('all')
8183
logger.info(f'Saved plot as {os.path.abspath(file_name)}...')

0 commit comments

Comments
 (0)