Skip to content

Instantly share code, notes, and snippets.

View thomaskelder's full-sized avatar

Thomas Kelder thomaskelder

View GitHub Profile
@thomaskelder
thomaskelder / wikipathways2gource.py
Created June 16, 2016 08:29
Small python script to create an input file for Gource (http://gource.io/) to visualize WikiPathways (http://www.wikipathways.org) edit histroy.
## Get pathway edit history from wikipathways.org and export as gource log file
## Run using:
## python wikipathways2gource.py wikipathways.log
## View in gourse using:
## gource -1280x720 -a 3 --seconds-per-day 0.01 --hide dirnames,filenames --user-filter MaintBot --key wikipathways.log
## Create video with gource using:
## gource -1280x720 -a 2 --seconds-per-day 0.005 --hide dirnames,filenames --user-filter MaintBot --key --stop-at-end -o - wikipathways.log | ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libvpx -b 10000K wikipathways.webm
## Known issues/shortcomings:
## - Pathway ontology terms can have multiple parents, this is ignored, only first is taken here to prevent pathways from showing multiple times in the visualization
@thomaskelder
thomaskelder / gist:7003350
Created October 16, 2013 06:18
load nutritech data from dbnp
## Fill out your own dbNP user / pass here
authenticate("****", "****", "****")
studies = getStudies()
studyName = "NutriTechHIS"
study = studies[[grep(studyName, sapply(studies, function(x) x$code))]]
studyToken = study['token']
## Test script to get NutriTech data from dbNP
## Crashes with:
## > source('~/projects/nutritech/code/dbnp.test.R')
## Clinical Chemistry
## Questionnaire Physical Activity
## Error in x$name : $ operator is invalid for atomic vectors
require(GSCFClient)
require(GSCFRUtils)
@thomaskelder
thomaskelder / gist:6006409
Created July 16, 2013 06:59
Illumina annotation
library(limma)
library(lumiMouseAll.db)
nu.ids = rownames(data) ## A list of lumi nuIDS
nu.annot = nuID2IlluminaID(nu.ids, lib.mapping = "lumiMouseIDMapping", idType = "All")
## Get entrez ids and gene names
geneNames = as.character(as.list(lumiMouseAllGENENAME)[nu.ids])
entrezIds = as.character(as.list(lumiMouseAllENTREZID)[nu.ids])
#############################
#### Apply functions ####
#############################
matrixData = matrix(1:40, nrow = 10, ncol = 4)
### Median of rows
## Using for loop
rowm = rep(NA, nrow(matrixData))
for(r in 1:nrow(matrixData)) {
rowm[r] = median(matrixData[r,])
@thomaskelder
thomaskelder / affy2entrez.R
Last active December 15, 2015 22:39
script to convert affy probes to entrez ids
## Only first time: install bioconductor package for your affy array
## Find the proper package here: http://www.bioconductor.org/packages/release/data/annotation/
source("http://bioconductor.org/biocLite.R")
biocLite("hgu95d.db")
## Load the affy annotation library
library(hgu95d.db)
ids = read.delim("omzetten ids.txt", as.is=T, header=T)