This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# type PrerankedProfile = Series(Index = Integer, Probe_ID = String, Rank = Integer) | |
# DataFrame -> List PrerankedProfile | |
def cmap2sortedseries(df): | |
return [series.order(ascending = True).reset_index() for series in df2series(df)] | |
# PrerankedProfile -> List a -> Float | |
def gsea_preranked(sorted_series, tag_list): | |
""" Apply KS test. | |
ex: scores = map(lambda profile: gsea_preranked(profile, up_probes), profiles) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Penrose where | |
import List exposing (foldr, map) | |
import Graphics.Collage exposing (..) | |
import Graphics.Element exposing (..) | |
import Color exposing (..) | |
goldenRatio = (1 + sqrt 5) / 2 | |
type alias Point = (Float, Float) | |
type Triangle | |
= Kite (Point, Point, Point) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Version info: R 2.14.1, Biobase 2.15.3, GEOquery 2.23.2, limma 3.10.1 | |
# R scripts generated Fri Jan 29 16:56:51 EST 2016 | |
################################################################ | |
# Differential expression analysis with limma | |
library(Biobase) | |
library(GEOquery) | |
library(limma) | |
# load series and platform data from GEO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Sequential | |
from keras.layers import Convolution2D, ZeroPadding2D, MaxPooling2D | |
img_width, img_height = 128, 128 | |
# this will contain our generated images | |
input_img = K.placeholder((1, 3, img_width, img_height)) | |
# build the VGG16 network with our input_img as input | |
first_layer = ZeroPadding2D((1, 1), input_shape=(3, img_width, img_height)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools as it | |
# Generator a -> Int -> List a | |
def take(generator, n): | |
""" Return first n elements of generator as list. """ | |
return list(it.islice(generator, n)) | |
# List a -> Int -> List a | |
def takecycle(elements, n): | |
""" Return first n elements of infinite cycle given by elements. """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import toolz as tz | |
np.random.seed(1000) | |
# String -> String | |
def generate_word(word): | |
""" Given a word, return a new word with vowels interspersed between the letters. """ | |
vowels = list('aeiouy_') | |
letters = list(word) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
import numpy as np | |
import cPickle as pickle | |
# (String -> a) -> Filename -> Int -> SideEffect[FileSystem] # List a | |
def chunkapply(f, filename, chunksize, savefile): | |
""" For each chunk, apply f to each line, and save the list of results to | |
file starting with savefilename, and followed by chunk number. """ | |
data = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def thread_last(val, *forms): | |
""" Thread value through a sequence of functions/forms | |
>>> def double(x): return 2*x | |
>>> def inc(x): return x + 1 | |
>>> thread_last(1, inc, double) | |
4 | |
If the function expects more than one input you can specify those inputs | |
in a tuple. The value is used as the last input. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasValue(x) { | |
return x.toString().length > 0; | |
} | |
function hasValues(values) { | |
for (var i = 0; i < values.length; i += 1) { | |
if (values[i].toString().length > 0) { | |
return true; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def lprint(xs): | |
for x in xs: | |
print(x) | |
def repeat_and_deduplicate(f, args, n): | |
return list(set([f(*args) for _ in range(n)])) | |