1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| f_gadem_one <- function(probes, seqname, delta_start = 100, delta_end = 100){ probes_tmp <- subset(probes, seqnames==seqname) res <- list( seqnames = rep(seqname,length(probes_tmp)), start = ranges(probes_tmp) %>% as.data.frame() %>% dplyr::pull("start") - 100, end = ranges(probes_tmp) %>% as.data.frame() %>% dplyr::pull("end") + 100 ) res } f_gadem <- function(probes, all_seqN=NULL, delta_start = 100, delta_end = 100){ if(is.null(all_seqN)){ all_seqN <- as.character(unique(seqnames(probes))) } res_seqnames <- NULL res_start <- NULL res_end <- NULL for(x in all_seqN){ res <- f_gadem_one(probes, x, delta_start, delta_end) res_seqnames <- c(res_seqnames, res$seqnames) res_start <- c(res_start, res$start) res_end <- c(res_end, res$end) } sequence <- GRanges( seqnames = res_seqnames, IRanges( start = res_start, end = res_end), strand = "*" ) gadem <- GADEM(sequence, verbose = FALSE, genome = BSgenome.Hsapiens.UCSC.hg19::Hsapiens) gadem }
|