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
# object must be an RGChannelSet object from the minfi package | |
getSnpBeta <- function(object){ | |
require(minfi) | |
minfi:::.isRG(object) | |
manifest <- getManifest(object) | |
snpProbesII <- getProbeInfo(manifest, type = "SnpII")$Name | |
M.II <- getGreen(object)[getProbeInfo(object, type = "SnpII")$AddressA,] |
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
makeAutosomal <- function(matrix){ | |
require(IlluminaHumanMethylation450kanno.ilmn12.hg19) | |
ann <- getAnnotation(IlluminaHumanMethylation450kanno.ilmn12.hg19) | |
good.probes <- rownames(ann)[-which(ann$chr=="chrX" | ann$chr=="chrY")] | |
matrix[rownames(matrix) %in% good.probes,] | |
} | |
makeX <- function(matrix){ | |
require(IlluminaHumanMethylation450kanno.ilmn12.hg19) |
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
getPCS <- function(matrix, ncomp=2){ | |
require(mixOmics) | |
nipals(matrix, ncomp = ncomp)$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
extract.portion <- function(file, chr, start, end, verbose = TRUE){ | |
rl <- IRanges::RangesList(IRanges::IRanges(start=start, end=end)) | |
names(rl) <- chr | |
portion <- import(file, as="Rle",format = "bw", selection = BigWigSelection(rl)) | |
portion <- portion[chr] | |
portion <- as.numeric(portion[[chr]]) | |
portion | |
} |
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
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)) | |
}) |
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(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 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 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 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) |
OlderNewer