countTable {ORFik} | R Documentation

## Extract count table directly from experiment

### Description

Used to quickly load read count tables to R.

### Usage

    countTable(df, region = "mrna", type = "count", collapse = FALSE)

### Arguments

`df` | an ORFik `experiment` or path to folder with countTable, use path if not same folder as experiment libraries.
`region` | a character vector (default: "mrna"), make raw count matrices of whole mrnas or one of (leaders, cds, trailers).
`type` | default: "count" (raw counts matrix), alternative is "fpkm", "log2fpkm" or "log10fpkm"
`collapse` | a logical/character (default FALSE), if TRUE all samples within the group SAMPLE will be collapsed to one. If "all", all groups will be merged into 1 column called merged_all. Collapse is defined as rowSum(elements_per_group) / ncol(elements_per_group)

### Details

If df is experiment: Extracts by getting /QC_STATS directory, and searching for region Requires `ORFikQC` to have been run on experiment!

If df is path to folder: Loads the the file in that directory with the regex region.rds, where region is what is defined by argument.

### Value

a data.table of columns as counts per library, column name is name of library. Rownames must be unique for now. Might change.

### Examples

    # 1. Pick directory
    dir <- system.file("extdata", "", package = "ORFik")
    # 2. Pick an experiment name
    exper <- "ORFik"
    # 3. Pick .gff/.gtf location
    txdb <- system.file("extdata", "annotations.gtf", package = "ORFik")
    template <- create.experiment(dir = dir, exper, txdb = txdb,
                                  viewTemplate = FALSE)
    template$X5[6] <- "heart" # <- fix non unique row
    # read experiment
    df <- read.experiment(template)
    # Make QC report to get counts ++
    # ORFikQC(df)

    # Get count Table of mrnas
    # countTable(df, "mrna")
    # Get count Table of cds
    # countTable(df, "cds")
    # Get count Table of mrnas as fpkm values
    # countTable(df, "mrna", type = "count")
    # Get count Table of mrnas with collapsed replicates
    # countTable(df, "mrna", collapse = TRUE)

[Package ORFik version 1.6.9 Index]