Skip to content

Commit

Permalink
Ran github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
smped committed Apr 7, 2024
1 parent dd9a065 commit 0537775
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: extraChIPs
Version: 1.7.6
Version: 1.7.7
Title: Additional functions for working with ChIP-Seq data
Authors@R: person("Stevie", "Pederson",
email = "[email protected]",
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@

# Changes in 1.7.6

- Added the DESeq2 Wald statistic to options for fitAssayDiff
- Added the DESeq2 Wald statistic to options for `fitAssayDiff()`

# Changes in 1.7.7

- Added `merge_within` to `makeConsensus()` for better handling when `method = "coverage"`
26 changes: 19 additions & 7 deletions R/makeConsensus.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#' range which are 'covered' by the minimum proportion of replicates specified
#' are returned. This will return narrower peaks in general, although some
#' artefactual very small ranges may be included (e.g. 10bp). Careful setting
#' of the min_width parameter may be very helpful for these instances. It is
#' also expected that setting method = "coverage" should return the region
#' within each range which is more likely to contain the true binding site for
#' the relevant ChIP targets
#' of the min_width and merge_within parameters may be very helpful for these
#' instances. It is also expected that setting method = "coverage" should return
#' the region within each range which is more likely to contain the true binding
#' site for the relevant ChIP targets
#'
#'
#' @param x A GRangesList
Expand All @@ -29,6 +29,7 @@
#' @param ignore.strand,simplify,... Passed to \link{reduceMC} or
#' \link{intersectMC} internally
#' @param min_width Discard any regions below this width
#' @param merge_within Passed to \link[GenomicRanges]{reduce} as `min.gapwidth`
#'
#' @return
#' `GRanges` object with mcols containing a logical vector for every element of
Expand Down Expand Up @@ -60,7 +61,8 @@
#' @export
makeConsensus <- function(
x, p = 0, var = NULL, method = c("union", "coverage"),
ignore.strand = TRUE, simplify = FALSE, min_width = 0, ...
ignore.strand = TRUE, simplify = FALSE, min_width = 0,
merge_within = 1L, ...
) {

## Starting with a GRList
Expand Down Expand Up @@ -91,22 +93,32 @@ makeConsensus <- function(
cov_gr <- GRanges(coverage(x))
cov_gr <- subsetByOverlaps(cov_gr, unlisted)
## Coverage will be returned as the column 'score'
cov_gr <- cov_gr[mcols(cov_gr)[["score"]] >= p * length(x)]
keep <- mcols(cov_gr)[["score"]] >= p * length(x)
cov_gr <- cov_gr[keep]
## If merging within a certain range, merge here. This ensures that
## returned regions still have coverage but deals with small holes
## that appear due to drops in coverage, without messing up the *MC
cov_gr <- GenomicRanges::reduce(
cov_gr, min.gapwidth = merge_within, ignore.strand = ignore.strand
)
red_ranges <- intersectMC(
unlisted, cov_gr, ignore.strand = ignore.strand,
simplify = simplify, ...
)

}
if (method == "union") {
## For now, remove all mcols, however reduceMC may be useful if
## wishing to retain these for use with plotOverlaps()
red_ranges <- reduceMC(
unlisted, ignore.strand = ignore.strand, simplify = simplify, ...
unlisted, ignore.strand = ignore.strand, simplify = simplify,
min.gapwidth = merge_within, ...
)
}
## Return the columns for overlaps
ol <- lapply(x, function(x) overlapsAny(red_ranges, x))
ol <- as.data.frame(ol)

## Ensure names are strictly retained
names(ol) <- names(x)
ol$n <- rowSums(ol)
Expand Down
8 changes: 4 additions & 4 deletions R/plotOverlaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#' `draw.single/triple.venn`) for Venn Diagrams, and to
#' \link[ComplexUpset]{upset} for UpSet plots
#' @param .sort_sets passed to `sort_sets` in \link[ComplexUpset]{upset}
#' @param min.gapwidth,ignore.strand Passed to \link[GenomicRanges]{reduce}
#' @param ignore.strand Passed to \link[GenomicRanges]{reduce}
#' @param merge_within Passed to \link{makeConsensus}
#' @param sz_sets Text size for set size labels. Passed internally to
#' `geom_text(size = sz_sets)`
#' @param hj_sets Horizontal adjustment of set size labels
Expand Down Expand Up @@ -72,7 +73,7 @@ setMethod(
x, type = c("auto", "venn", "upset"), var = NULL,
f = c("mean", "median", "max", "min", "sd"),
set_col = NULL, ..., .sort_sets = "ascending", hj_sets = 1.15,
sz_sets = 3.5, exp_sets = 0.25, min.gapwidth = 1L, ignore.strand = TRUE
sz_sets = 3.5, exp_sets = 0.25, merge_within = 1L, ignore.strand = TRUE
) {

stopifnot(is(x, "GRangesList"))
Expand All @@ -87,8 +88,7 @@ setMethod(

# Collapse as required
gr <- makeConsensus(
x, var = var,
min.gapwidth = min.gapwidth, ignore.strand = ignore.strand
x, var = var, merge_within = merge_within, ignore.strand = ignore.strand
)

if (is.null(var) | type == "venn") {
Expand Down
2 changes: 1 addition & 1 deletion R/setoptsMC.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ setMethod(
col_names <- colnames(DF)
if (n > 0) {
DF2 <- list()
for (i in seq_along(col_names)){
for (i in seq_along(col_names)) {
vec <- DF[[i]]
nm <- col_names[[i]]
type <- is(vec)[[1]]
Expand Down
11 changes: 7 additions & 4 deletions man/makeConsensus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/plotOverlaps-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0537775

Please sign in to comment.