-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port tidyChromosomes from BRGenomics package
- Loading branch information
Showing
10 changed files
with
294 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Type: Package | ||
Package: EpiCompare | ||
Title: Comparison, Benchmarking & QC of Epigenomic Datasets | ||
Version: 1.7.5 | ||
Version: 1.9.5 | ||
Authors@R: c( | ||
person(given = "Sera", family = "Choi", | ||
email = "[email protected]", | ||
|
@@ -24,7 +24,11 @@ Authors@R: c( | |
comment = c(ORCID = "0000-0002-6807-3180")), | ||
person(given="Thomas", family="Roberts", | ||
email = "[email protected]", | ||
role = "cre") | ||
role = "ctb"), | ||
person(given="Hiranyamaya", family="Dash", | ||
email = "[email protected]", | ||
role = "cre", | ||
comment = c(ORCID = "0009-0005-5514-505X")) | ||
) | ||
Description: EpiCompare is used to compare and analyse epigenetic datasets | ||
for quality control and benchmarking purposes. | ||
|
@@ -44,7 +48,6 @@ Depends: | |
R (>= 4.2.0) | ||
Imports: | ||
AnnotationHub, | ||
BRGenomics, | ||
ChIPseeker, | ||
data.table, | ||
genomation, | ||
|
@@ -98,4 +101,4 @@ biocViews: Epigenetics, Genetics, QualityControl, ChIPSeq, | |
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
LazyData: FALSE | ||
RoxygenNote: 7.3.1 | ||
RoxygenNote: 7.3.2 |
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,78 @@ | ||
#' Remove odd chromosomes from GRanges objects | ||
#' | ||
#' This convenience function removes non-standard, mitochondrial, and/or sex | ||
#' chromosomes from any GRanges object. | ||
#' | ||
#' This function is adapted from \code{tidyChromosomes} in the | ||
#' \code{BRGenomics} package licensed under the Artistic License 2.0. | ||
#' Original author: Mike DeBerardine <https://github.com/mdeber> | ||
#' | ||
#' @param gr Any GRanges object, or any another object with associated | ||
#' \code{seqinfo} (or a \code{Seqinfo} object itself). The object should | ||
#' typically have a standard genome associated with it, e.g. \code{genome(gr) | ||
#' <- "hg38"}. \code{gr} can also be a list of such GRanges objects. | ||
#' @param keep.X,keep.Y,keep.M,keep.nonstandard Logicals indicating which | ||
#' non-autosomes should be kept. By default, sex chromosomes are kept, but | ||
#' mitochondrial and non-standard chromosomes are removed. | ||
#' @param genome An optional string that, if supplied, will be used to set the | ||
#' genome of \code{gr}. | ||
#' | ||
#' @return A GRanges object in which both ranges and \code{seqinfo} associated | ||
#' with trimmed chromosomes have been removed. | ||
#' | ||
#' @details Standard chromosomes are defined using the | ||
#' \code{\link[GenomeInfoDb:seqlevels-wrappers]{standardChromosomes}} function | ||
#' from the \code{GenomeInfoDb} package. | ||
#' | ||
#' @author Mike DeBerardine | ||
#' @seealso \code{\link[GenomeInfoDb:seqlevels-wrappers]{ | ||
#' GenomeInfoDb::standardChromosomes}} | ||
#' | ||
#' @export | ||
#' @importFrom GenomeInfoDb standardChromosomes seqlevels keepSeqlevels | ||
#' sortSeqlevels genome genome<- | ||
#' @importFrom methods is | ||
#' @examples | ||
#' # make a GRanges | ||
#' chrom <- c("chr2", "chr3", "chrX", "chrY", "chrM", "junk") | ||
#' gr <- GRanges(seqnames = chrom, | ||
#' ranges = IRanges(start = 2*(1:6), end = 3*(1:6)), | ||
#' strand = "+", | ||
#' seqinfo = Seqinfo(chrom)) | ||
#' genome(gr) <- "hg38" | ||
#' | ||
#' gr | ||
#' | ||
#' tidy_chromosomes(gr) | ||
#' | ||
#' tidy_chromosomes(gr, keep.M = TRUE) | ||
#' | ||
#' tidy_chromosomes(gr, keep.M = TRUE, keep.Y = FALSE) | ||
#' | ||
#' tidy_chromosomes(gr, keep.nonstandard = TRUE) | ||
#' | ||
#' @keywords internal | ||
tidy_chromosomes <- function(gr, keep.X = TRUE, keep.Y = TRUE, keep.M = FALSE, | ||
keep.nonstandard = FALSE, genome = NULL) { | ||
|
||
if (is.list(gr) || is(gr, "GRangesList")) | ||
return(lapply(gr, tidy_chromosomes, keep.X, keep.Y, keep.M, | ||
keep.nonstandard, genome)) | ||
|
||
if (!is.null(genome)) | ||
genome(gr) <- genome | ||
|
||
chrom <- standardChromosomes(gr) | ||
|
||
if (keep.nonstandard) chrom <- seqlevels(gr) | ||
if (!keep.X) chrom <- chrom[ chrom != "chrX" ] | ||
if (!keep.Y) chrom <- chrom[ chrom != "chrY" ] | ||
if (!keep.M) chrom <- chrom[ (chrom != "chrM") & (chrom != "chrMT") ] | ||
|
||
if (is(gr, "Seqinfo")) { | ||
gr <- keepSeqlevels(gr, chrom) | ||
} else { | ||
gr <- keepSeqlevels(gr, chrom, pruning.mode = "tidy") | ||
} | ||
sortSeqlevels(gr) | ||
} |
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
Oops, something went wrong.