read2count {metaseqR2} | R Documentation

## SAM/BAM/BED file reader helper for the metaseqr2 pipeline

### Description

This function is a helper for the `metaseqr2` pipeline, for reading SAM/BAM or BED files when a read counts file is not available. It can also be used very easily in an autonomous manner.

### Usage

        read2count(targets, annotation, fileType = targets$type,
            transLevel = "gene", utrOpts = list(frac = 1,
            minLength = 300, downstream = 50), interFeature = FALSE,
            rc = NULL)

### Arguments

`targets` | a named list, the output of `readTargets` or an existing file with targets. See also the main `metaseqr2` man page.
`annotation` | a `GenomicRanges` or `data.frame` with genomic coordinates to use for read counting. See also `getAnnotation`.
`fileType` | the type of raw input files. It can be `"bed"` for BED files or `"sam"`, `"bam"` for SAM/BAM files. See the same argument in the main `metaseqr2` function for the case of auto-guessing.
`transLevel` | see the `transLevel` argument in the main `metaseqr2` function.
`utrOpts` | a named list with members `frac` which is the fraction (0-1) of the 3' UTR region to count reads in, `minLength` the minimum acceptable 3'UTR length irrespective of `frac` and `downstream` the number of base pairs to flank the end of the 3' UTR of transcripts when analyzing Quant-Seq data.
`interFeature` | see the `inter.feature` argument in `summarizeOverlaps`.
`rc` | the fraction of the available cores to use in a multicore system.

### Value

A data frame with counts for each sample, ready to be passed to the main `metaseqr2` pipeline.

### Author(s)

Panagiotis Moulos

### Examples

    dataPath <- system.file("extdata",package="metaseqR2")
    targets <- data.frame(samplename=c("C","T"),
        filename=file.path(dataPath,c("C.bam","T.bam")),
        condition=c("Control","Treatment"),
        paired=c("single","single"),stranded=c("forward","forward"))
    path <- tempdir()
    write.table(targets,file=file.path(path,"targets.txt"),
        sep="\t",row.names=FALSE,quote=FALSE)
    geneData <- loadAnnotation("mm9","ensembl","gene")
    myTargets <- readTargets(file.path(path,"targets.txt"))
    if (.Platform$OS.type == "unix") {
        r2c <- read2count(targets=myTargets,
            fileType=myTargets$type,annotation=geneData)
        geneCounts <- r2c$counts
        libsizeList <- r2c$libsize
    }

[Package metaseqR2 version 1.2.0 Index]