Skip to content

Instantly share code, notes, and snippets.

@agrueneberg
Created October 5, 2012 21:07
Show Gist options
  • Save agrueneberg/3842413 to your computer and use it in GitHub Desktop.
Save agrueneberg/3842413 to your computer and use it in GitHub Desktop.
UUIDs to Patient Barcodes
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)
})
@asnanizami
Copy link

I'm getting error while extracting mappings:
Error in fromJSON(resp) : unexpected character '<'

please help.

@Tyelcie
Copy link

Tyelcie commented Jul 23, 2017

I got the same problem, please help ~

@shirleydaidai
Copy link

same error here: unexpected character '<'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment