This file contains 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
library(ggplot2) | |
library(gtable) | |
# create example data | |
set.seed(42) | |
dataset_names <- c("Human", "Mouse", "Fly", "Worm") | |
datasets <- data.frame(name = factor(dataset_names, levels=dataset_names), parity = factor(c(0, 0, 1, 0)), v50 = runif(4, max=0.5), y=1:4) | |
data <- data.frame( dataset1 = rep(datasets$name, 4), dataset2 = rep(datasets$name, each = 4), z = runif(16,min = 0, max = 0.5) ) | |
pal <- c("#dddddd", "#aaaaaa") |
This file contains 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
library(dplyr) | |
a <- data.frame(foo = 1:10, bar = "bar") | |
b <- tbl_df(a) | |
a[,1] | |
b[,1] | |
paste0(a[,1], "!") | |
paste0(b[,1], "!") |
This file contains 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
# with the help of decorators, keep track of the functions | |
# we would like to use for fitting | |
fit_functions = [] | |
def fit_func(f): | |
fit_functions.append(f) | |
return f | |
class C(object): |
This file contains 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
#!/usr/bin/perl -w | |
my $columns = 50; | |
my $gapped = 0; | |
my $progname = $0; | |
$progname =~ s/^.*?([^\/]+)$/$1/; | |
my $usage = "Usage: $progname [<Stockholm file(s)>]\n"; | |
$usage .= " [-h] print this help message\n"; |
This file contains 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
#!/usr/bin/env python | |
import readline | |
import os | |
import sys | |
import re | |
if len(sys.argv) == 1: | |
print >> sys.stderr, "Usage: igrep[.py] file1 [file2 ...]" |
This file contains 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
p <- ggplot(d,aes(x+0.05,y+0.05))+geom_tile(aes(fill=enrichment)) + scale_fill_gradient(low="white", high="steelblue", limits=c(0,120)) | |
p <- p + xlab("x") + ylab("y") | |
p <- p + geom_point(aes(x=x+0.05, y=y+0.05, colour=pred),size=20) + scale_colour_gradient(low="white", high="steelblue", limits=c(0,120)) | |
print(p) |
This file contains 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
pred <- ddply(data.frame(x=c(5:65)*0.01), .(x), function(t) data.frame(x = t$x, y = c(5:85)*0.01) ) | |
pred$enrichment <- predict(sigmoid, pred) | |
max_pred <- max(pred$enrichment, d$enrichment) | |
p <- ggplot(pred,aes(x,y))+geom_tile(aes(fill=enrichment))+scale_fill_gradient(low = "white", high = "steelblue",limits=c(0,max_pred)) | |
p <- p + xlab("x") + ylab("y") | |
p <- p + geom_point(data=d,aes(x=x, y=y, colour=enrichment),size=20) +scale_colour_gradient(low = "white", high = "steelblue",limits=c(0,max_pred)) | |
print(p) |
This file contains 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
library(ggplot2) | |
df <- data.frame( n=c("a","a","b","b","c","c"), x = rep(c(1,2), 3), y = rep(c(1), 6), l = as.factor(c(1,1,0,0,0,0))) | |
# Contents of df: | |
# n x y l | |
# 1 a 1 1 1 | |
# 2 a 2 1 1 | |
# 3 b 1 1 0 | |
# 4 b 2 1 0 |
This file contains 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
library(purrr) | |
runtimes <- get_elapsed_time(fit)[,2] | |
inits <- get_inits(fit) | |
## traditional conversion to a matrix | |
# m.init <- do.call(rbind, lapply(inits, function(l) do.call(c, l))) | |
## using purrr |
This file contains 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
> library(purrr) | |
> ll <- list(list(a=1:3, b=4), list(a=5:7, b=8)) | |
> ll %>% map(lift_dl(c)) %>% map_call(rbind) | |
a1 a2 a3 b | |
[1,] 1 2 3 4 | |
[2,] 5 6 7 8 | |
> Reduce(rbind, ll) | |
a b | |
init Integer,3 4 | |
Integer,3 8 |
OlderNewer