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
4 # number of states | |
START | |
COLD | |
HOT | |
END | |
3 # size of vocab | |
1 | |
2 | |
3 |
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
# Alternative to a doubly-nested loop | |
# Imagine I want to perform an operation on a data frame | |
# once for each combination of two variables, such as Country and Year | |
# I can do this with a nested loop, or I can do this with (among other | |
# things) lapply() | |
# Generate random data: | |
allCountries <- LETTERS[1:10] | |
allYears <- 1990:2012 |
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("rtracklayer") | |
session <- browserSession("UCSC") | |
genome(session)<-"mm9" | |
query <- ucscTableQuery(session, "refGene") | |
tableName(query) <- "refGene" | |
getTable(query) -> refseq | |
refseq[,c(2,3,4,5,6,7,8,13)] -> refseq | |
refseq$"width" <- refseq$"txEnd"-refseq$"txStart" | |
as.character(refseq[,1]) -> refseq[,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
library(data.table) | |
library(genomation) | |
library(ggplot2) | |
#' Annotate given ranges with genomic features | |
#' | |
#' The function annotates a target GRangesList or GRanges object as overlapping | |
#' or not with | |
#' the elements of named GRangesList. This is useful to annotate your regions |
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
geneRanges <- | |
function(db, column="ENTREZID") | |
{ | |
g <- genes(db, columns=column) | |
col <- mcols(g)[[column]] | |
genes <- granges(g)[rep(seq_along(g), elementNROWS(col))] | |
mcols(genes)[[column]] <- as.character(unlist(col)) | |
genes | |
} |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
from scipy.integrate import odeint | |
# Set random seed (for reproducibility) | |
np.random.seed(1000) | |
# Start and end time (in milliseconds) | |
tmin = 0.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
# test Jaccard | |
# Create a list gene sets | |
char1 <- c("gene1", "gene2", "gene5", "gene9", "gene10") | |
char2 <- c("gene2", "gene3", "gene5", "gene7", "gene10") | |
char3 <- c("gene7", "gene9", "gene10", "gene11", "gene12", "gene1") | |
lst <- list(char1, char2, char3) | |
# Function to calculate Jaccard distance |
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(ChIPpeakAnno) | |
library(biomaRt) | |
library(genomation) | |
library(dplyr) | |
# Read in metilene results | |
res <- read.table("results_de_novo_all_10.txt", sep = "\t", header = T) | |
head(res) |
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
# Alternative to a doubly-nested loop | |
# Imagine I want to perform an operation on a data frame | |
# once for each combination of two variables, such as Country and Year | |
# I can do this with a nested loop, or I can do this with (among other | |
# things) lapply() | |
# Generate random data: | |
allCountries <- LETTERS[1:10] | |
allYears <- 1990:2012 |