mergeSamples {Chicago} | R Documentation

## Merge samples together.

### Description

Merge a number of `chicagoData` objects together, summarising their counts into a normalised value.

### Usage

    mergeSamples(cdl, normalise = TRUE, NcolOut = "N",
          NcolNormPrefix = "NNorm", mergeMethod = c("weightedMean", "mean")[1], repNormCounts = (mergeMethod=="mean"))

### Arguments

`cdl` | A `list` of `chicagoData` objects.
`normalise` | If `TRUE`, use a normalisation procedure, specified by `mergeMethod`, to arrive at a normalised count. If `FALSE`, take the mean number of reads.
`NcolOut` | The column to store the normalised counts in.
`NcolNormPrefix` | Each sample gains a normalised count column, that begins with this prefix.
`mergeMethod` | If `mergeMethod == "weightedMean"`, then NcolOut is the weighted mean of the sample-wise counts adjusted by the samples' respective scaling factors `s_k`. If `mergeMethod == "mean"`, then sample-specific counts are first normalised by dividing by s_k, and NcolOut is computed as the mean of these normalised counts.
`repNormCounts` | Report normalised counts for each replicate (by dividing them by s_k) in the <NcolNormPrefix>.<sampleNo> column (by default, NNorm.1, NNorm.2, etc.). This option is on by default when `mergeMethod == "mean"`. However, it can also be used with `mergeMethod == "weightedMean"` (but the normalised counts will still be produced by dividing the raw counts for each replicate by s_k).

### Value

An object of class `chicagoData`, with a `params(cd)$s_k` slot added representing the per-sample scaling factors used in normalisation.

### Note

Raw per-sample counts will be stored in the N.<sampleNo> column (N.1, N.2, etc.)

### Author(s)

Mikhail Spivakov, Jonathan Cairns, Paula Freire Pritchett

### See Also

`readAndMerge`

### Examples

    filesDir <- file.path(system.file("extdata", package="Chicago"), "unitTestData")
    files <- file.path(filesDir, dir(filesDir))
    print(files) ##we will read in and merge these files

    designDir <- file.path(system.file("extdata", package="Chicago"), "unitTestDesign")

    cdA <- setExperiment(designDir=designDir)
    cdA <- readSample(files[1], cdA)

    cdB <- setExperiment(designDir=designDir)
    cdB <- readSample(files[2], cdB)

    cdMerged <- mergeSamples(list(cdA, cdB))

[Package Chicago version 1.18.0 Index]