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
D <- split(as.data.frame(M), A) | |
correlations <- llapply(D,D,getCorrelation) | |
llapply <- function(list1,list2, fun){ | |
temp <- unlist(lapply(list1, function(x){ | |
unlist(lapply(list2, function(y){ | |
do.call(fun, list(x,y)) | |
})) | |
})) |
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
pair.lapply <- function(list1, list2, fun, list3=NULL){ | |
results <- list() | |
for (i in 1:length(list1)){ | |
if (is.null(list3)){ | |
results[[i]] <- do.call(fun, list(list1[[i]],list2[[i]])) | |
} else { | |
results[[i]] <- do.call(fun, list(list1[[i]][list3[[i]]],list2[[i]][list3[[i]]])) | |
} | |
} |
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
tar -zxvf |
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
library(IlluminaHumanMethylation450kanno.ilmn12.hg19) | |
locations <- getLocations(IlluminaHumanMethylation450kanno.ilmn12.hg19) | |
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
killscreens () { | |
screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill | |
} |
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
# To ask for more writing memory: | |
-l h_fsize=40G | |
# Tar | |
tar -xvfz | |
# To remove all deleted files from git repo: | |
git rm $(git ls-files --deleted) |
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
BetaToM <- function(beta){ | |
matrix <- log2(beta) - log2(1-beta) | |
impute.matrix(matrix) | |
} | |
MToBeta <- function(mmatrix){ | |
matrix <- 2^mmatrix/(2^mmatrix+1) | |
impute.matrix(matrix) | |
} |
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
impute.matrix <- function (matrix) { | |
missing <- which(is.na(matrix) | !is.finite(matrix), arr.ind=TRUE) | |
if (length(missing)!=0){ | |
for (j in 1:nrow(missing)){ | |
mean <- mean(matrix[missing[j,1],][is.finite(matrix[missing[j,1],])], na.rm=TRUE) | |
matrix[missing[j,1],missing[j,2]] <- mean | |
} | |
} | |
matrix | |
} |
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
library(IlluminaHumanMethylation450kanno.ilmn12.hg19) | |
ann <- getAnnotation(IlluminaHumanMethylation450kanno.ilmn12.hg19) | |
island.status <- gsub("N_|S_","",ann$Relation_to_Island) | |
counts <- table(island.status) | |
percs <- counts/nrow(ann)*100 |
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
extract.block <- function(files, chr, start, end, verbose = TRUE){ | |
rl <- IRanges::RangesList(IRanges::IRanges(start=start, end=end)) | |
names(rl) <- chr | |
cat("[extract.block] Reading in the files \n") | |
rles <- lapply(files, function(xx) { | |
#if (verbose){ | |
# cat("Reading", xx, "\n") | |
#} | |
import(xx, as = "Rle", format = "bw", selection = BigWigSelection(rl)) | |
}) |