The synapser package provides an interface to Synapse, a collaborative workspace for reproducible data intensive research projects, providing support for:

  • integrated presentation of data, code and text
  • fine grained access control
  • provenance tracking

The synapser package lets you communicate with the Synapse platform to create collaborative data analysis projects and access data using the R programming language. Other Synapse clients exist for Python, Java, and the web browser.

If you’re just getting started with Synapse, have a look at the Getting Started guides for Synapse.

Good example projects are:


synapser is available as a ready-built package for Microsoft Windows and Mac OSX. For Linux systems, it is available to install from source. It can be installed or upgraded using the standard install.packages() command, adding the Sage Bionetworks R Archive Network (RAN) to the repository list, e.g.:

Alternatively, edit your ~/.Rprofile and configure your default repositories:

after which you may run install.packages without specifying the repositories:

Connecting to Synapse

To use Synapse, you’ll need to register for an account. The Synapse website can authenticate using a Google account, but you’ll need to take the extra step of creating a Synapse password to use the programmatic clients.

Once that’s done, you’ll be able to load the library and login:

synLogin('me@nowhere.com', 'secret')

You can also create a file .synapseConfig in your home directory containing login credentials:


after which you can log in without typing your credentials:

For more details see the native reference documentation:

Accessing Data

To make the example below print useful information, we prepare a file:

Synapse identifiers are used to refer to projects and data which are represented by entity objects. For example, the entity above represents a tab-delimited file containing a 2 by 3 matrix. Getting the entity retrieves an object that holds metadata describing the matrix, and also downloads the file to a local cache:

View the entity’s metadata in the R console:

This is one simple way to read in a small matrix (we load just the first few rows):

View the entity in the browser:


Download Location

By default the download location will always be in the Synapse cache. You can specify the downloadLocation parameter.

entity <- synGet("syn00123", downloadLocation="/path/to/folder")

For more details see the native reference documentation, e.g.:

Organizing Data in a Project

You can create your own projects and upload your own data sets. Synapse stores entities in a hierarchical or tree structure. Projects are at the top level and must be uniquely named:


Creating a folder:

dataFolder <- Folder('Data', parent=project)
dataFolder <- synStore(dataFolder)

Adding files to the project:

You can print the properties of an entity (such as the file we just created):

Most other properties are immutable, but you can change an entity’s name:

Update Synapse with the change:

You can list all children of an entity:

You can also filter by type:

You can avoid reading all children into memory at once by iterating through one at a time:

Content can be deleted:

Deletion of a project will also delete its contents, in this case the folder:

In addition to simple data storage, Synapse entities can be annotated with key/value metadata, described in markdown documents (wikis), and linked together in provenance graphs to create a reproducible record of a data analysis pipeline.

For more details see the native reference documentation, e.g.:

Annotating Synapse Entities

To add a new annotation to the ones currently defined for an entity:


Synapse provides tools for tracking ‘provenance’, or the transformation of raw data into processed results, by linking derived data objects to source data and the code used to perform the transformation.

The Activity object represents the source of a data set or the data processing steps used to produce it. Using W3C provenance ontology terms, a result is generated by a combination of data and code which are either used or executed.

Creating an activity object:

Here, syn1234 and syn1235 might be two types of measurements on a common set of samples. Some whizzy clustering code might be referred to by syn4567.

Alternatively, you can build an activity up piecemeal:

The used and executed can reference entities in Synapse or URLs.

Entity examples:

URL examples:

Storing entities with provenance

The activity can be passed in when storing an Entity to set the Entity’s provenance:

project <- synGet(project$properties$id)
project <- synStore(project, activity=act)

We’ve now recorded that ‘project’ is the output of syn4567 applied to the data stored in syn1234 and syn1235.

Recording data source

The synStore() has shortcuts for specifying the used and executed lists directly. For example, when storing a data entity, it’s a good idea to record its source:

For more information:


Tables can be built up by adding sets of rows that follow a user-defined schema and queried using a SQL-like syntax. Please visit the Table vignettes for more information.


Wiki pages can be attached to an Synapse entity (i.e. project, folder, file, etc). Text and graphics can be composed in markdown and rendered in the web view of the object.

Creating a Wiki

Updating a Wiki

For more information:


An Evaluation is a Synapse construct useful for building processing pipelines and for scoring predictive modeling and data analysis challenges.

Creating an Evaluation:

Retrieving the created Evaluation:

Submitting a file to an existing Evaluation:

List submissions:

submissions <- synGetSubmissionBundles(eval)
## [[1]]
## [[1]][[1]]
## {
##   "contributors": [
##     {
##       "createdOn": "2018-02-15T00:42:28.368Z",
##       "principalId": "1"
##     }
##   ],
##   "createdOn": "2018-02-15T00:42:28.368Z",
##   "entityBundleJSON": "{\"entity\":{\"name\":\"filedfaf78277cb0\",\"id\":\"syn9602737\",\"uri\":\"/services-repository-develop-SNAPSHOT/repo/v1/entity/syn9602737\",\"etag\":\"a5e612d0-97c5-42af-b2d8-1919ab5370c8\",\"createdOn\":\"2018-02-15T00:42:28.048Z\",\"modifiedOn\":\"2018-02-15T00:42:28.048Z\",\"createdBy\":\"1\",\"modifiedBy\":\"1\",\"annotations\":\"/services-repository-develop-SNAPSHOT/repo/v1/entity/syn9602737/annotations\",\"accessControlList\":\"/services-repository-develop-SNAPSHOT/repo/v1/entity/syn9602737/acl\",\"parentId\":\"syn9602736\",\"entityType\":\"org.sagebionetworks.repo.model.FileEntity\",\"concreteType\":\"org.sagebionetworks.repo.model.FileEntity\",\"versionNumber\":1,\"versionLabel\":\"1\",\"versionUrl\":\"/services-repository-develop-SNAPSHOT/repo/v1/entity/syn9602737/version/1\",\"versions\":\"/services-repository-develop-SNAPSHOT/repo/v1/entity/syn9602737/version\",\"dataFileHandleId\":\"334\"},\"entityType\":\"org.sagebionetworks.repo.model.FileEntity\",\"annotations\":{\"id\":\"syn9602737\",\"uri\":\"/entity/syn9602737/annotations\",\"etag\":\"00000000-0000-0000-0000-000000000000\",\"creationDate\":\"1518655348048\",\"stringAnnotations\":{},\"doubleAnnotations\":{},\"longAnnotations\":{},\"dateAnnotations\":{},\"blobAnnotations\":{}},\"fileHandles\":[{\"id\":\"334\",\"etag\":\"293b6fde-1115-4621-899a-d2c098c8e5f2\",\"createdBy\":\"1\",\"createdOn\":\"2018-02-15T00:42:27.000Z\",\"concreteType\":\"org.sagebionetworks.repo.model.file.S3FileHandle\",\"contentType\":\"application/octet-stream\",\"contentMd5\":\"3f466b7f85d184292a68cea1c4f7cfc2\",\"fileName\":\"filedfaf78277cb0\",\"storageLocationId\":1,\"contentSize\":27,\"bucketName\":\"devdata.sagebase.org\",\"key\":\"1/bb46741b-5054-4fdc-84b8-7b7049605656/filedfaf78277cb0\"}]}",
##   "entityId": "syn9602737",
##   "evaluationId": "9602629",
##   "id": "9602639",
##   "name": "filedfaf78277cb0",
##   "userId": "1",
##   "versionNumber": 1
## }
## [[1]][[2]]
## {
##   "entityId": "syn9602737",
##   "etag": "b2faface-ba8a-4d00-a7e4-9a9aa4e5ddbf",
##   "id": "9602639",
##   "modifiedOn": "2018-02-15T00:42:28.368Z",
##   "status": "RECEIVED",
##   "statusVersion": 0,
##   "versionNumber": 1
## }

Retrieving submission by id:

Retrieving the submission status:

To view the annotations:

To update an annotation:

Query an evaluation:

To learn more about writing an evaluation query, please see: http://docs.synapse.org/rest/GET/evaluation/submission/query.html

For more information, please see:

Sharing Access to Content

By default, data sets in Synapse are private to your user account, but they can easily be shared with specific users, groups, or the public.

Retrieve the sharing setting on an entity:

synGetPermissions(project, principalId=273950)
## list()

The first time an entity is shared, an ACL object is created for that entity. Let’s make project public:

Now public can read:

synGetPermissions(project, principalId=273950)
## [[1]]
## [1] "READ"

File Views

A file view can be defined by its scope. It allows querying for FileEntity within the scope using a SQL-like syntax. Please visit the File View vignettes for more information.

Accessing the API Directly

These methods enable access to the Synapse REST(ish) API taking care of details like endpoints and authentication. See the REST API documentation.

Synapse Utilities


More information

For more information see the Synapse User Guide.