Skip to content

Instantly share code, notes, and snippets.

@cbare
Created May 13, 2015 19:52
Show Gist options
  • Select an option

  • Save cbare/4c1382929aedea2d87b7 to your computer and use it in GitHub Desktop.

Select an option

Save cbare/4c1382929aedea2d87b7 to your computer and use it in GitHub Desktop.
Read the leaderboard information for the Prostate Cancer DREAM Challenge into a data.frame
library(plyr)
library(synapseClient)
synapseLogin('chris.bare')
## Q1a = 3317421, Q1b = 3317433, Q2 = 3317446
## https://www.synapse.org/#!Synapse:syn2762531/wiki/72477
## metrics in the query may need to change for different questions
eid = '3317421'
total = .Machine$integer.max
limit = 50
offset = 0
blocks = list()
i = 0
## read blocks of rows from Synapse
while (offset < total) {
fields = paste('objectId', 'status', 'createdOn', 'modifiedOn', 'team', 'name', 'cIndex', 'auc12', 'auc18', 'auc24', 'iAUC', sep=",+")
uri = sprintf("/evaluation/submission/query?query=select+%s+from+evaluation_%s+where+status==\"SCORED\"+limit+%d+offset+%d", fields, eid, limit, offset)
results <- synRestGET(uri)
## massage data into data.frames
m <- do.call(rbind, lapply(results$rows, function(row) { row$values }))
colnames(m) <- results$headers
df <- as.data.frame(m)
i <- i + 1
blocks[[i]] <- df
total <- results$totalNumberOfResults
offset <- offset + limit
}
## combine rows to a data.frame using plyr's rbind.fill
df <- rbind.fill(blocks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment