-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1056 lines (941 loc) · 47 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Avoiding common annoyances in bioinformatics</title>
<meta name="author" content="Pieter Moris">
<!-- <link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css"> -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/monokai.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section style="font-size: 0.7em;">
<h1>1111 rules for avoiding misery in bioinformatics</h1>
<h3>or a bunch of stupid things I've done</h3>
<h3>or an excuse to spout my opinion and act smug</h3>
<p>
<medium>Created by Pieter Moris</medium>
</p>
</section>
<!-- GIT -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e">
<h1>Use version control</h1>
<h4 class="fragment visible">Preferably <code>git</code></h4>
</section>
<!-- <section>
<h4>Use version control - preferably <code>git</code>.</h4>
<p>Nuff' said.</p>
</section> -->
<!-- <section>
<p>Why?</p>
</br>
<span class="fragment">
<img class="fragment visible" data-src="assets/why-you-need-vcs.jpg" alt="version-control-r-files">
</br>
<ul style="font-size: 0.7em">
<li class="fragment visible">Safety</li>
<li class="fragment visible">History</li>
<li class="fragment visible">Organization</li>
</ul>
</span>
</section> -->
<section>
<p>Why?</p>
<div class="column_container">
<div class="col">
<img class="fragment visible" data-src="assets/why-you-need-vcs.jpg"
alt="version-control-r-files">
</div>
<div class="col">
<ul style="vertical-align: middle;">
<li class="fragment visible">Safety</li>
<li class="fragment visible">History</li>
<li class="fragment visible">Organization</li>
</ul>
</div>
</div>
<!-- Notes: use it so you don't end up with this nonsense. It's safe because you'll be able to re-trace your steps and get a free backup. You get an overview of your history and attempts, because you sure as hell won't remember what you were doing two weeks from now. It also allows you to be better organized, by avoiding these redundant naming schemes and making you think about which files should be available and where they should be located. -->
</section>
<section>
<p>How?</p>
<ul class="fragment">
<li style="padding: 10px;">My git internals tutorial: <a
href=https://pmoris.github.io/git-gud>https://pmoris.github.io/git-gud </a> </li> <li
style="padding: 10px;">Various other resources and tutorials are collected in my
computational skill set primer.</li>
</ul>
</section>
<section style="font-size: 0.65em">
<h4>Beware git GUIs</h4>
<p><span class="emphasized">Use the command line</span> as much as possible for interacting with
<code>git</code> and only rely on a GUI for visualisation of history and file diffs.</p>
</br>
<p class="fragment">Reason: GUIs sometimes hide steps, use slightly different naming conventions or
try to be smart and automate certain steps, which can cause a lot of confusion, anxiety and/or
horror.</p>
<p class="fragment">Or they just choke completely after a <code>git rebase -i</code>.</p>
<div style="font-size: 0.9em" class="fragment">
</br>
<p>Read more in the primer, important aspects include: </p>
<ul>
<li>How to generate SSH keys and how to use them in other git-aware tools.</li>
<li>Use a private commit e-mail address and don't accidentally overwrite it.</li>
<li><code>git clone</code> is just a way to download a repository to your computer.</li>
</ul>
</div>
</section>
<!-- <section data-menu-title="git SSH vs HTTPS"> -->
<section>
<h4>These are not the same!</h4>
<img style="border: 0;" height="100%" data-src="assets/ssh-https.png" alt="ssh-https-github">
<p>GitHub recommends HTTPS, but SSH allows you to use your SSH key instead of requiring login
credentials for each remote action.</p>
<ul style="font-size: 0.6em">
<li><a
href="https://help.github.com/en/articles/which-remote-url-should-i-use">https://help.github.com/en/articles/which-remote-url-should-i-use</a>
</li>
<li><a
href="https://stackoverflow.com/questions/11041729/why-does-github-recommend-https-over-ssh">https://stackoverflow.com/questions/11041729/why-does-github-recommend-https-over-ssh</a>
</li>
</ul>
</section>
<section style="font-size: 0.8em">
<!-- <section style="font-size: 0.8em" data-menu-title="GitKraken"> -->
<h3>Side note for those that use <span style="color: #a6e22e">GitKraken</span>: </h3>
<ul>
<li>GitKraken account != GitHub account != git username</li>
<li>Profile overwrites your git e-mail <code>git config --list</code></li>
</ul>
</section>
</section>
<!-- EXCEL -->
<section>
<section data-menu-title="Spreadsheet software woes">
<h2>Be careful when using <span style="color: #a6e22e">Excel</span> or equivalents</h2>
<img class="stretch" data-src="assets/excel.png" alt="excel">
</section>
<section style="font-size: 0.4em">
<img class="stretch" data-src="assets/gene-names-dates.png" alt="gene-names-dates">
<blockquote>
Mistaken Identifiers: Gene name errors can be introduced inadvertently when using Excel in
bioinformatics (Zeeberg et al., 2004. <a
href="https://doi.org/10.1186/1471-2105-5-80">https://doi.org/10.1186/1471-2105-5-80</a>)
</blockquote>
<blockquote>
Gene name errors are widespread in the scientific literature (Ziemann et al., 2016. <a
href="https://doi.org/10.1186/s13059-016-1044-7">https://doi.org/10.1186/s13059-016-1044-7</a>)
</blockquote>
</section>
<section style="font-size: 0.6em">
<img class="stretch" data-src="assets/encoding.png" alt="encoding">
<p class="fragment">Other lessons to learn: encapsulate fields (<code>"entry-filled with, separators
you use to separate; columns"</code>) and mind character encoding (almost always opt for
<code>UTF-8</code>).</p>
<p class="fragment">Similar issues can crop up when importing data into <code>R</code> or
<code>pandas</code> dataframes, so be explicit and specify the encoding!</p>
</section>
</section>
<!-- HOTKEYS -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e">
<h1>Familiarise yourself with hotkeys and shortcuts ⌨</h1>
</section>
<!-- <section data-background-transition="zoom" data-background="#191919">
<h1 style="color: #a6e22e">Familarise yourself with hotkeys and shortcuts</h1>
</section> -->
<!-- <section data-background-transition="zoom" data-background="#466111">
<h1>Familarise yourself with hotkeys and shortcuts</h1>
</section> -->
<section>
<p>Seeing other people navigate their computer sometimes triggers a deep silent rage within me.</p>
<img class="stretch" data-src="assets/screaming.gif" alt="screaming">
</section>
<section style="font-size: 0.9em">
<h3>Notorious examples include:</h3>
</br>
<ul>
<li>Not using <span class="emphasized">tab-completion</span> whenever possible (and mistyping
file paths as a consequence).</li>
<li>Re-typing commands in a terminal instead of using the <span
class="emphasized">history</span> <span style="font-size: 70%">(<code>↑</code> key or
history search function <code>ctrl + r</code>)</span>.</li>
<li>Using the mouse and GUI buttons to run code in notebooks or IDEs.</li>
</ul>
</section>
<section>
<blockquote>Spend 10 minutes now to save many more in the future.</blockquote>
</br>
<p class="fragment">Especially important in your <span class="emphasized">terminal</span>, <span
class="emphasized">file manager</span> and <span class="emphasized">IDE</span> or <span
class="emphasized">text editor</span>.</p>
</section>
<section style="font-size: 0.75em">
<h4>Additional examples and resources</h4>
<ul>
<li>Your <span class="emphasized">terminal</span> has dozens of neat shortcuts, like moving the
cursor to the start/end of a line, deleting whole words, etc.</li>
<li class="fragment">R and Jupyter <span class="emphasized">notebooks</span> have hotkeys to
create cells, switch between cell types, run the current/above/below/all cells</li>
<li class="fragment">In RStudio select lines and use <code>ctrl + return</code> to run just them
(or all lines).</li>
<li class="fragment">Use automatic docstring <span class="emphasized">generators</span>. <span
style="font-style: italic">You are writing docstrings, aren't you?</span></li>
<li class="fragment">Decide on a code <span class="emphasized">formatter + linter</span> and use
it consistently, most editors can do this for you (e.g. VS code + <code>black</code> and
<code>flake8</code>).</li>
</ul>
<p>Check out the primer for more resources on this topic.</p>
</section>
</section>
<!-- COPYING CODE -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e">
<h1>Be careful when copying code from the web ✂📋</h1>
</section>
<section>
<pre><code class="sh" data-trim data-noescape>
pieter 🐍 base ~ sudo apt install –y cowsay
[sudo] password for pieter:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package –y
</code></pre>
<p class="fragment" style="font-size: 0.7em"><code>—</code> (em dash) VS <code>–</code> (en dash) VS
<code>-</code> (hyphen ~= hyphen-minus)</p>
</br>
<pre class="fragment"><code class="sh" data-trim data-noescape>
pieter 🐍 base ~ echo “something profound”
“something profound”
pieter 🐍 base ~ echo "something else"
something else
</code></pre>
<span class="fragment" style="font-size: 0.7em">
<p>curly or smart and straight or vertical quotation marks</p>
<p><code>“ ”</code> VS <code>" "</code></p>
<p><code>‘ ’</code> VS <code>' '</code></p>
</span>
</section>
</section>
<!-- TERMINAL TIPS -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e">
<h1>Terminal tips <i class="fas fa-terminal"></i></h1>
</section>
<section>
<ul>
<li>Increase the length of your bash history: <br> <code>echo "HISTFILESIZE=100000" >>
~/.bashrc</code> and use <code>ctrl + r</code> to search through it.</li>
<br>
<li class="fragment">Create aliases and save short scripts: <br> <code>echo alias vpn="sudo
openconnect vpn.uantwerpen.be" >> ~/.bash_aliases</code> </li>
</ul>
</section>
<section>
<h4>Be careful when using <code>rm</code>.</h4>
<ul style="font-size: 0.8em">
<li><code>cd /so/very/deep/in/a/path && rm -rf dir</code></li>
<li>Place dangerous flags after the path: <code>rm /path/to/dir -r</code>. <small>Accidentally
pressing enter too soon is less likely to cause harm.</small></li>
<li>Tab completion helps!</li>
<li><code>touch -- -i</code> in important directories.</li>
<li>Use <a href="https://launchpad.net/safe-rm">https://launchpad.net/safe-rm</a></li>
<li>Don't use trailing slashes or dot-slash starts in your filepaths: <br> <code>rm -rf ./* # *;
rm -rf $FOO/ # $FOO</code></li>
</ul>
</section>
<section id="path">
<h4>What is the <span class="emphasized">PATH</span>?!‽‽‽</h4>
<span class="fragment" style="font-size: 0.8em">
<p>List of directories where the shell searches for executable files.</p>
<div class="column_container">
<div style="font-size: 0.55em;" class="fragment" class="col">
<h6>Windows</h6>
<img width="65%" data-src="assets/windows-path.jpg" alt="path-windows">
</div>
<div style="font-size: 0.55em; margin-left: 50px !important; text-align:left !important"
class="col">
<span class="fragment">
<h6>Unix</h6>
<code class="shell" data-trim>
$ echo $PATH <br>
/home/pieter/.nvm/versions/node/v10.5.0/bin:/home/pieter/.rbenv/shims:/home/pieter/.rbenv/bin:/opt/pycharm/bin:/home/pieter/miniconda3/bin:/home/pieter/miniconda3/condabin:/home/pieter/bin:/home/pieter/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-10-oracle/bin:/usr/lib/jvm/java-10-oracle/db/bin:/usr/lib/jvm/java-11-openjdk-amd64/bin:/home/pieter/miniconda3/envs/tools/bin
</code>
</span>
<br><br>
<code class="fragment">
echo 'export PATH="$PATH:/home/pieter/miniconda3/envs/tools/bin"' >> .bash_rc
</code>
</div>
</div>
<ul style="font-size: 0.5em">
<li><a
href="https://astrobiomike.github.io/unix/modifying_your_path">https://astrobiomike.github.io/unix/modifying_your_path</a>
</li>
<li><a
href="https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them">https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them</a>
</li>
</ul>
</span>
</section>
<section>
<p>You can use the following commands to find out where a command is located:</p>
<pre class="stretch"><code class="sh" data-trim data-noescape>
$ which python # only works if binary is included in $PATH
/home/pieter/miniconda3/bin/python
$ conda activate tools
$ which python
/home/pieter/miniconda3/envs/tools/bin/python
$ whereis python # searches hard-coded paths regardless of $PATH
python: /usr/bin/python3.6 /usr/bin/python3.5 /usr/bin/python3.6m-config /usr/bin/python3.6m /usr/bin/python3.5m /usr/bin/python3.6-config /usr/bin/python2.7 /usr/bin/python /usr/lib/python3.6 /usr/lib/python3.5 /usr/lib/python2.7 /usr/lib/python3.7 /etc/python3.6 /etc/python3.5 /etc/python2.7 /etc/python /usr/local/lib/python3.6 /usr/local/lib/python3.5 /usr/local/lib/python2.7 /usr/include/python3.6 /usr/include/python3.6m /usr/include/python2.7 /usr/share/python /home/pieter/miniconda3/envs/tools/bin/python3.7 /home/pieter/miniconda3/envs/tools/bin/python3.7m /home/pieter/miniconda3/envs/tools/bin/python3.7m-config /home/pieter/miniconda3/envs/tools/bin/python3.7-config /home/pieter/miniconda3/envs/tools/bin/python /usr/share/man/man1/python.1.gz
$ echo alias vpn=openconnect vpn.uantwerpen.be >> .bash_aliases
$ type vpn # searches environment including $PATH and aliases (or "command -v")
vpn is aliased to `sudo openconnect vpn.uantwerpen.be'
</code></pre>
<p>cf. version managers</p>
</section>
<!--
<section>
<h4>How not do to it</h4>
<pre><code class="sh" data-trim data-noescape>
$ pip install redis
$ sudo apt install python2
$ bash ./install_conda.sh
$ conda install
$ R
$ install.packages
</code></pre>
<p>Learn how different methods of install work behind the scenes.</p>
SEE INSTALLATION MANAGEMENT PYTHON/R
</section> -->
<section>
<img width="60%" data-src="assets/bash-windows.jpg" alt="bash-windows">
</section>
<section style="font-size: 0.5em">
<p>Windows Command Prompt and Powershell are not the same as a Unix-shell, although they have their
uses.</p>
<p>Install the Windows Subsystem for Linux on W10 <a
href="https://docs.microsoft.com/en-us/windows/wsl/install-win10">https://docs.microsoft.com/en-us/windows/wsl/install-win10</a>,
rather than running a virtual machine (for most scenarios).</p>
<p>Caveat: things like Python are <span class="emphasized">not automatically shared</span> between
Windows and the Subsystem.</p>
<p>Even GUI apps work if you install an X server!</p>
<p>Can even be linked to your IDE e.g. VS Code: <a
href="https://medium.com/@janelgbrandon/a-guide-for-using-wsl-for-development-d135670313a6">https://medium.com/@janelgbrandon/a-guide-for-using-wsl-for-development-d135670313a6</a>
& <a
href="https://code.visualstudio.com/docs/remote/wsl">https://code.visualstudio.com/docs/remote/wsl</a>
as if it's a remote server</p>
<p>For the full write-up, see the primer.</p>
<a
href="https://askubuntu.com/questions/1051525/windows-subsystem-for-linux-wsl-what-cant-i-do-with-the-ubuntu-application-f">https://askubuntu.com/questions/1051525/windows-subsystem-for-linux-wsl-what-cant-i-do-with-the-ubuntu-application-f</a>
</section>
<section>
<img width="60%" data-src="assets/exit-vim.jpeg" alt="bash-windows">
</section>
<section>
<h2>Learn how to exit vim</h2>
<code style="text-decoration: line-through;">Press the X button</code><br>
<span style="text-decoration: line-through;"><code>$ killall -9 vim</code></span><br>
<code data-noescape> <esc>:wq<enter></code><br>
<code>Shift-Z-Z</code>
<p style="font-size:0.6em"><a
href="https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/">https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/</a>
</p>
</section>
<section>
<h4>Learn (at least) a few Bash/PowerShell tools</h4>
<p><code>grep</code> (and by extension regular expressions) can help when your IDE decides to be an
idiot.</p>
<img class="stretch" data-src="assets/grep-ide.png" alt="ide-vs-grep">
</section>
<!-- counting lines
head or tail
checking columns
editing line-by-line sed
low memory editing vim -->
<section>
<h4>Spend some time on a bash primer</h4>
<pre>
<code class="sh" data-trim data-noescape>
$ rsync --help | grep "-z"
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
$ rsync -h | grep "\-z"
-z, --compress compress file data during the transfer
$ rsync -h | grep '\-z'
-z, --compress compress file data during the transfer
$ rsync --help | grep -- -z
-z, --compress compress file data during the transfer
</code>
</pre>
</section>
<section>
<h4>Things worth your time</h4>
<ul style="font-size: 0.7em">
<li>File permissions: <a
href="https://linuxjourney.com/lesson/file-permissions">https://linuxjourney.com/lesson/file-permissions</a>
</li>
<li>File redirection: <a
href="https://catonmat.net/bash-one-liners-explained-part-three">https://catonmat.net/bash-one-liners-explained-part-three</a>
e.g. <code>foo >outfile1 2>&1 >outfile2</code> (<a
href="https://stackoverflow.com/questions/818255/in-the-shell-what-does-21-mean">see
SO</a>)</li>
<li>Regular expressions and <code>grep / sed / awk</code>: <a
href="https://regexone.com/">https://regexone.com/</a></li>
<li><a href="https://mywiki.wooledge.org/BashGuide">https://mywiki.wooledge.org/BashGuide</a>
</li>
<li><a
href="https://mywiki.wooledge.org/BashPitfalls">https://mywiki.wooledge.org/BashPitfalls</a>
(even just number 1 is useful)</li>
<li><a
href="https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/">https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/</a>
</li>
</ul>
</section>
<!-- MENTION TEE? -->
<!-- counting lines
head or tail
checking columns
editing line-by-line sed
low memory editing vim -->
</section>
<!-- SSH TIPS -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e">
<h1>SSH tips 🔑 </h1>
</section>
<section>
<h4>Use <code>~/.ssh/config</code></h4>
<pre>
<code class="sh" data-trim data-noescape>
Host calcua
HostName login-leibniz.uantwerpen.be
#Port 22000
User vsc20380
IdentityFile ~/.ssh/id_rsa
</code>
</pre>
<pre>
<code class="sh" data-trim data-noescape>
$ ssh calcua
$ rsync -avhzP *.tar.gz calcua:/scratch/antwerpen/203/vsc20380/pmc/
</code>
</pre>
</section>
<section>
<h4>When working on a remote server over <span class="emphasized">SSH</span> (or <span
class="emphasized">PuTTY</span>), you can keep jobs alive after disconnecting:</h4>
<ul style="font-size: 0.8em">
<li class="fragment">After already starting a process: <code>^Z</code> followed by <code>bg
%1</code> and <code>disown (-h) %1</code></li>
<li class="fragment"><code>nohup bash my_amazing_script.sh > output.log 2>&1 &</code> (cf.
redirection)</li>
<li class="fragment"><code style="text-decoration: line-through">screen</code> /
<code>tmux</code></li>
</ul>
<span class="fragment">
<p>Process needs to be immune to SIGHUP.</p>
<ul style="font-size: 0.5em">
<li><a
href="https://serverfault.com/questions/311593/keeping-a-linux-process-running-after-i-logout">https://serverfault.com/questions/311593/keeping-a-linux-process-running-after-i-logout</a>
</li>
<li><a
href="https://unix.stackexchange.com/questions/3886/difference-between-nohup-disown-and">https://unix.stackexchange.com/questions/3886/difference-between-nohup-disown-and</a>
</li>
<li><a
href="https://unix.stackexchange.com/questions/484276/do-disown-h-and-nohup-work-effectively-the-same">https://unix.stackexchange.com/questions/484276/do-disown-h-and-nohup-work-effectively-the-same</a>
</li>
<li><a
href="https://unix.stackexchange.com/questions/57166/disown-wont-take-h-option">https://unix.stackexchange.com/questions/57166/disown-wont-take-h-option</a>
</li>
</ul>
</span>
</section>
<section style="font-size: 0.85em">
<p>If you cannot connect to a server using SSH keys (and <code>ssh -vvv</code> is cryptic), check
your <span class="emphasized">file permissions</span>.</p>
</br>
<ul>
<li>.ssh directory: 700 (<code>drwx------</code>)</li>
<li>public key (.pub file): 644 (<code>-rw-r--r--</code>)</li>
<li>private key (id_rsa): 600 (<code>-rw-------</code>)</li>
<li>home directory should not be writeable by the group or others, at most 755
(<code>drwxr-xr-x</code>)</li>
</ul>
</section>
<section>
<p>
Windows users: be aware than when you create <span class="emphasized">keys in WSL</span> the
keys won't automatically be picked up by other Windows programs (PuTTY, git GUIs, etc.)
</p>
</section>
</section>
<!-- PYTHON DEBUGGING -->
<section>
<section data-menu-title="Debugging">
<img class="stretch" data-src="assets/python-debug.jpg" alt="python-debug">
</section>
<!-- <section data-background-transition="zoom" data-background="#a6e22e"> -->
<section>
<h4>When you have more than a few <code>print()</code> statements in your Python code, it's time to
use a proper <span class="emphasized">debugger</span>.</h4>
<pre class="fragment"><code class="python" data-trim>
import pdb # or import ipdb as pdb
# insert this line where you want a breakpoint
pdb.set_trace()
</code></pre>
<p class="fragment">Or use a solution built into your IDE e.g. PyCharm.</p>
<br>
<ul class="fragment" style="font-size: 0.5em">
<li><a
href="https://realpython.com/python-debugging-pdb/">https://realpython.com/python-debugging-pdb/</a>
</li>
<li><a
href="https://github.com/spiside/pdb-tutorial">https://github.com/spiside/pdb-tutorial</a>
</li>
<li>Changing breakpoint statement: <a
href="https://www.andreagrandi.it/2018/10/16/using-ipdb-with-python-37-breakpoint/">https://www.andreagrandi.it/2018/10/16/using-ipdb-with-python-37-breakpoint/</a>
</li>
</ul>
</section>
<!-- R equivalents? -->
</section>
<!-- Managing python -->
<section>
<section data-menu-title="Managing Python">
<h2>Managing Python <i class="fab fa-python"></i></h2>
<img class="stretch" style="border: 0px" data-src="assets/python_environment.png" alt="python-hell">
</section>
<section>
<h3>Use <code>conda</code></h3>
<ul style="font-size: 0.8em">
<li class="fragment">Actually, use <code>miniconda</code> to avoid bloat.</li>
<li class="fragment">Lives side-by-side your system-wide Python install, but uses an alias to
become the default <code>which python</code></li>
<li class="fragment">Use <code>conda</code> <span class="emphasized">environments</span> to keep
projects and specific package versions separated and documented cf. version control.</li>
<li class="fragment">Use <code>virtualenv</code> when deploying code on a remote server or
docker container.</li>
</ul>
<p class="fragment" style="font-size: 0.6em">Check the documentation for a list of command commands:
creating/listing/exporting environments, installing/removing packages, etc. <a
href="https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html">https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html</a>
</p>
</section>
<section>
<h3><code>conda</code> and <code>pip</code> are separate things</h3>
<p class="fragment" style="font-size: 0.8em">Use <code>conda install</code> by default.</p>
<p class="fragment" style="font-size: 0.8em">If a package is missing, check out different channels
e.g. <code>conda install --channel forge</code> (bioconda is also nice).</p<>
<p class="fragment" style="font-size: 0.8em">If that fails, <span class="emphasized">first
install pip inside the conda environment</span>.</p>
<p class="fragment">cf. <a href="#/path">What is <code>PATH</code>?</a></p>
</section>
<section>
<h4>Never use <code>sudo conda/pip install</code>!</h4>
<p>You should always be able to install packages for just your user. This is more secure and ensures
all packages can see one another.</p>
</section>
<section>
<h4><code>pip</code> is not installed by default!</h4>
<pre><code class="sh" data-trim data-noescape>
$ conda create -n newenv python=3.7
......
$ which python
/home/pieter/miniconda3/envs/newenv/bin/python
$ which pip
/home/pieter/miniconda3/envs/newenv/bin/pip
$ conda create -n newerenv
......
$ conda activate newerenv
$ which python
/usr/bin/python
$ which pip
/home/pieter/miniconda3/envs/tools/bin/pip
# due to custom PATH append statement inside my .bashrc
</code></pre>
</section>
<section>
<h4>Install <code>nb_conda</code> for managing environments inside notebooks</h4>
<div style="font-size: 0.75em" class="fragment">
<img width="100%" data-src="assets/nb_conda.png" alt="nb_conda">
<p>Add <code>nb_conda</code> to whatever environment you want to launch Jupyter notebooks from
(I use the base environment).</p>
<p>Install <code>ipykernel / r-irkernel</code> into any environment you want to use inside
notebooks.</p>
</div>
</section>
<section>
<p>For <code>ruby</code> use <code><a href="https://github.com/rbenv/rbenv">rbenv</a></code>.</p>
<p>For <code>node.js</code> use <code><a href="https://github.com/creationix/nvm">nvm</a></code>.
</p>
</section>
<section>
<h4>Use <code>pathlib</code> to mange i/o.</h4>
<ul>
<li><a
href="https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/">https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/</a>
</li>
<li><a
href="https://pbpython.com/pathlib-intro.html">https://pbpython.com/pathlib-intro.html</a>
</li>
<li>
<a href="https://realpython.com/python-pathlib/">https://realpython.com/python-pathlib/</a>
</li>
</ul>
</section>
</section>
<!-- Managing R -->
<section data-menu-title="Managing R">
<section data-background-transition="zoom" data-background="#a6e22e" data-menu-title="Managing R">
<h1>Managing <i class="fab fa-r-project"></i></h1>
</section>
<section>
<ul>
<li>Use (RStudio) projects.</li>
<li class="fragment">Never use <code>setwd()!</code></li>
<li class="fragment"><span class="emphasized">Do</span> use the <code>here</code> package and create paths relative to the top
level of your project.</li>
<small>
<li class="fragment">See: <a
href="https://www.tidyverse.org/articles/2017/12/workflow-vs-script" />https://www.tidyverse.org/articles/2017/12/workflow-vs-script/</a>
<!-- https://stackoverflow.com/questions/53433955/relative-paths-in-r-how-to-avoid-my-computer-being-set-on-fire
https://whattheyforgot.org/project-oriented-workflow.html
http://plantarum.ca/code/setwd/
https://malco.io/2018/11/05/why-should-i-use-the-here-package/ -->
</li>
</small>
</ul>
<pre class="fragment">
<code class="r" data-trim data-noescape>
> here("data","raw","input.dat")
[1] "/home/pieter/projects/dot-project-directory/data/raw/input.dat"
</code>
</pre>
</section>
<section>
<p>Don't preserve your workspace, since previously stored variables can
silently mess up your results.</p>
<img width="45%"
data-src="assets/rstudio-workspace.png" alt="rstudio-workspace">
</section>
<section>
<h4>For package management, check out <code>renv</code>. <small>(or <code>packrat</code>)</small>
</h4>
<br>
<p class="fragment">Don't install packages via your system package manager, only use
<code>install.packages()</code>.</p>
<p class="fragment"><code>conda</code> can also manage R environments, but might not act nicely with
R_LIBS <small>(<a
href="https://waoverholt.com/conda-and-R/">https://waoverholt.com/conda-and-R/</a>)</small>
</p>
</section>
<section>
<code>renv</code>: if things go awry, install package into the base environment, purge the renv
files (`renv` dir, `renv.lock` and a line in `.RProfile`) and start over.
</section>
<section>
<p>
The default R installation directory might not be writeable for a user, so a user library should
be created (rather than installing packages as an admin).
</p>
<pre>
<code>
install.packages('random')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("random") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (y/n) y
Would you like to create a personal library
~/R/pc-linux-gnu-library/3.2
to install packages into? (y/n) y
</code>
</pre>
<p>You can also set this in a file:</p>
<pre>
<code>
echo R_LIBS_USER="~/lib/R/library" > .Renviron
</code>
</pre>
</section>
</section>
<!-- Notebooks -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e">
<h1>Use interactive coding notebooks responsibly 📓</h1>
</section>
<section>
<h4>Notebooks (Jupyter and R) are great for: </h4>
<ul>
<li class="fragment">Exploration</li>
<li class="fragment">Prototyping</li>
<li class="fragment">Sharing results, visualisation and adding remarks</li>
</ul>
</section>
<section>
<h4>But notebooks suffer from: </h4>
<ul>
<li class="fragment">Hidden states (<a
href="https://docs.google.com/presentation/d/1n2RlMdmv1p25Xy5thJUhkKGvjtV-dkAIsUXP-AL4ffI/edit#slide=id.g3a428e2eb8_0_223">see
example</a>)</li>
<li class="fragment">Out-of-order execution</li>
<li class="fragment">Horrible for sharing code</li>
</ul>
<br>
<p class="fragment">Use them appropriately, for <span class="emphasized">exploration, not
reproducing</span>.</p>
<p class="fragment">Write functions in separate files or create a local package (see primer).</p>
<br>
<ul class="fragment" style="font-size: 0.6em">
<li>Excellent talk by Joel Grus: <a
href="https://www.youtube.com/watch?v=7jiPeIFXb6U">https://www.youtube.com/watch?v=7jiPeIFXb6U</a>
</li>
<li>Thoughts of the amazing author of <code>knitr</code>: <a
href="https://yihui.name/en/2018/09/notebook-war/#summary">https://yihui.name/en/2018/09/notebook-war/#summary</a>
</li>
</ul>
</section>
<section data-transition="slide none">
<img width="100%" data-src="assets/notebook1.png">
</section>
<section data-transition="none side">
<img width="100%" data-src="assets/notebook2.png">
</section>
<section data-transition="none side">
<img width="100%" data-src="assets/notebook3.png">
</section>
<section>
<p>As a side note, everyone who uses Jupyter Notebooks should check out its successor JupyterLab and
Binder-like cloud solutions. <small>(<a
href="https://www.dataschool.io/cloud-services-for-jupyter-notebook/">https://www.dataschool.io/cloud-services-for-jupyter-notebook/</a>)</small>
</p>
</section>
</section>
<!-- unit testing -->
<section>
<section data-menu-title="Unit tests" style="font-size: 0.52em">
<pre><code style="max-height: 100%; max-width: 100%;" data-trim data-noescape>
,@@@@@@@@@@,,@@@@@@@% .#&@@@&&.,@@@@@@@@@@, %@@@@@@%* ,@@@% .#&@@@&&. *&@@@@&( ,@@@@@@@% %@@@@@, ,@@,
,@@, ,@@, ,@@/ ./. ,@@, %@% ,&@# .&@&@@( .@@/ ./. #@&. .,/ ,@@, %@% *&@&. ,@@,
,@@, ,@@&%%%%. .&@@/, ,@@, %@% ,&@# %@& /@@, .&@@/, (@@&%(*. ,@@&%%%%. %@% &@# ,@@,
,@@, ,@@/,,,, ./#&@@@( ,@@, %@@@@@@%* /@@, #@&. ./#&@@@( *(%&@@&. ,@@/,,,, %@% &@# .&&.
,@@, ,@@, ./, .&@# ,@@, %@% ,@@@@@@@@@% ./. .&@# /*. /@@. ,@@, %@% *&@&. ,,
,@@, ,@@@@@@@% .#&@@@@&/ ,@@, %@% .&@# ,@@/.#&@@@@&/ /%&@@@@. ,@@@@@@@% %@@@@@. ,@@,
,*************,,*/(((((//,,*(#%%%%%%%%%%%%%%%#(*,,,****************************************************,*/(((((((((/((((////****/((##%%%%%%
,*************,,//((((((//,,*(%%%%%%%%%%%%%%%%%##/*****************************************************,,*/(///(//////****//((##%%%%%%%%%%%
,************,,*/(((((((//***/#%%%%%%%%%%%%%%%%%%%#(/***************************************************,*//////////*//((#%%%%%%%%%%%%%%%%%
,***********,,*////////////***/##%%%%%%%%%%%%%%%%%%%##(*,***********************************************,,*////////(###%%%%%%%%%%%%%%%%%%%%
,**********,,,*/*******//////**/(#%%%%%%%%%%%%%%%%%%%%%#(/**********************************************,,,***/(##%%%%%%%%%%%%%%%%%%%%%%%%%
,*********,,,,*************///***/(#%%%%%%%%%%%%%%%%%%%%%%#(/***********************************,****,****/((#%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
,*********,,,***************//****/(##%%%%%%%%%%%%%%%%%%%%%%##//**************//////////////////////((#####%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(
,********,,,,***********************/(#%%%%%%%%%%%%%%%%%%%%%%%##################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##(/
,*******,..,***********************,,*/##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###((//
,*******,.,,***********************,,,,*(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##(//**//
,******,.,,,************************,,,,*/(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(//*******
,*****,,,,,********,***,,,,,,,,,,,,*,,,,,,*/(######%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##(/**********
,*****,..,*******,,,,,,,,,,,,,,,,,,,,,,*,,,,*///((#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###(/************
,*****,,,*******,,,,,*,,,,,,,,,,,,,,,,,****,,,*/(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#######(//**************
,****,.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,**,,,/(%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#((//******************
,***,..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..,,,,,,,*(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(/*******************
,**,,.,,,,,,,,,,,,,,,,,,,,,,,,,,.......,,,,,,/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#####%%%%%%%%%%%%%%%%#(/******************
,**,..,,,,,,,,,,,,,,,,,,,,,,,,,......,,,*,,,*(#%%%%%%%%##(((/(##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##(((/*/((#%%%%%%%%%%%%%%#(/*****************
,*,..,,,,,,,,,,,,,,,,,,,,,,,,,,,.....,,**,,*/#%%%%%%%##((((*,**/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%##((##/,,,*(#%%%%%%%%%%%%%%#(*****************
.*,.,,,**,,,,,,,,,,,,,,,,,,,,,,,,,,*****,,,/(%%%%%%%%#(//(#/,..*/#%%%%%%%%%%%%%%%%%%%%%%%%%%%#(//(#/,..,/(#%%%%%%%%%%%%%%#/*****///////////
.,..,,,,,,,,,,,,,,,,,,,,,,,,,,*,,*******,,,(#%%%%%%%%#(*,,,....,/#%%%%%%%%%%%%%%%%%%%%%%%%%%%#(*,,,....,/(#%%%%%%%%%%%%%%#(*,**////////////
.,..,,,,,,,,,...........,,,,,,*,********,,*(#%%%%%%%%%#(/*,,...,/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(/*,,..,*/##%%%%%%%%%%%%%%%#(***////////////
...,,,,,,,................,,*,**********,,/#%%%%%%%%%%%%#((////((#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##((///(#%%%%%%%%%%%%%%%%%%(/**////////////
..,,,,,,.................,,,**********,,*(#%%%%%%%%%%%%%%%%%%#%%%%%%%%#((///((#%%%%%%%%%%%%%%%%%%%%%#%%%%%%%%%%%%%%%%%%%%%#/**////////////
.,,,,,,,,.................,,***********,,/(####%%%%%%%%%%%%%%%%%%%%%%%%#(/*,,,*(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(/*////////////
.,***,,,,,,..............,,,**********,..,***//((##%%%%%%%%%%%%%%%%%%%%%%%##((##%%%%%%%%%%%%%%%%%%%%%%%%%##(((((((((###%%%%%#/**///////////
.*****,,,,,,,,,,,,,,,,,,,*************,..,*******/(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##///*//////((#%%%%%#(**///////////
.****************/******/***////*****,.,*///////**/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(////////////(#%%%%%#/**//////////
.***********************/////*******,..,*//////////(#%%%%%%%%%%%%%%%%%%%%##########%%%%%%%%%%%%%%%%%%%%#(///////////*/(#%%%%%#(***/////////
.************************///********,..,*//////////#%%%%%%%%%%%%%%%%%%#(//*****///(((##%%%%%%%%%%%%%%%%#(///////////**/##%%%%##/***////////
.***********************************,.,,***///////(#%%%%%%%%%%%%%%%%#(/*,,,*//((((////(#%%%%%%%%%%%%%%%#((////////////(#%%%%%%#(*********//
,***********,,,*,,*,,**************,,,*//******//(#%%%%%%%%%%%%%%%%%#(*,,*/(((#####(((((#%%%%%%%%%%%%%%%##///////////(#%%%%%%%%#(***///////
,*************,,**,,,************,,,,,/(##((((####%%%%%%%%%%%%%%%%%%%(/**/(((#((((#((//(#%%%%%%%%%%%%%%%%%#(((((((((##%%%%%%%%%%#/**///////
,******************************,,,,,,,*(#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#(**/((#(#(((#((//(#%%%%%%%%%%%%%%%%%%%%%%%#%#%%%%%%%%%%%%%#(**///////
,*************,**************,****,,,,,/(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(/*/((((#((((///(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%(/*///////
,*************************************,*/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##(////////////(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#/**/////*
,******////****///////////////////////***/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%####(((((((###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(********
.,*,****///////////////////////////////***/#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#(/*******
.,,,,*****//////////////////////////*******(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##(*******
.,,,,,,***********/////////////////********/(#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%(*******
</code></pre>
</section>
<section style="font-size: 0.8em">
<p>Try to incorporate unit testing into your workflow. </p>
<p class="fragment">Even something as simple as an <code>assert</code> statement checking the number
of columns after reading a .csv file goes a long way.</p>
<p class="fragment">For more information, check out this talk aimed specifically at data scientists
(as opposed to software engineers): <a
href="https://www.youtube.com/watch?v=0ysyWk-ox-8">https://www.youtube.com/watch?v=0ysyWk-ox-8</a>
</p>
</section>
</section>
<!-- dos2unix -->
<section data-menu-title="dos2unix">
<p>When sharing files between Windows and Unix systems, use the <code>dos2unix / unix2dos</code> command
to convert line breaks (<code>"\r\n" <=> "\n"</code>).</p>
</section>
<!-- Python / coding conventions
wout's talk
type hinting
etc.
+ project organization => cookie cutters => README for data or workflow managers-->
<!-- python environments
conda != pip
nb_conda for kernel switching -->
<section>
<section data-background-transition="zoom" data-background="#a6e22e"
data-menu-title="Project organization">
<h2>Structure your projects and your code</h2>
</section>
<section>
<p>Go through Wout's presentations and/or the primer.</p>
</section>
<section style="font-size: 0.8em">
<p>Add <span class="emphasized">docstrings</span> to your functions.</p>
<p class="fragment">Create <span class="emphasized">functions</span>.</p>
<p class="fragment">Be consistent in <span class="emphasized">code style</span> (cf. use a
formatter).</p>
<p class="fragment">Decide on a sane <span class="emphasized">project directory structure</span>.
<small>(e.g. <a
href="https://drivendata.github.io/cookiecutter-data-science/">https://drivendata.github.io/cookiecutter-data-science/</a>,
<a
href="https://community.rstudio.com/t/data-science-project-template-for-r/3230">https://community.rstudio.com/t/data-science-project-template-for-r/3230</a>,
<a
href="https://www.r-bloggers.com/structuring-r-projects/">https://www.r-bloggers.com/structuring-r-projects/</a>,
<a
href="https://nicercode.github.io/blog/2013-04-05-projects/">https://nicercode.github.io/blog/2013-04-05-projects/</a>)</small>
</p>
<p class="fragment">For all one-off commands, download sources and general meta-data, create <span
class="emphasized">READMEs</span> in the relevant directories.</p>
<p class="fragment">For repeated pipelines, use a workflow manager (<code>Make</code> is fine, but
more feature-rich variants exist). <small>(e.g. <code>snakemake</code> and
<code>nextflow</code>, discussion here: <a
href="https://www.biostars.org/p/258436/">https://www.biostars.org/p/258436/</a>)</small>
</p>
</section>
<section style="font-size: 0.8em">
<p>Python imports are weird.</p>
<p>My prefered approach is to use a locally installed package.</p>
<p>Store all your functions in a <code>src</code> directory and <code>pip install -e .</code> it
using a <code>setup.py</code> in the project root directory.
</p>
<p>More reading material on this:</p>
<ul style="font-size: 0.5em">
<li>https://dev.to/codemouse92/dead-simple-python-project-structure-and-imports-38c6</li>
<li>https://towardsdatascience.com/whats-init-for-me-d70a312da583</li>
<li>https://towardsdatascience.com/building-package-for-machine-learning-project-in-python-3fc16f541693
</li>
<li>https://realpython.com/absolute-vs-relative-python-imports/</li>
<li>https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html</li>
<li>https://alex.dzyoba.com/blog/python-import/</li>
<li>https://hackernoon.com/pip-install-abra-cadabra-or-python-packages-for-beginners-33a989834975
</li>
<li>https://stackoverflow.com/questions/22840671/what-is-the-difference-between-importing-python-sub-modules-from-numpy-matplotl
</li>
<li>https://stackoverflow.com/questions/16475129/clean-name-space-and-init-py</li>
<li>https://stackoverflow.com/questions/13093665/python-import-statement-semantics</li>
<li>https://stackoverflow.com/questions/19989179/modules-expose-imported-packages</li>
</ul>
</section>
</section>
<section>
<h1>Just use a password manager already</h1>
</section>
<section>
<h1>And Zotero for managing your literature</h1>
</section>
<section>
That's all folks.
</section>
<!-- safe rm https://old.reddit.com/r/linux/comments/c6dcbo/psa_the_rm_utility_accepts_flags_after_the_file/ -->
<!-- dtypes? -->
<!-- colordiff -->
<!-- <section>
<section>
<h1>My setup recommendations</h1>
</section>
<section>
vs studio screenshot
</section>
<section>
black formatter
</section>
<section>
rstudio editor
</section>
<section>
git command line
</section>
</section> -->