First Steps with Python in
Life Sciences
Wandrille Duchemin
Robin Engler
Orlin Topalov
Reproducibility crisis
Survey of 516 studies:
• - 17% data availability per year.
• Only 19% retrieval rate after 10 year...
Vines et al. (2014) Curr. Biol. [Link]/10.1016/[Link].2013.11.014
The FAIR guiding principles
Findable: Metadata and data should be easy to find for both humans and computers (unique global
identifier, rich description, machine readable and searchable).
Accessible: The data can be retrieved using a standard communication protocol (e.g. https or sftp).
Where needed, authentication and authorization procedures are available and documented.
Interoperable: the (meta)data should be based on standardized vocabulary and ontologies
(categories and their relations), so that it integrates with existing applications and workflows.
Reusable: Metadata and data should be well described so that data can be replicated and/or combined
in different research settings (rich metadata, clear license term, origin of data, data meets domain-
relevant community standards).
[Link], et al. The FAIR Guiding Principles for scientific data management and
stewardship. Sci Data. 2016;3:160018. doi:10.1038/sdata.2016.18. [Link]
FAIR applied to code
Don't do this
Do that
FAIR applied to code
• Write code that also acts as documentation, and clearly communicates the analysis.
• Apply the standard you would expect of a ‘wet-lab’ protocol.
• Will a reasonably competent colleague understand your code ?
• Will you understand your code in 6 month ??
To achieve this, you should:
• Comment as much as needed.
• Use explicit names when naming things (variables, functions, classes).
• Possibly use a support that allows to easily mix code and text, e.g. Jupyter notebook or Jupyter-lab.
• Also, you can look at:
• Schwen LO, Rueschenbaum S (2018) Ten quick tips for getting the most scientific value out of numerical
data. PLoS Comput Biol 14(10): e1006141. [Link]
Different ways o
executing
python code
How to execute python code
Three main modes of interaction:
• Interactive console
• Python code file (.py files)
• Jupyter Notebook (.ipynb files)
How to execute python code
Three main modes of interaction:
• Interactive console
• Nice for quick debugging, testing syntax, ...
• Python code file (.py files)
• Jupyter Notebook (.ipynb files)
How to execute python code
Three main modes of interaction:
• Interactive console
• Python code file (.py files)
• Scripts, programs, …
• Most used form
• Jupyter Notebook (.ipynb files)
How to execute python code
Three main modes of interaction:
• Interactive console
• Python code file (.py files)
• Jupyter Notebook (.ipynb files)
• Great for data analysis and teaching
Python – using the console
• The code is executed as you press 'Enter'
• Great for: quickly testing things out
• But, you keep no trace of your workflow/environment
Only use it to test little bits of code
Python – writing code in a .py file
• Write a script in a .py text file, then
execute it.
• Main way python code is shared.
• Ideal for standalone programs and
modules.
• Code and results are kept separate (may
be a good or a bad thing).
Good for general purpose coding, “operational script”.
Jupyter notebook / jupyterlab
• Browser based interface (but runs locally on your
machine).
• Interlace Markdown and code ‘cells’.
• Execute code cell by cell.
• Commentary, code, and results together in the
same file.
• Visually pleasant and fairly ergonomic.
Helps data analysis thank to Literate Programming