Last active
January 25, 2017 16:24
-
-
Save jshayiding/6e182fd10f56b6ba348abba61472ccd3 to your computer and use it in GitHub Desktop.
minimal peak Interval example
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
# minimal example to test revised implementation | |
grs <- GRangesList( | |
bar= GRanges(seqnames = Rle("chr1",9), | |
IRanges( | |
c(8,18,33,53,69,81,105,115,135), | |
c(14,21,39,61,73,87,111,120,153)), | |
score=c(48,7,10,8,4,15,4,4,38)), | |
cat = GRanges(seqnames = Rle("chr1",8), | |
IRanges( | |
c(6,15,20,44,71,99,113,141), | |
c(10,17,34,51,78,103,124,147)), | |
score=c(54,21,14,12,21,7,32,4)), | |
foo= GRanges(seqnames = Rle("chr1",5), | |
IRanges( | |
c(11,43,57,101,117), | |
c(36,49,92,109,139)), | |
score=c(49,13,13,11,5)) | |
) | |
#----------------------------------------------------------# | |
inDat <- lapply(grs, function(x) { | |
x$p.value <- 10^(score(x)/(- 1L)) | |
x | |
}) | |
inDat <- GRangesList(inDat) | |
#---------------------------------------------------------# | |
Hit <- peakOverlapping(inDat, whichType="max") | |
filtByOvHit <- filterByOverlapHit(ovHit = Hit, peakset=inDat, replicate.type = "Biological", isSuffOverlap = TRUE) | |
#---------------------------------------------------------# | |
# Trivial revision for Fisher_stats | |
# Note : let's do not run Fisher_stats function, I'll do rewrite its implementation | |
DF <- DataFrame(split(filtByOvHit, filtByOvHit$query)) | |
pvList <- as.matrix(DF$p.value) | |
pvList[is.na(pvList)] <- 0 | |
#rslt <- DataFrame(subject=DF$subject, pvalue=DF$p.value) | |
DF$comb.pv <- apply(pvList,1,fisherCmbp) | |
res <- unlist(extractList(unlist(inDat, use.names = TRUE), | |
DF$subject), use.names = FALSE) | |
rslt <- split(res, names(res)) | |
# use base R to remove redundant name | |
rslt <- lapply(rslt, unname) | |
# ?? How can I make above process more efficient and computationaly less expensive ? How can I resolve mysterious duplicate removal method? | |
# ?? why revised implementation is not expected output ?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment