-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
191 changed files
with
22,614 additions
and
49 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' GR.name_filter_convert | ||
#' | ||
#' @family plot | ||
#' @keywords internal | ||
GR.name_filter_convert <- function(GR.final, | ||
GR.names, | ||
min_hits = 1) { | ||
names(GR.final) <- GR.names | ||
grl <- GR.final[!as.logical(lapply(GR.final, is.null))] | ||
# Filter to those that had at least N hits | ||
grl <- grl[as.logical(lapply(grl, function(g, min_hits. = min_hits) { | ||
length(GenomicRanges::seqnames(g)) >= min_hits. | ||
}))] | ||
# Convert to GRangesList (important) | ||
grl <- GenomicRanges::GRangesList(grl) | ||
return(grl) | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Gather Roadmap annotation metadata | ||
#' | ||
#' @param ref_path Where the ROADMAP metadata is stored. | ||
#' @param keyword_query Search all columns in the Roadmap annotations metadata | ||
#' and only query annotations that contain your keywords. | ||
#' Can provide multiple keywords in list form: | ||
#' \code{c("placenta","liver","monocytes")} | ||
#' | ||
#' @examples | ||
#' ref <- ROADMAP.construct_reference(keyword_query = c( | ||
#' "placenta", | ||
#' "liver", | ||
#' "monocytes" | ||
#' )) | ||
#' @family ROADMAP | ||
#' @export | ||
#' @importFrom data.table transpose fread | ||
ROADMAP.construct_reference <- function(ref_path = | ||
system.file( | ||
"extdata/ROADMAP", | ||
"ROADMAP_Epigenomic.js", | ||
package = "echoannot" | ||
), | ||
keyword_query = NULL) { | ||
# %like% is from data.table | ||
ref <- suppressWarnings(data.table::fread(ref_path)) | ||
colnames(ref)[1] <- "EID" | ||
if (!is.null(keyword_query)) { | ||
rows <- grep(paste(keyword_query, collapse = "|"), | ||
data.table::transpose(ref), | ||
ignore.case = TRUE | ||
) | ||
ref <- ref[rows, ] | ||
messager( | ||
"+ ROADMAP::", nrow(ref), | ||
"annotation(s) identified that match `keyword_query`." | ||
) | ||
} | ||
return(ref) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#' Standardize Roadmap query | ||
#' | ||
#' @param grl.roadmap Roadmap query results | ||
#' @param n_top_tissues The number of top tissues to include, | ||
#' sorted by greatest number of rows | ||
#' (i.e. the number of genomic ranges within the window). | ||
#' @family ROADMAP | ||
#' @importFrom IRanges overlapsAny | ||
#' @importFrom dplyr %>% group_by tally n_distinct | ||
ROADMAP.merge_and_process_grl <- function(grl.roadmap, | ||
gr.snp, | ||
n_top_tissues = 5, | ||
sep = " ") { | ||
grl.roadmap.merged <- unlist(grl.roadmap) | ||
grl.roadmap.merged$Source <- names(grl.roadmap.merged) | ||
grl.roadmap.merged$Source <- gsub("_", sep, grl.roadmap.merged$Source) | ||
grl.roadmap.merged$ChromState <- | ||
lapply( | ||
grl.roadmap.merged$State, | ||
function(ROW) { | ||
base::strsplit(ROW, "_")[[1]][2] | ||
} | ||
) %>% unlist() | ||
grl.roadmap.filt <- grl.roadmap.merged[unlist(lapply( | ||
grl.roadmap, function(e) { | ||
IRanges::overlapsAny(e, gr.snp, minoverlap = 1) | ||
} | ||
))] | ||
if (!is.null(n_top_tissues)) { | ||
top_tissues <- data.frame(grl.roadmap.filt) %>% | ||
dplyr::group_by(Source) %>% | ||
dplyr::tally(sort = TRUE) | ||
grl.roadmap.filt <- subset( | ||
grl.roadmap.filt, | ||
Source %in% unique(top_tissues$Source[ | ||
seq(1, min( | ||
n_top_tissues, | ||
dplyr::n_distinct(top_tissues$Source) | ||
)) | ||
]) | ||
) | ||
} | ||
return(grl.roadmap.filt) | ||
} |
Oops, something went wrong.