-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from gf-dcc/feat/manage-sample-ids
Add prelim script
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Sample ID Management | ||
|
||
Collection of utility scripts that help with managing sample entities for the BEN Collaborative Project / Breast Atlas in Synapse. | ||
There is potential functionality for extracting ids, inferring linkage of existing sample entities with data files, etc., that may be more automated eventually. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
library(synapser) | ||
|
||
synapser::synLogin(authToken = Sys.getenv("SYNAPSE_AUTH_TOKEN")) | ||
|
||
# It is easiest to use a fileview to get all nested children in "Samples" | ||
SampleTracking <- "syn52225331" | ||
|
||
tb <- synapser::synTableQuery(glue::glue("select id from {SampleTracking}")) | ||
ids <- as.data.frame(tb)$id | ||
|
||
asPatientID <- function(s) regmatches(s, regexpr("[A-Z]+[0-9]?-?[0-9]+", s)) | ||
|
||
errors <- c() | ||
|
||
for(i in ids) { | ||
|
||
entity <- synapser::synGet(i, downloadFile = FALSE) | ||
pID <- asPatientID(entity$properties$name) | ||
entity$annotations$PatientID <- pID | ||
|
||
# For now, let's just use the entity name as sample name | ||
entity$annotations$SampleID <- entity$properties$name | ||
tryCatch(synapser::synStore(entity), error = function(e) { cat("Skipped ", i, "\n"); errors <- append(errors, i) }) | ||
} | ||
|
||
|
||
|