Created
October 5, 2012 21:07
-
-
Save agrueneberg/3842413 to your computer and use it in GitHub Desktop.
UUIDs to Patient Barcodes
This file contains hidden or 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
library(RCurl) | |
library(rjson) | |
# Read sample UUIDs. | |
uuids <- read.csv(file="~/uuids.csv") | |
# Convert to character vector. | |
uuids <- as.vector(t(uuids)) | |
# Query TCGA's UUID to barcode Web Service. | |
resp <- getURL("https://tcga-data.nci.nih.gov/uuid/uuidws/mapping/json/uuid/batch", customrequest="POST", httpheader=c("Content-Type: text/plain"), postfields=paste(uuids, collapse=",")) | |
# Extract mappings from response. | |
mappings <- fromJSON(resp)$uuidMapping | |
# Extract patient barcode from sample barcode. | |
mappings <- lapply(mappings, function (mapping) { | |
mapping$barcode <- substr(mapping$barcode, 0, 12) | |
return(mapping) | |
}) |
I got the same problem, please help ~
same error here: unexpected character '<'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting error while extracting mappings:
Error in fromJSON(resp) : unexpected character '<'
please help.