library(microbenchmark)
set.seed(1024) nr <- 1e4 nc <- 100
m <- matrix(runif(nr * nc), nrow = nr, dimnames = list(paste0("g", seq_len(nr)), paste0("s", seq_len(nc))))
# Download the latest GENCODE annotations file and export as a GRanges object | |
library(RCurl) | |
library(rtracklayer) | |
# Variables --------------------------------------------------------------- | |
# 'human' or 'mouse' | |
organism <- "human" |
library(ggplot2) | |
library(plyr) | |
# Load data --------------------------------------------------------------- | |
enrich.file <- "results/alspac/enrichment/enrichment-results-alspac-encode-dnase-h3k4me3.csv" | |
enrich.df <- read.csv(enrich.file, stringsAsFactors = FALSE) | |
# address stem-cell samples missing tissue annotation |
javascript:var%20insert_proxy%20=%20function(proxy)%20{var%20url%20=%20document.URL;if%20(url.indexOf(proxy)%20===%20-1)%20{var%20parser%20=%20document.createElement(%27a%27);parser.href%20=%20url;var%20host%20=%20parser.host;if%20(host%20==%20%27www.ncbi.nlm.nih.gov%27)%20{host%20=%20host.replace(/\./g,%20%27-%27);};host%20=%20host.concat(proxy);proxy_url%20=%20url.replace(parser.host,%20host);window.open(proxy_url,%20%27_self%27);};};insert_proxy(%27.proxy.library.vcu.edu%27); |
# Parse pathway file containing entries from the KEGG enzyme, orthology and | |
# pathway databases. | |
# | |
# For cases when there are multiple matches across databases all combinations | |
# of the match are returned. For example, some enzyme entries map to multiple | |
# orthologies: | |
# | |
# K00918 ADP-dependent phosphofructokinase/glucokinase [EC:2.7.1.146 2.7.1.147] | |
# | |
# will become... |
# Extract and append multiple values embedded in rows | |
# | |
# data: data.frame | |
# col: column name containing embedded values | |
# sep: regular expression to split column by | |
# | |
# df <- data.frame(key = c("a", "a;b", "a;b;c"), val = 1:3) | |
# unembed(df, "key", ";") | |
unembed <- function(data, col, sep, ...) { |
# Identify clusters of contiguous factors within a dendrogram | |
# Aaron Wolen | |
# | |
# See http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0038422 | |
# for an example situation in which this would be useful | |
# | |
# x: dendrogram | |
# f: a named vector containing the factor that defines the grouping of leaves, | |
# must be named using the same values that define x's leaf labels |
--- | |
title: "test" | |
output: | |
html_document: | |
keep_md: yes | |
--- | |
```{r} | |
library(qtl) | |
library(qtlcharts) |
(* | |
display-specific fullscreen behavior | |
enable fullscreen for specific applications on MacBook and disable fullscreen | |
when using a larger external display | |
adapted from: | |
* https://gist.github.com/dsummersl/4175461 | |
* http://daringfireball.net/2006/12/display_size_applescript_the_lazy_way | |
*) |
# A few simple rules from Stephen Wolfram's A New Kind of Science | |
apply_rule <- function(x, rule = "254") { | |
stopifnot(length(x) == 3) | |
stopifnot(all(x %in% c(0, 1))) | |
rules <- list("254" = c(1, 1, 1, 1, 1, 1, 1, 0), | |
"250" = c(1, 1, 1, 1, 1, 0, 1, 0), | |
"90" = c(0, 1, 0, 1, 1, 0, 1, 0), | |
"30" = c(0, 0, 0, 1, 1, 1, 1, 0)) |
library(microbenchmark)
set.seed(1024) nr <- 1e4 nc <- 100
m <- matrix(runif(nr * nc), nrow = nr, dimnames = list(paste0("g", seq_len(nr)), paste0("s", seq_len(nc))))