R/dataset_functions.R
mergeReplicates.Rd
This simple convenience function uses
mergeGRangesData
to combine
replicates (e.g. biological replicates) of basepair-resolution GRanges
objects.
mergeReplicates(
...,
field = "score",
sample_names = NULL,
makeBRG = TRUE,
exact_overlaps = FALSE,
ncores = getOption("mc.cores", 2L)
)
Either a list of GRanges objects, or any number of GRanges objects
(see mergeGRangesData
). However,
the names of the datasets must end in "_rep#"
, where "#" is one or
more characters indicating the replicate.
The metadata field that contains count information for each
range. length(field)
should either be 1, or equal to the number of
datasets.
Optional character vector with which to rename the datasets. This is useful if the sample names do not conform to the "_rep" naming scheme.
See
mergeGRangesData
.
The number of cores to use. This function will try to maximize
the use of the ncores
given, but care should be taken as
mergeGRangesData
can be memory intensive. Excessive memory usage can
cause dramatic reductions in performance.
A list of GRanges objects.
data("PROseq")
ps_list <- list(a_rep1 = PROseq[seq(1, length(PROseq), 4)],
b_rep1 = PROseq[seq(2, length(PROseq), 4)],
a_rep2 = PROseq[seq(3, length(PROseq), 4)],
b_rep2 = PROseq[seq(4, length(PROseq), 4)])
mergeReplicates(ps_list, ncores = 1)
#> $a
#> GRanges object with 23690 ranges and 1 metadata column:
#> seqnames ranges strand | score
#> <Rle> <IRanges> <Rle> | <integer>
#> [1] chr4 1295 + | 1
#> [2] chr4 42588 + | 1
#> [3] chr4 42593 + | 5
#> [4] chr4 42595 + | 1
#> [5] chr4 42601 + | 1
#> ... ... ... ... . ...
#> [23686] chr4 1307122 - | 1
#> [23687] chr4 1307283 - | 1
#> [23688] chr4 1307301 - | 1
#> [23689] chr4 1316537 - | 1
#> [23690] chr4 1319004 - | 1
#> -------
#> seqinfo: 7 sequences from an unspecified genome
#>
#> $b
#> GRanges object with 23690 ranges and 1 metadata column:
#> seqnames ranges strand | score
#> <Rle> <IRanges> <Rle> | <integer>
#> [1] chr4 41428 + | 1
#> [2] chr4 42590 + | 2
#> [3] chr4 42594 + | 2
#> [4] chr4 42596 + | 1
#> [5] chr4 42618 + | 1
#> ... ... ... ... . ...
#> [23686] chr4 1307126 - | 1
#> [23687] chr4 1307300 - | 1
#> [23688] chr4 1307742 - | 1
#> [23689] chr4 1318960 - | 1
#> [23690] chr4 1319369 - | 1
#> -------
#> seqinfo: 7 sequences from an unspecified genome
#>