Skip to content

Instantly share code, notes, and snippets.

@brian-bot
brian-bot / nbaDraftChalk.R
Created July 20, 2016 21:08
calculation for the probability of the NBA Draft lottery going as 'chalk'
## NBA DRAFT ODDS - CHANCES OF 'CHALK'
chancesInOrder <- c(250, 199, 156, 119, 88, 63, 43, 28, 17, 11, 8, 7, 6, 5)
conditionalProb <- 1
for(i in 1:3){
conditionalProb <- conditionalProb*chancesInOrder[i]/sum(chancesInOrder[i:length(chancesInOrder)])
}
conditionalProb
# > conditionalProb
runAttractorInCRCSC <- function(projectId){
require(synapseClient)
thisFile <- "https://gist.github.com/brian-bot/3f2b74694f58404c93fd"
## PULL FROM THE LINK THAT WAS CREATED IN THE PROJECT AT AN EARLIER STAGE
findLink <- synapseQuery(paste('SELECT id, name FROM link WHERE benefactorId=="', projectId, '"'))
resolveLink <- synGet(findLink$link.id[findLink$link.name=="COAD.attractors.rnaseq.txt"][1])
## GET THE ATTRACTOR METAGENES FOR TCGA COAD FROM THE LINK
@brian-bot
brian-bot / copyWikis.R
Last active August 29, 2015 13:58
primitive function for copying Synapse Wiki content from one resource to another
#####
## FUNCTION FOR COPYING ALL SYNAPSE WIKI CONTENT (AND SUBPAGES) FROM ONE OWNER RESOURCE TO ANOTHER
## AUTHOR: BRIAN M. BOT
#####
## ARGUMENTS:
## oldOwnerId - the Synapse ID of the resource (e.g. Project) to copy the wiki content from
## newOwnerId - the Synapse ID of the resource (e.g. Project) to copy the wiki content to
#####
## VALUE:
## Silently returns the Wiki headers from the new owner
@brian-bot
brian-bot / synTable.R
Last active December 20, 2015 21:28
A function to render Synapse-specific markdown for table rendering
#####
## AUTHOR: BRIAN M. BOT
## ORGANIZATION: SAGE BIONETWORKS
##
## FUNCTION TO RENDER SYNAPSE-SPECIFIC MARKDOWN FOR TABLE RENDERING
#####
## PARAMETERS:
## x: an R object of class data.frame, matrix, or table
## row.names (=TRUE): whether or not to include row names in the table (if available)
## col.names (=TRUE): whether or not to include column names in the table (if available)
@brian-bot
brian-bot / knit2synapse.R
Last active November 23, 2020 18:37
A function to allow users to leverage knitr functionality when constructing Synapse wiki content.
#####
## AUTHOR: BRIAN M. BOT
## ORGANIZATION: SAGE BIONETWORKS
##
## ALLOW USERS TO LEVERAGE KNITR WHEN CONSTRUCTING SYNAPSE WIKI CONTENT
#####
## PARAMETERS:
## file: path to a local .Rmd file which to knit
## owner: a Synapse object which will own the resulting WikiPage (usually a Project, Folder, or File)
## parentWikiId (optional): if the resulting WikiPage is to be a subpage of another WikiPage, this is the id for the parent WikiPage (NOTE: owner is still required)