A small request: support for upset plots when visualizing peak overlaps.
I am currently using a modified version of the vennplot function, but having it accessible somewhere in ChIPseeker itself would be very convenient.
This modified function accepts the same inputs as vennplot, but when by = UpSetR the function takes overlapDF and copies rows n times based on the Weight column, subsequently drops the Weight column, and passes the resultant overlapDF to a standard UpSetR plot call. This quick-fix has worked well enough for my purposes, although I admit there are probably better ways to achieve this.
Thanks for considering! See below for function code & a couple example plots.
overlapPlot <- function (Sets, by = "gplots")
{
if (is.null(names(Sets))) {
nn <- paste0("Set", seq_along(Sets))
warning("input is not a named list, set the name automatically to ",
paste(nn, collapse = " "))
names(Sets) <- nn
}
overlapDF <- overlap(Sets)
if (by == "Vennerable") {
pkg <- "Vennerable"
require(pkg, character.only = TRUE)
Venn <- eval(parse(text = "Venn"))
v <- Venn(SetNames = names(Sets), Weight = overlapDF$Weight)
plotVenn <- eval(parse(text = "Vennerable:::plotVenn"))
plotVenn(v)
}
else if (by == "gplots") {
n <- ncol(overlapDF)
colnames(overlapDF)[n] <- "num"
overlapDF <- overlapDF[, c(n, 1:(n - 1))]
rownames(overlapDF) = apply(overlapDF, 1, function(i) paste(i[-1],
sep = "", collapse = ""))
vennCount <- as.matrix(overlapDF)
class(vennCount) <- "venn"
plot.venn(vennCount)
}
else if (by == "UpSetR") {
pkg <- "UpSetR"
require(pkg, character.only = TRUE)
n <- ncol(overlapDF)
overlapDF <- overlapDF[rep(seq(nrow(overlapDF)), overlapDF$Weight),]
overlapDF <- overlapDF[, c(1:(n-1))]
upset(overlapDF)
}
else {
stop("not supported...")
}
}
A small request: support for upset plots when visualizing peak overlaps.
I am currently using a modified version of the
vennplot
function, but having it accessible somewhere in ChIPseeker itself would be very convenient.This modified function accepts the same inputs as
vennplot
, but whenby = UpSetR
the function takesoverlapDF
and copies rowsn
times based on theWeight
column, subsequently drops theWeight
column, and passes the resultantoverlapDF
to a standard UpSetR plot call. This quick-fix has worked well enough for my purposes, although I admit there are probably better ways to achieve this.Thanks for considering! See below for function code & a couple example plots.