This use case will combine concepts from Annotating Data With Metadata, Views, Uploading and Organizing Data Into Projects, Files, and Folders. You will learn how to:
Create a manifest
Upload 100 files
Edit annotations on these files using the Synapse programmatic clients
The Sage Bionetworks maintains annotation dictionaries in GitHub. You can use the terms in this repository as a starting point, or you can create your own annotation dictionary.
Batch Upload Files with Annotations
To batch upload files, create a tab-delimited manifest which contains, at minimum, the columns
parent. You can also add additional annotations as columns in your manifest. For example, your manifest might have the following headers:
path: the local path to your file
parent: the Synapse ID (in the format syn123456) of the folder or project where your files will be uploaded
specimenID: the unique identifier for each of your specimens
assay: the technology used to generate the data in this file (for example, RNASeq, ChIPSeq, wholeGenomeSeq)
species: the species of your sample (for example, Mouse, Rat, Human, Triceratops)
platform: the hardware used to generate the data (for example, HiSeq2500, Affy6.0, HoodDNASequencer)
sex: a label assigned at birth based on biological attributes (for example, male or female)
fileFormat: is the type of file (e.g. fastq, R script)
Save this file in a tab-delimited format called
Files can be uploaded all at once with a manifest file. If you would like to do a “dry run” validation of the file before uploading, you can add the parameter
dryRun = True to the function
syncToSynapse. Note that the
dryRun feature checks everything, but does not upload the files.
validate the manifest and upload files in the Python client.
validate the manifest and upload files in the R client.
Create a File View (web)
Once the files have been uploaded with annotations, you can use a file view to query, facet, and bulk manipulate the files and metadata.
To create your file view:
Navigate to your project.
Go to the tables tab, select Tables Tools in the upper right corner, and click Add File View.
In the resulting pop-up, give the new file view a name.
Select the container (Synapse project or folder) of files, and click Next. In this case, you would want the synID of the
parentcolumn in the manifest.
Select the columns you would like to keep. Since we are going to edit the annotations later, make sure you have the column
etaglisted as one of your columns.
Add All Annotations at the end of the opened window will add all existing annotations.
Click Finish to create the file view.
For more information on file views, see Views.
Perform a One-Time Annotation Update or Deletion (web)
An annotation for a single file can be modified in the web client view. For example, you can update
From your view, select the pencil icon to edit query results.
In the pop-up window, find the single value you want to change and edit the field.
Scroll down to the bottom and click Save to update the file view.
Perform a Bulk Annotation Update or Deletion
A bulk annotation update is required in the case that
Velociraptor mongoliensis should be modified to
Utahraptor ostrommaysorum in all 100 files.
To download the annotation values from the web client:
Navigate to the your file view.
Click the Download Options button to the right of the query bar of the file view.
Click Export Table to download the file view. Be sure to have
Include row metadata (Row ID and Row Version)selected when downloading.
Now that you have the file view downloaded, you can edit the values using your preferred tool (Python, R, Excel, or other).
With the changes saved, go back to the file view in your browser.
Click View Tools located at the upper right of the file view.
Select Upload Data to View from the dropdown.
Browse and choose the edited file.
Click Next to preview the uploaded file.
Click Update Table to update the file view and populate the changes to all the files in Synapse.
Alternatively, download the file view with the R or Python client, then: