Ok, so I want my own definition of reduce, that calls GenomicRanges::reduce() if keep.names = F, the extra argument I want.
I can not find the original setGeneric for reduce, I guess it's auto-created ?
my generic is:
setGeneric("reduce", function(x, ...) standardGeneric("reduce")) # i extend with ...
It works, and all is good, but when doing check on package I get warning:
Warning: multiple methods tables found for ‘reduce’
How to fix this ?
My functions are:
#' Generic for reduce in ORFik
#'
#' @param x a GRangesList
#' @param ... see \code{\link[GenomicRanges]{reduce}}
#' @importFrom methods setGeneric
#' @export
setGeneric("reduce", function(x, ...) standardGeneric("reduce"))
#' Reduce GRanges / GRangesList
#'
#' Extends function \code{\link[GenomicRanges]{reduce}}
#' by trying to keep names and meta columns if it is a
#' GRangesList. If keep.names == F, it's just the normal
#' GenomicRanges::reduce.
#'
#' Only tested for orfik, might not work for other naming conventions.
#' @param x a \code{\link[GenomicRanges]{GRangesList}} or GRanges object
#' @param drop.empty.ranges (FALSE) if a group is empty (width 0), delete it.
#' @param min.gapwidth (1L) how long gap can it be to say they belong together
#' @param with.revmap (FALSE) return info on which mapped to which
#' @param with.inframe.attrib (FALSE) For internal use.
#' @param ignore.strand (FALSE), can different strands be reduced together.
#' @param keep.names (FALSE) keep the names and meta columns of the GRangesList
#' @importFrom methods setMethod
#' @export
#' @return A reduced GRangesList
setMethod("reduce", signature = signature(x = "GRangesList"),
function(x, drop.empty.ranges = FALSE,
min.gapwidth = 1L, with.revmap = FALSE,
with.inframe.attrib = FALSE,
ignore.strand = FALSE , keep.names = FALSE){ #### <- here keep.names is defined, my variable.
if (keep.names) { # return with names
gr <- unlist(GenomicRanges::reduce(x), use.names = TRUE)
if (length(gr) == 0) return(GRangesList())
return(matchNaming(gr, x))
} else { # return original
return(GenomicRanges::reduce(x, drop.empty.ranges, min.gapwidth,
with.revmap, with.inframe.attrib,
ignore.strand))
}
})

Thanks for the help Martin, slowly learning the way of R.
I renamed the function to reduce_keep_attr
It tries to keep the meta columns and naming if it makes sense after reduction.