From 8b2d310ca11c56d2514fb8d719edeb2a1cecc475 Mon Sep 17 00:00:00 2001
From: thomasyu888 Docker
Bruce Hoff
- 2023-02-01
+ 2023-09-09
Source: vignettes/docker.Rmd
docker.Rmd
Manage Synapse Credentials
KimYen
Ladia
- 2023-02-01
+ 2023-09-09
Source: vignettes/manageSynapseCredentials.Rmd
manageSynapseCredentials.Rmd
Synapse R Client Overview
Bruce Hoff
- 2023-02-01
+ 2023-09-09
Source: vignettes/synapser.Rmd
synapser.Rmd
Accessing DataView the entity’s metadata in the R console:
print(fileEntity)
-## File(parentId='syn51038312', path='/var/folders/zl/j6z0kpys2gl7pwc1x63w0gwr001lqt/T/RtmpG52o0s/file156f930cb36ad', name='file156f930cb36ad', files=['file156f930cb36ad'], cacheDir='/var/folders/zl/j6z0kpys2gl7pwc1x63w0gwr001lqt/T/RtmpG52o0s', etag='c22c30c1-ccb7-493b-a665-e5edeefa6fe1', concreteType='org.sagebionetworks.repo.model.FileEntity', createdOn='2023-02-02T02:15:24.818Z', dataFileHandleId='121216962', versionNumber=1, createdBy='3324230', modifiedOn='2023-02-02T02:15:24.974Z', modifiedBy='3324230', versionLabel='1', _file_handle={'id': '121216962', 'etag': 'db05364c-205e-460f-a79c-a679ca016da6', 'createdBy': '3324230', 'createdOn': '2023-02-02T02:15:25.000Z', 'modifiedOn': '2023-02-02T02:15:25.000Z', 'concreteType': 'org.sagebionetworks.repo.model.file.S3FileHandle', 'contentType': 'application/octet-stream', 'contentMd5': '8465d33d9f407ef250ce519e92f300fb', 'fileName': 'file156f930cb36ad', 'storageLocationId': 1, 'contentSize': 23, 'status': 'AVAILABLE', 'bucketName': 'proddata.sagebase.org', 'key': '3324230/1c78e027-8a1a-49fc-832e-b927417b9e1f/file156f930cb36ad', 'isPreview': False, 'externalURL': None}, isLatestVersion=True, id='syn51038314', synapseStore=True)
This is one simple way to read in a small matrix (we load just the first few rows):
@@ -286,7 +286,7 @@Organizing Data in a Project## [1] "Data" ## ## [[1]]$id -## [1] "syn51038316" +## [1] "syn52417365" ## ## [[1]]$type ## [1] "org.sagebionetworks.repo.model.Folder" @@ -301,13 +301,13 @@
Organizing Data in a Project## [1] TRUE ## ## [[1]]$benefactorId -## [1] 51038312 +## [1] 52417363 ## ## [[1]]$createdOn -## [1] "2023-02-02T02:15:25.912Z" +## [1] "2023-09-10T01:52:05.690Z" ## ## [[1]]$modifiedOn -## [1] "2023-02-02T02:15:26.070Z" +## [1] "2023-09-10T01:52:05.840Z" ## ## [[1]]$createdBy ## [1] "3324230" @@ -318,10 +318,10 @@
Organizing Data in a Project## ## [[2]] ## [[2]]$name -## [1] "file156f930cb36ad" +## [1] "file335b64fd60c" ## ## [[2]]$id -## [1] "syn51038314" +## [1] "syn52417364" ## ## [[2]]$type ## [1] "org.sagebionetworks.repo.model.FileEntity" @@ -336,13 +336,13 @@
Organizing Data in a Project## [1] TRUE ## ## [[2]]$benefactorId -## [1] 51038312 +## [1] 52417363 ## ## [[2]]$createdOn -## [1] "2023-02-02T02:15:24.818Z" +## [1] "2023-09-10T01:52:04.003Z" ## ## [[2]]$modifiedOn -## [1] "2023-02-02T02:15:24.974Z" +## [1] "2023-09-10T01:52:04.176Z" ## ## [[2]]$createdBy ## [1] "3324230" @@ -358,7 +358,7 @@
Organizing Data in a Project## [1] "Data" ## ## [[1]]$id -## [1] "syn51038316" +## [1] "syn52417365" ## ## [[1]]$type ## [1] "org.sagebionetworks.repo.model.Folder" @@ -373,13 +373,13 @@
Organizing Data in a Project## [1] TRUE ## ## [[1]]$benefactorId -## [1] 51038312 +## [1] 52417363 ## ## [[1]]$createdOn -## [1] "2023-02-02T02:15:25.912Z" +## [1] "2023-09-10T01:52:05.690Z" ## ## [[1]]$modifiedOn -## [1] "2023-02-02T02:15:26.070Z" +## [1] "2023-09-10T01:52:05.840Z" ## ## [[1]]$createdBy ## [1] "3324230" @@ -390,10 +390,10 @@
Organizing Data in a Project## ## [[2]] ## [[2]]$name -## [1] "file156f930cb36ad" +## [1] "file335b64fd60c" ## ## [[2]]$id -## [1] "syn51038314" +## [1] "syn52417364" ## ## [[2]]$type ## [1] "org.sagebionetworks.repo.model.FileEntity" @@ -408,13 +408,13 @@
Organizing Data in a Project## [1] TRUE ## ## [[2]]$benefactorId -## [1] 51038312 +## [1] 52417363 ## ## [[2]]$createdOn -## [1] "2023-02-02T02:15:24.818Z" +## [1] "2023-09-10T01:52:04.003Z" ## ## [[2]]$modifiedOn -## [1] "2023-02-02T02:15:24.974Z" +## [1] "2023-09-10T01:52:04.176Z" ## ## [[2]]$createdBy ## [1] "3324230" @@ -437,7 +437,7 @@
Organizing Data in a Project## [1] "Data" ## ## $id -## [1] "syn51038316" +## [1] "syn52417365" ## ## $type ## [1] "org.sagebionetworks.repo.model.Folder" @@ -452,13 +452,13 @@
Organizing Data in a Project## [1] TRUE ## ## $benefactorId -## [1] 51038312 +## [1] 52417363 ## ## $createdOn -## [1] "2023-02-02T02:15:25.912Z" +## [1] "2023-09-10T01:52:05.690Z" ## ## $modifiedOn -## [1] "2023-02-02T02:15:26.070Z" +## [1] "2023-09-10T01:52:05.840Z" ## ## $createdBy ## [1] "3324230" @@ -467,10 +467,10 @@
Organizing Data in a Project## [1] "3324230" ## ## $name -## [1] "file156f930cb36ad" +## [1] "file335b64fd60c" ## ## $id -## [1] "syn51038314" +## [1] "syn52417364" ## ## $type ## [1] "org.sagebionetworks.repo.model.FileEntity" @@ -485,13 +485,13 @@
Organizing Data in a Project## [1] TRUE ## ## $benefactorId -## [1] 51038312 +## [1] 52417363 ## ## $createdOn -## [1] "2023-02-02T02:15:24.818Z" +## [1] "2023-09-10T01:52:04.003Z" ## ## $modifiedOn -## [1] "2023-02-02T02:15:24.974Z" +## [1] "2023-09-10T01:52:04.176Z" ## ## $createdBy ## [1] "3324230" @@ -524,7 +524,7 @@
Organizing Data in a Project= TRUE ) ## Retrieving a deleted folder causes: Error in value[[3L]](cond): 404 Client Error: -## Entity syn51038316 is in trash can.
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 @@ -574,91 +574,6 @@
The core of the Synapser library is the python client. Reticulate is used to -translate R to Python and back.
-These are the documented conversions from R to Python: Reticulate -Type Conversions
-NA
values in R do not have a direct equivalent in
-Python. This has been a topic of great discussion. Synapser is not
-trying to solve this. NA
values in R are handled by
-Reticulate per the implementation defined in Reticulate.
When working with R and Reticulate, NA values in types tables are -converted by Reticulate depending on the data type.
-For numeric data types, NA values are converted to the corresponding
-R value NA_real_
. For integer data types, NA values are
-converted to NA_integer_
. For logical data types, NA values
-are converted to NA_logical_
. For character data types, NA
-values are converted to NA_character_
.
In addition, Reticulate also converts any values that cannot be
-coerced to the specified data type to NA_character_
.
Reticulate performs these conversions automatically.
-When Reticulate converts R objects to Python objects, the NA values
-in R types tables are converted to Python’s None
.
R’s NA
is a logical constant of length 1 which is used
-to represent the absence of a value. In Python, the equivalent of
-NA
is None
, which is a special constant used
-to indicate the absence of a value.
Reticulate automatically converts NA
values in R types
-tables to None
when converting R objects to Python. This
-ensures that the data types and values remain consistent between the two
-languages.
Examples:
-NA
s to Python
-True
, which convert back to TRUE
in R
-na_logical = NA
-class(na_logical)
-## [1] "logical"
-na_py <- reticulate::r_to_py(na_logical)
-na_py
-## True
-na_r <- reticulate::py_to_r(na_py)
-na_r
-## [1] TRUE
-na_logical = c(T, F, NA)
-class(na_logical)
-## [1] "logical"
-na_py <- reticulate::r_to_py(na_logical)
-na_py
-## [True, False, True]
-na_r <- reticulate::py_to_r(na_py)
-na_r
-## [1] TRUE FALSE TRUE
NA
s to Python strings,
-which convert back to characters in R
-na_char = c("T", "F", NA)
-class(na_char)
-## [1] "character"
-na_py <- reticulate::r_to_py(na_char)
-na_py
-## ['T', 'F', 'NA']
-na_r <- reticulate::py_to_r(na_py)
-na_r
-## [1] "T" "F" "NA"
NA
s to Python
-np.nan
, which convert back to NA
in RSynapse provides tools for tracking ‘provenance’, or the @@ -672,7 +587,7 @@
+@@ -205,29 +205,29 @@act <- Activity( name = "clustering", description = "whizzy clustering", @@ -682,18 +597,18 @@
Creating an activity object:
+act <- Activity(name = "clustering", description = "whizzy clustering") act$used(c("syn12345", "syn12346")) act$executed("syn4567")
The used and executed can reference entities in Synapse or URLs.
Entity examples:
-++act$used("syn12345") act$used(project) act$used(target = "syn12345", targetVersion = 2)
URL examples:
-@@ -174,7 +174,7 @@+@@ -703,7 +618,7 @@act$used("http://mydomain.com/my/awesome/data.RData") act$used(url = "http://mydomain.com/my/awesome/data.RData", name = "Awesome Data") act$used(url = "https://github.com/joe_hacker/code_repo", name = "Gnarly hacks", wasExecuted = TRUE)
Storing entities with provenance
The activity can be passed in when storing an Entity to set the Entity’s provenance:
-+We’ve now recorded that ‘project’ is the output of syn4567 applied to @@ -715,14 +630,14 @@
Recording data sourceThe 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: -
+project <- synStore( project, activityName = "data-r-us", activityDescription = "downloaded from data-r-us", used = "http://data-r-us.com/excellent/data.xyz")
For more information:
-@@ -741,7 +656,7 @@+?Activity ?synDeleteProvenance
Wikis folder, file, etc). Text and graphics can be composed in markdown and rendered in the web view of the object.
Creating a Wiki
-+## <synapseclient.table.CsvFileTable object at 0x10e2cece0>+project <- synGet(project$properties$id) content <- " # My Wiki Page @@ -760,7 +675,7 @@
Wikis attachments = list(filePath)) wiki <- synStore(wiki)
Updating a Wiki
-@@ -246,7 +246,7 @@+project <- synGet(project$properties$id) wiki <- synGetWiki(project) wiki.markdown <- " @@ -772,7 +687,7 @@
Wikis wiki <- synStore(wiki)
For more information:
-@@ -783,7 +698,7 @@+?Wiki ?synGetWiki
Evaluations
+eval <- Evaluation( name = sprintf("My unique evaluation created on %s", format(Sys.time(), "%a %b %d %H%M%OS4 %Y")), description = "testing", @@ -792,22 +707,22 @@
Evaluations= "This evaluation only accepts files.") eval <- synStore(eval)
Retrieving the created Evaluation:
-@@ -103,7 +103,7 @@+eval <- synGetEvaluation(eval$id) eval ## { -## "contentSource": "syn51038321", -## "createdOn": "2023-02-02T02:15:38.350Z", +## "contentSource": "syn52417370", +## "createdOn": "2023-09-10T01:52:19.778Z", ## "description": "testing", -## "etag": "ba59943c-7633-41b0-b1c7-cf395a2d2690", -## "id": "9615299", -## "name": "My unique evaluation created on Wed Feb 01 181538.1668 2023", +## "etag": "ab96e0c7-14f2-4ca8-bc6e-343d23e97f9e", +## "id": "9615409", +## "name": "My unique evaluation created on Sat Sep 09 185219.5925 2023", ## "ownerId": "3324230", ## "submissionInstructionsMessage": "This evaluation only accepts files.", ## "submissionReceiptMessage": "Thank you for your submission!" ## }
Submitting a file to an existing Evaluation:
-@@ -103,7 +103,7 @@+# first create a file to submit filePath <- tempfile() connection <- file(filePath) @@ -818,7 +733,7 @@
Evaluations# submit the created file submission <- synSubmit(eval, file)
List submissions:
-diff --git a/docs/articles/upload.html b/docs/articles/upload.html index 2405c00f..a6797d82 100644 --- a/docs/articles/upload.html +++ b/docs/articles/upload.html @@ -33,7 +33,7 @@+submissions <- synGetSubmissionBundles(eval) as.list(submissions) ## [[1]] @@ -826,73 +741,124 @@
Evaluations## { ## "contributors": [ ## { -## "createdOn": "2023-02-02T02:15:40.563Z", +## "createdOn": "2023-09-10T01:52:22.150Z", ## "principalId": "3324230" ## } ## ], -## "createdOn": "2023-02-02T02:15:40.563Z", -## "entityBundleJSON": "{\"entity\":{\"name\":\"file156f93dd15047\",\"id\":\"syn51038326\",\"etag\":\"144a593a-46fa-4cf9-80e7-a9eb272b462f\",\"createdOn\":\"2023-02-02T02:15:40.020Z\",\"modifiedOn\":\"2023-02-02T02:15:40.169Z\",\"createdBy\":\"3324230\",\"modifiedBy\":\"3324230\",\"parentId\":\"syn51038321\",\"concreteType\":\"org.sagebionetworks.repo.model.FileEntity\",\"versionNumber\":1,\"versionLabel\":\"1\",\"isLatestVersion\":true,\"dataFileHandleId\":\"121216980\"},\"entityType\":\"file\",\"annotations\":{\"id\":\"syn51038326\",\"etag\":\"00000000-0000-0000-0000-000000000000\",\"annotations\":{}},\"fileHandles\":[{\"id\":\"121216980\",\"etag\":\"ed105c86-869d-4acf-a84c-2adadb1d15b4\",\"createdBy\":\"3324230\",\"createdOn\":\"2023-02-02T02:15:40.000Z\",\"modifiedOn\":\"2023-02-02T02:15:40.000Z\",\"concreteType\":\"org.sagebionetworks.repo.model.file.S3FileHandle\",\"contentType\":\"application/octet-stream\",\"contentMd5\":\"3f466b7f85d184292a68cea1c4f7cfc2\",\"fileName\":\"file156f93dd15047\",\"storageLocationId\":1,\"contentSize\":27,\"status\":\"AVAILABLE\",\"bucketName\":\"proddata.sagebase.org\",\"key\":\"3324230/3e54a923-1a7a-426f-b298-40fd6b05fd5a/file156f93dd15047\",\"isPreview\":false}]}", -## "entityId": "syn51038326", -## "evaluationId": "9615299", -## "id": "9731868", -## "name": "file156f93dd15047", +## "createdOn": "2023-09-10T01:52:22.150Z", +## "entityBundleJSON": "{\"entity\":{\"name\":\"file335b1a36cede\",\"id\":\"syn52417371\",\"etag\":\"d842081b-7747-4d4d-908e-5ff7e1e903ce\",\"createdOn\":\"2023-09-10T01:52:21.570Z\",\"modifiedOn\":\"2023-09-10T01:52:21.734Z\",\"createdBy\":\"3324230\",\"modifiedBy\":\"3324230\",\"parentId\":\"syn52417370\",\"concreteType\":\"org.sagebionetworks.repo.model.FileEntity\",\"versionNumber\":1,\"versionLabel\":\"1\",\"isLatestVersion\":true,\"dataFileHandleId\":\"128470731\"},\"entityType\":\"file\",\"annotations\":{\"id\":\"syn52417371\",\"etag\":\"00000000-0000-0000-0000-000000000000\",\"annotations\":{}},\"fileHandles\":[{\"id\":\"128470731\",\"etag\":\"24c712b6-9809-468e-a4a1-f60d1a979b3a\",\"createdBy\":\"3324230\",\"createdOn\":\"2023-09-10T01:52:21.000Z\",\"modifiedOn\":\"2023-09-10T01:52:21.000Z\",\"concreteType\":\"org.sagebionetworks.repo.model.file.S3FileHandle\",\"contentType\":\"application/octet-stream\",\"contentMd5\":\"3f466b7f85d184292a68cea1c4f7cfc2\",\"fileName\":\"file335b1a36cede\",\"storageLocationId\":1,\"contentSize\":27,\"status\":\"AVAILABLE\",\"bucketName\":\"proddata.sagebase.org\",\"key\":\"3324230/5076c7be-528c-412f-8abd-aa8cd1477038/file335b1a36cede\",\"isPreview\":false}]}", +## "entityId": "syn52417371", +## "evaluationId": "9615409", +## "id": "9740517", +## "name": "file335b1a36cede", ## "userId": "3324230", ## "versionNumber": 1 ## } ## ## [[1]][[2]] ## { -## "entityId": "syn51038326", -## "etag": "0df85dea-16a7-41f1-8402-3ba8fc5df2d6", -## "id": "9731868", -## "modifiedOn": "2023-02-02T02:15:40.563Z", +## "entityId": "syn52417371", +## "etag": "c3b2103e-5a41-4863-b798-7a4077c82aad", +## "id": "9740517", +## "modifiedOn": "2023-09-10T01:52:22.150Z", ## "status": "RECEIVED", ## "statusVersion": 0, ## "submissionAnnotations": {}, ## "versionNumber": 1 ## }
Retrieving submission by id:
-+# Not evaluating this section because of SYNPY-235 submission <- synGetSubmission(submission$id) submission
Retrieving the submission status:
-++submissionStatus <- synGetSubmissionStatus(submission) submissionStatus ## { -## "entityId": "syn51038326", -## "etag": "0df85dea-16a7-41f1-8402-3ba8fc5df2d6", -## "id": "9731868", -## "modifiedOn": "2023-02-02T02:15:40.563Z", +## "entityId": "syn52417371", +## "etag": "c3b2103e-5a41-4863-b798-7a4077c82aad", +## "id": "9740517", +## "modifiedOn": "2023-09-10T01:52:22.150Z", ## "status": "RECEIVED", ## "statusVersion": 0, ## "submissionAnnotations": {}, ## "versionNumber": 1 ## }
To view the annotations:
-@@ -103,7 +103,7 @@+submissionStatus$submissionAnnotations ## {}
To update an annotation:
-diff --git a/docs/articles/troubleshooting.html b/docs/articles/troubleshooting.html index 7409bc0e..d08f03bf 100644 --- a/docs/articles/troubleshooting.html +++ b/docs/articles/troubleshooting.html @@ -33,7 +33,7 @@+Query an evaluation:
-++## [1] 1queryString <- sprintf("query=select * from evaluation_%s LIMIT %s OFFSET %s'", eval$id, 10, 0) synRestGET(paste("/evaluation/submission/query?", URLencode(queryString), sep = "")) ## $headers -## list() +## [1] "scopeId" "entityId" "userId" "createdOn" +## [5] "versionNumber" "modifiedOn" "submitterAlias" "cancelControl" +## [9] "submitterId" "teamId" "name" "cancelRequested" +## [13] "objectId" "status" "canCancel" ## ## $rows -## list() +## $rows[[1]] +## $rows[[1]]$values +## $rows[[1]]$values[[1]] +## [1] "9615409" +## +## $rows[[1]]$values[[2]] +## [1] "syn52417371" +## +## $rows[[1]]$values[[3]] +## [1] "3324230" +## +## $rows[[1]]$values[[4]] +## [1] "1694310742150" +## +## $rows[[1]]$values[[5]] +## [1] "1" +## +## $rows[[1]]$values[[6]] +## [1] "1694310742150" +## +## $rows[[1]]$values[[7]] +## NULL +## +## $rows[[1]]$values[[8]] +## [1] "{\"submissionId\":\"9740517\",\"userId\":\"3324230\",\"canCancel\":false,\"cancelRequested\":false}" +## +## $rows[[1]]$values[[9]] +## [1] "3324230" +## +## $rows[[1]]$values[[10]] +## NULL +## +## $rows[[1]]$values[[11]] +## [1] "file335b1a36cede" +## +## $rows[[1]]$values[[12]] +## [1] "false" +## +## $rows[[1]]$values[[13]] +## [1] "9740517" +## +## $rows[[1]]$values[[14]] +## [1] "RECEIVED" +## +## $rows[[1]]$values[[15]] +## [1] "false" +## +## +## ## ## $totalNumberOfResults -## [1] 0
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:
-+?synGetEvaluation ?synSubmit ?synGetSubmissionBundles @@ -906,22 +872,22 @@
Sharing Access to Content
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:
-++## [1] "CHANGE_SETTINGS" "MODERATE" "UPDATE" +## [4] "DOWNLOAD" "CHANGE_PERMISSIONS" "READ" +## [7] "CREATE" "DELETE"acl <- synSetPermissions(project, principalId = 273949, accessType = list("READ")) acl ## $id -## [1] "syn51038321" +## [1] "syn52417370" ## ## $creationDate -## [1] "2023-02-02T02:15:31.181Z" +## [1] "2023-09-10T01:52:11.933Z" ## ## $etag -## [1] "45bf1411-d081-4b88-a89c-7378d27f7ca7" +## [1] "6e48e9be-eb88-4ab9-b91b-271986469f72" ## ## $resourceAccess ## $resourceAccess[[1]] @@ -937,17 +903,17 @@
Sharing Access to Content## [1] 3324230 ## ## $resourceAccess[[2]]$accessType -## [1] "DELETE" "CHANGE_PERMISSIONS" "CREATE" -## [4] "MODERATE" "UPDATE" "DOWNLOAD" -## [7] "CHANGE_SETTINGS" "READ"
Now public can read:
-+-synGetPermissions(project, principalId = 273950) ## list()
+-?synGetPermissions ?synSetPermissions
@@ -962,7 +928,7 @@+synDelete(project) ## NULL
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.
-@@ -102,7 +102,7 @@+@@ -103,7 +103,7 @@?synRestGET ?synRestPOST ?synRestPUT diff --git a/docs/articles/systemDependencies.html b/docs/articles/systemDependencies.html index 2a199d33..a2294ade 100644 --- a/docs/articles/systemDependencies.html +++ b/docs/articles/systemDependencies.html @@ -33,7 +33,7 @@
System Dependencies
KimYen Ladia
-2023-02-01
+2023-09-09
Source:vignettes/systemDependencies.Rmd
diff --git a/docs/articles/tables.html b/docs/articles/tables.html index a69b933d..012e7d38 100644 --- a/docs/articles/tables.html +++ b/docs/articles/tables.html @@ -33,7 +33,7 @@systemDependencies.Rmd
Tables
Bruce Hoff
-2023-02-01
+2023-09-09
Source:vignettes/tables.Rmd
@@ -154,7 +154,7 @@tables.Rmd
Tables
+## Schema(concreteType='org.sagebionetworks.repo.model.table.TableEntity', parentId='syn52417372', columns_to_store=[{'name': 'Name', 'columnType': 'STRING', 'maximumSize': 30, 'defaultValue': '', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Chromosome', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Start', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'End', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Strand', 'columnType': 'STRING', 'maximumSize': 30, 'defaultValue': '', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'TranscriptionFactor', 'columnType': 'BOOLEAN', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Time', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}], name='My Favorite Genes', columnIds=[])table <- synBuildTable("My Favorite Genes", project, genes) table$schema -## Schema(concreteType='org.sagebionetworks.repo.model.table.TableEntity', columnIds=[], columns_to_store=[{'name': 'Name', 'columnType': 'STRING', 'maximumSize': 30, 'defaultValue': '', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Chromosome', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Start', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'End', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Strand', 'columnType': 'STRING', 'maximumSize': 30, 'defaultValue': '', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'TranscriptionFactor', 'columnType': 'BOOLEAN', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}, {'name': 'Time', 'columnType': 'INTEGER', 'concreteType': 'org.sagebionetworks.repo.model.table.ColumnModel'}], parentId='syn51038332', name='My Favorite Genes')
synBuildTable
creates a Table Schema based on the data and returns a Table object that can be stored in Synapse usingsynStore()
. To create a custom Table Schema, defines the @@ -186,7 +186,7 @@Tables
We now have a table populated with data. Let’s try to query:
+-results <- synTableQuery(sprintf("select * from %s where Chromosome='1' and Start < 41000 and End > 20000", tableId))
results <- synTableQuery(sprintf('select * from %s where Chromosome=1 and Start < 41000 and "End" > 20000', tableId))
synTableQuery()
downloads the data and saves it to a csv file at location:+## <synapseclient.table.CsvFileTable object at 0x125cdf430>@@ -225,7 +225,7 @@Changing Data= c(F, F), Time = as.POSIXlt(c("2070-01-12 03:53:12.169", "2018-05-03 12:03:33.464"), tz = "UTC", format = "%Y-%m-%d %H:%M:%OS")) synStore(Table(tableId, moreGenes)) -## <synapseclient.table.CsvFileTable object at 0x12babe740>
For example, let’s update the names of some of our favorite genes:
+## <synapseclient.table.CsvFileTable object at 0x125cdf580>@@ -367,14 +367,14 @@Notes on Dates and Timesdf <- as.data.frame(results) df$Time <- as.POSIXlt("2015-07-04 05:22", tz = "UTC", format = "%Y-%m-%d %H:%M") synStore(Table(tableId, moreGenes)) -## <synapseclient.table.CsvFileTable object at 0x12bb405b0>
Dates may also be submitted in timestamp milliseconds:
+## <synapseclient.table.CsvFileTable object at 0x125d5d2d0>results <- synTableQuery(sprintf("select * from %s where Name='zap'", tableId)) df <- as.data.frame(results) df$Time <- timestamp synStore(Table(tableId, moreGenes)) -## <synapseclient.table.CsvFileTable object at 0x12bb42140>
Note that using
POSIXlt
is strongly preferred overPOSIXct
, becausePOSIXct
does not store values with enough precision to reliably recover milliseconds. For more @@ -419,7 +419,7 @@Table Attached Files# get the filehandle ids fileHandleIds <- lapply(files, function(f) f$id) newData["covers"] <- fileHandleIds -## Warning in `[<-.data.frame`(`*tmp*`, "covers", value = list("121215793", : +## Warning in `[<-.data.frame`(`*tmp*`, "covers", value = list("128470754", : ## provided 4 variables to replace 1 variables newTable <- synStore(Table(newSchema$properties$id, newData))
Troubleshooting
KimYen Ladia
-2023-02-01
+2023-09-09
Source:vignettes/troubleshooting.Rmd
@@ -152,6 +152,91 @@troubleshooting.Rmd
Using Synapser with reticulateSynapse Python client through reticulate.
+Type Conversions +
+The core of the Synapser library is the python client. Reticulate is used to +translate R to Python and back.
+These are the documented conversions from R to Python: Reticulate +Type Conversions
++
NA
values in R do not have a direct equivalent in +Python. This has been a topic of great discussion. Synapser is not +trying to solve this.NA
values in R are handled by +Reticulate per the implementation defined in Reticulate.When working with R and Reticulate, NA values in types tables are +converted by Reticulate depending on the data type.
+For numeric data types, NA values are converted to the corresponding +R value
+NA_real_
. For integer data types, NA values are +converted toNA_integer_
. For logical data types, NA values +are converted toNA_logical_
. For character data types, NA +values are converted toNA_character_
.In addition, Reticulate also converts any values that cannot be +coerced to the specified data type to
+NA_character_
.Reticulate performs these conversions automatically.
+When Reticulate converts R objects to Python objects, the NA values +in R types tables are converted to Python’s
+None
.R’s
+NA
is a logical constant of length 1 which is used +to represent the absence of a value. In Python, the equivalent of +NA
isNone
, which is a special constant used +to indicate the absence of a value.Reticulate automatically converts
+NA
values in R types +tables toNone
when converting R objects to Python. This +ensures that the data types and values remain consistent between the two +languages.Examples:
++
+- Reticulate converts logical
+NA
s to Python +True
, which convert back toTRUE
in R++na_logical = NA +class(na_logical) +## [1] "logical" +na_py <- reticulate::r_to_py(na_logical) +na_py +## True +na_r <- reticulate::py_to_r(na_py) +na_r +## [1] TRUE
++na_logical = c(T, F, NA) +class(na_logical) +## [1] "logical" +na_py <- reticulate::r_to_py(na_logical) +na_py +## [True, False, True] +na_r <- reticulate::py_to_r(na_py) +na_r +## [1] TRUE FALSE TRUE
+
+- Reticulate converts character
+NA
s to Python strings, +which convert back to characters in R++na_char = c("T", "F", NA) +class(na_char) +## [1] "character" +na_py <- reticulate::r_to_py(na_char) +na_py +## ['T', 'F', 'NA'] +na_r <- reticulate::py_to_r(na_py) +na_r +## [1] "T" "F" "NA"
+
+ +- Reticulate converts numeric
+NA
s to Python +np.nan
, which convert back toNA
in RFile Upload
KimYen Ladia
-2023-02-01
+2023-09-09
Source:vignettes/upload.Rmd
diff --git a/docs/articles/views.html b/docs/articles/views.html index f9bdd3ce..3d0fb484 100644 --- a/docs/articles/views.html +++ b/docs/articles/views.html @@ -33,7 +33,7 @@upload.Rmd
Views
KimYen Ladia
-2023-02-01
+2023-09-09
Source:vignettes/views.Rmd
@@ -200,26 +200,26 @@views.Rmd
Views data <- as.data.frame(queryResults) data ## ROW_ID ROW_VERSION ROW_ETAG id -## 1 51038357 1 31ff56cb-b476-4d8d-bb74-4a14d7ace68f syn51038357 -## 2 51038358 1 56d0f16e-e8ef-4293-9eb0-ba65001f0fdc syn51038358 -## name description createdOn createdBy -## 1 file1583932d4a572 NA 2023-02-01 18:17:17 3324230 -## 2 file1583926b9f970 NA 2023-02-01 18:17:19 3324230 +## 1 52417381 1 4b6521d7-f314-4c67-9a64-0ddef6b6ca26 syn52417381 +## 2 52417382 1 43a889f5-a890-4d8a-8472-d0b7f5b0dbae syn52417382 +## name description createdOn createdBy +## 1 file36303670318 NA 2023-09-09 18:54:16 3324230 +## 2 file36305ffc1e66 NA 2023-09-09 18:54:17 3324230 ## etag modifiedOn modifiedBy type -## 1 31ff56cb-b476-4d8d-bb74-4a14d7ace68f 2023-02-01 18:17:19 3324230 file -## 2 56d0f16e-e8ef-4293-9eb0-ba65001f0fdc 2023-02-01 18:17:20 3324230 file +## 1 4b6521d7-f314-4c67-9a64-0ddef6b6ca26 2023-09-09 18:54:18 3324230 file +## 2 43a889f5-a890-4d8a-8472-d0b7f5b0dbae 2023-09-09 18:54:18 3324230 file ## currentVersion parentId benefactorId projectId dataFileHandleId -## 1 1 syn51038356 syn51038356 syn51038356 121217064 -## 2 1 syn51038356 syn51038356 syn51038356 121217065 +## 1 1 syn52417380 syn52417380 syn52417380 128470769 +## 2 1 syn52417380 syn52417380 syn52417380 128470770 ## dataFileSizeBytes dataFileMD5Hex ## 1 37 47dfe7f5eaa49a5413c7b79b67ab9c43 ## 2 38 ba01e01b9e3ffea3ebef95efa62998b0 ## dataFileConcreteType dataFileBucket ## 1 org.sagebionetworks.repo.model.file.S3FileHandle proddata.sagebase.org ## 2 org.sagebionetworks.repo.model.file.S3FileHandle proddata.sagebase.org -## dataFileKey contributor -## 1 3324230/094122c1-804d-4d5b-84dd-301746556a10/file1583932d4a572 Sage -## 2 3324230/600e1433-6618-43ae-8970-cfc24033608a/file1583926b9f970 UW +## dataFileKey contributor +## 1 3324230/1707f7f0-0fe1-40c1-a732-089576539347/file36303670318 Sage +## 2 3324230/868c18c3-a1a7-4dd2-8067-a8d20addc0d6/file36305ffc1e66 UW ## class rank ## 1 V NA ## 2 NA X
Updating Annotations using View
data$contributor[1] <- c("Sage Bionetworks") synStore(Table(view$properties$id, data[1,])) -## <synapseclient.table.CsvFileTable object at 0x1134a1270>
@@ -98,13 +98,13 @@Update View’s Content diff --git a/docs/authors.html b/docs/authors.html index daaac20b..dfe2cda3 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@
Citation
Hoff B (2023). synapser: R Language Bindings for Synapse API. -R package version 1.0.0, https://www.synapse.org. +R package version 1.1.0, https://www.synapse.org.
@Manual{, title = {synapser: R Language Bindings for Synapse API}, author = {Bruce Hoff}, year = {2023}, - note = {R package version 1.0.0}, + note = {R package version 1.1.0}, url = {https://www.synapse.org}, }diff --git a/docs/index.html b/docs/index.html index 48844361..88a8edc7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,7 +33,7 @@On Windows
python --version
@@ -185,17 +185,17 @@
Note
If it still shows the old version, you may restart your system. Or uninstall the old version from the control panel.On macOS
Both python 2x and 3x can stay installed in a MAC. Mac comes with python 2x version. To check the default python version in your MAC, open the terminal and type
-+python --version -python3 --version
If you don’t then go ahead and install it with the installer. Go the the python’s official site here.
Now restart the terminal and check again with both commands python —version
-+python3 --version
-
Or
use toinstall last version
+brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python
On Linux
Add the repository and update
-+sudo add-apt-repository ppa:deadsnakes/ppa -sudo apt-get update
Update the package list
-+apt-get update
Verify the updated Python packages list
-+apt list | grep python3.10
Install the Python 3.10 package using apt-get
-+sudo apt-get install python3.10
Add Python 3.8 & Python 3.10 to update-alternatives
-+sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 -sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
Update Python 3 for point to Python 3.10
-+sudo update-alternatives --config python3
NEWS.md
+