Skip to content

Instantly share code, notes, and snippets.

👨‍🔬
Researching 'em microbes...

Christian Diener cdiener

👨‍🔬
Researching 'em microbes...
Block or report user

Report or block cdiener

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cdiener
cdiener / topics.md
Last active Aug 29, 2015
Learning Topics
View topics.md

Learning List

Next topics to learn:

  • webservers
  • node.js
  • Django or Pyramid [maybe Jinja2+Tornado a better option for smaller projects]
  • Plone plugins [too complex, substituded by FormGen]
  • D3
  • Python testing frameworks
@cdiener
cdiener / points
Last active Aug 29, 2015
ggplot2 grouped points with horizontal means
View points
library(scales)
library(Hmisc)
emsa_plot = ggplot(emsa, aes(x=Name, y=intensity, shape=charge_ratio, col=charge_ratio, width=0.8)) +
geom_point(size=3, position=position_dodge(width=0.8)) +
stat_summary(fun.data=mean_sdl, mult=0, color="black", geom="errorbar", size=1, position=position_dodge(width=0.8)) +
scale_color_grey(start=0, end=0.5,name="charge ratio") +
scale_shape(name="charge ratio") +
scale_y_continuous(limits=c(-0.05,1), breaks=seq(0,1,by=0.2), label=percent) +
@cdiener
cdiener / cache.R
Last active Aug 29, 2015
cache operator for R
View cache.R
# Caching operator executes command if there is no saved version of the data
# just delete the saved file and code will be run again
'%c%' = function(ex, file) if(file.exists(file), env=parent.frame(4)) load(file) else evalq(ex))
# Example
# first execution
{ x <- rnorm(1e6); save(x, file="cache.Rd") } %c% "cache.Rd" # executes the sampling
@cdiener
cdiener / eset_reduce.R
Last active Feb 3, 2016
ExpressionSet reducer - allows you to reduce the features of an expression set from an nxn grouping, for instance probesets to genes/transcripts etc.
View eset_reduce.R
Rcpp::sourceCpp("matrix_reduce.cpp")
#' Reduces an ExpressionSet by an n-to-n map of features to groups. All entries
#' in \code{features} must exist in \code{eset}. \code{features} and
#' \code{groups} must have the same length.
#'
#' @param eset An ExpressionSet object.
#' @param features A character vector of features to be grouped.
#' @param groups A factor or character vector mapping the entries in
#' \code{features} to groups.
View bug245.py
#/usr/bin/env python
from cobra.test import create_test_model
from cobra.flux_analysis import single_gene_deletion
cobra_model = create_test_model("textbook")
dels = {"b0008": 0.87, "b0114": 0.71, "b0116": 0.56, "b2276": 0.11, "b1779": 0.00}
rates, statuses = single_gene_deletion(cobra_model, gene_list=dels.keys(),
method="moma", solver="mosek")
@cdiener
cdiener / enrichment.R
Created May 4, 2016
Small GSEA implementation
View enrichment.R
ES <- function(p, w, pws, both=FALSE) {
n <- length(pws)
nr <- sum(abs(w[pws == p]))
nh <- sum(pws == p)
scores <- vector(length=n)
scores[pws == p] <- abs(w[pws == p])/nr
scores[pws != p] <- -1/(n - nh)
r <- range(cumsum(scores))
i <- which.max(abs(r))
@cdiener
cdiener / compare.py
Last active Mar 6, 2017
Compare pytest benchmarks
View compare.py
import json
import pandas as pd
from sys import argv, exit
def benchmark_to_df(json_file):
with open(json_file) as jf:
content = json.load(jf)
df = pd.DataFrame(columns=("test", "time [ms]"))
for b in content["benchmarks"]:
@cdiener
cdiener / settings.json
Created Jun 16, 2017
My vscode settings....
View settings.json
{
"workbench.colorTheme": "Sublime Material Theme - Dark",
"workbench.iconTheme": "material-icon-theme",
"editor.fontFamily": "'Fira Mono', monospace",
"editor.fontSize": 17,
"editor.rulers": [80],
"window.zoomLevel": 0,
"window.menuBarVisibility": "toggle",
// Settings for Python
@cdiener
cdiener / orlitsky.R
Created Sep 1, 2017
Source code for my blog post
View orlitsky.R
library(data.table)
library(ggplot2)
library(magrittr)
library(pbapply)
large <- fread("ERR260132_genes.csv")
#' Sample a rarefied version of a count vector.
#'
#' @param x A named vector of counts.
@cdiener
cdiener / install.md
Last active Nov 9, 2017
Como instalar docker para la clase de Desafio LatAm.
View install.md

Instalación de Docker

Lo primero que tienes que saber sobre la instalación de docker es que para Mac y windows hay dos versiones de docker:

  1. una versión legacy que usa maquinas virtuales (VM) para correr docker adentro de una maquina virtual.
  2. una versión nativa que usa una capa de compatibilidad (HyperKit + Hypervisor en Mac y Hyper-V en Windows) para correr docker directamente con el kernel nativo

La versión nativa (opción 2) tiene menos overhead y corre más rapido pero pone mas restricciones a su OS. Por el momento yo recomiendo que usan esta versión en Mac y Linux y la version legacy (opcion 1) en Windows.

You can’t perform that action at this time.