Document toolboxDocument toolbox

Provenance

Reproducible research is a fundamental responsibility of scientists, but the best practices for achieving it are not established in computational biology. The Synapse provenance system is one of many solutions you can use to make your work reproducible by you and others.

Overview of Synapse Provenance

Provenance is a concept describing the origin of something. In Synapse, it is used to describe the connections between the workflow steps used to create a particular file or set of results. Data analysis often involves multiple steps to go from a raw data file to a finished analysis. Synapse’s provenance tools allow users to keep track of each step involved in an analysis and share those steps with other users.

The model Synapse uses for provenance is based on the W3C provenance spec where items are derived from an activity which has components that were used and components that were executed. Think of the used items as input files and executed items as software or code. Both used and executed items can reside in Synapse or in URLs such as a link to a GitHub commit or a link to a specific version of a software tool.

You can use the command line, Python, and R to create and edit provenance relationships. In the web client, you can add provenance relationships once the file has been uploaded.

Below is a Synapse visualization of provenance relationships that was created with the example in this guide using our programmatic and web clients. In this example, we have two scripts, one that generates random numbers and another that takes a list of numbers and computes their squares. The project’s workflow resembles the provenance relationships.

 

Setting Provenance when Uploading a File

Let’s begin with a script that generates a list of normally distributed random numbers and saves the output to a file. For example, you have an R script file called generate_random_data.R and you’ve saved the output to a data file called random_numbers.txt. We’ll begin by uploading the files to Synapse and then set their provenance.

Upload a File and Add Provenance

For this example, we’ll use a project that already exists (Wondrous Research Example : syn1901847). The code file is saved in Synapse with synID syn7205215, so we’ll upload the data file to this project, or in Synapse terminology, the project will be the parent of the new entities.

As the random_numbers.txt file was generated from the above script, we are going to specify this using provenance.

There are a couple ways to set provenance information for a Synapse entity. The used and executed arguments specify resources used and code executed in the process of creating the entity. Code can be stored in Synapse (as we did in the previous step) or, better yet, linked by URL to a source code versioning system like GitHub or SVN. As an example, we’ll specify two somewhat contrived sources of provenance:

  1. Synapse entity by synID: syn7205215 (the code file)

  2. URL to a page describing normal distributions

Web

The web client does not support setting provenance when uploading a file. Instead, upload the file first, then navigate to the file in your project. Click on the File Tools dropdown in the upper right hand corner and select Edit File Provenance. In the resulting pop-up, enter the relevant information. If you are entering an external URL as a reference, include the full URL path. In this example, you would enter http://mathworld.wolfram.com/NormalDistribution.html.

Command Line

synapse add random_numbers.txt --parentId syn1901847 --executed syn7205215 --used http://mathworld.wolfram.com/NormalDistribution.html

Alternatively in the command line client, if you have downloaded the file, you can specify a local path as such:

synapse add random_numbers.txt --parentId syn1901847 --executed ./generate_random_data.R --used http://mathworld.wolfram.com/NormalDistribution.html

Python

# Set provenance for data file generated by the script file data_file = File(path="random_numbers.txt", parent="syn1901847") data_file = syn.store(data_file, executed="syn7205215", used="http://mathworld.wolfram.com/NormalDistribution.html")

R

Once the data file is uploaded, Synapse will provide the synID assigned to that file. In this case, the synID is syn7208917.

Editing Provenance

To continue our example above, we’ll now add some new results from our initial data file. We’re going to take the results in random_numbers.txt and square them. The script to square the numbers will be square.R, and we’ll save the output to a data file, squares.txt. As with the previous example, the code file is already saved in Synapse, so we’ll upload the data file and set its provenance.

Web

To update the provenance on a file, navigate to the File that you would like to update. Click on the File Tools dropdown in the upper right hand corner and select Edit File Provenance. In the resulting pop-up, enter the relevant information.

Command Line

Python

R

Deleting Provenance

To delete a provenance relationship, you must be the person who created the entity.

Web

Navigate to the entity you would like to delete provenance from (e.g. a file or folder). In this example, we are deleting provenance from a file. Select File Tools, then Edit File Provenance. In the list of Used and Executed, click the minus symbol ( ) next to the URL or synID to delete each activity and Save your changes.

Command Line

Currently, deleting provenance is not supported in the command line client.

Python

R

Viewing Provenance

Web

Navigate to a file to view its provenance. Clicking on the triple dots above an entity will expand it to show the file's full provenance.

Command Line

Python

R

Reusing Provenance for Multiple Files

An activity is a Synapse object that helps to keep track of what objects were used in an analysis step, as well as what objects were generated. Thus, all relationships between Synapse objects and an activity are governed by dependencies. That is, an activity needs to know what it ‘used’, and outputs need to know what activity they were ‘generatedBy’. A couple of points for clarity:

  • An activity can ‘use’ many things (i.e. many inputs to an analysis)

  • Many outputs can be ‘generatedBy’ the same activity

If an activity isn’t assigned to an entity and then stored, a separate graph will be created for each file that the activity generated. The following example is used to assign the same activity to multiple files resulting in one provenance graph:

Web

Unfortunately, the web interface does not support assigning the same activity to multiple files. This action must be completed using either the R or the Python client.

Command Line

The command line currently does not support assigning the same activity to multiple files.

Python

R