experiment-class {ORFik} | R Documentation

## experiment class definition

### Description

It is an object to massivly simplify your coding, by having a table of all libraries of an experiment. That contains filepaths and info for each library in the experiment. It also tries to guess grouping / types / pairs by the file names.
Act as a way of extension of `SummarizedExperiment` by allowing more ease to find not only counts, but rather information about libraries, and annotation, so that more tasks are possible. Like coverage per position in some transcript etc.
## Constructor:
Simplest way to make is to call:
create.experiment(dir)
On some folder with NGS libraries (usually bam files) and see what you get. Some of the fields might be needed to fill in manually. Each resulting row must be unique (not including filepath, they are always unique), that means if it has replicates then that must be said explicit. And all filepaths must be unique and have files with size > 0. Syntax (columns):
libtype (library type): rna-seq, ribo-seq, CAGE etc.
rep (replicate): 1,2,3 etc
condition: WT (wild-type), control, target, mzdicer, starved etc.
fraction: 18, 19 (fractinations), or other ways to split library.
filepath: Full filepath to file

### Details

Special rules:
Supported:
Single/paired end bam, bed, wig, ofst + compressions of these
Paired forward / reverse wig files, must have same name except _forward / _reverse in name
Paired end bam, set pairedEndBam = c(T, T, T, F). For 3 paired end libraries, then one single end.
Naming: Will try to guess naming for tissues / stages, replicates etc. If it finds more than one hit for one file, it will not guess. Always check that it guessed correctly.

### See Also

Other ORFik_experiment: `ORFik.template.experiment()`, `bamVarName()`, `create.experiment()`, `filepath()`, `libraryTypes()`, `organism.df()`, `outputLibs()`, `read.experiment()`, `save.experiment()`, `validateExperiments()`

### Examples

    ## To see an internal ORFik example
    df <- ORFik.template.experiment()
    ## See libraries in experiment
    df
    ## See organism of experiment
    organism.df(df)
    ## See file paths in experiment
    filepath(df, "default")
    ## Output objects in R, to .GlobalEnv
    #outputLibs(df)

    ## This is how to make it:
    ## Not run:
    library(ORFik)

    # 1. Update path to experiment data  directory (bam, bed, wig files etc)
    exp_dir = "/data/processed_data/RNA-seq/Lee_zebrafish_2013/aligned/"

    # 2. Set a 5 character name for experiment, (Lee et al 2013 -> Lee13, etc)
    exper_name = "Lee13"

    # 3. Create a template experiment (gtf and fasta genome)
    temp <- create.experiment(exp_dir, exper_name, saveDir = NULL,
     txdb = "/data/references/Zv9_zebrafish/Danio_rerio.Zv9.79.gtf",
     fa = "/data/references/Zv9_zebrafish/Danio_rerio.Zv9.fa",
     organism = "Homo sapiens")

    # 4. Make sure each row(sample) is unique and correct
    # You will get a view open now, check the data.frame that it is correct:
    # library type (RNA-seq, Ribo-seq), stage, rep, condition, fraction.
    # Let say it did not figure out it is RNA-seq, then we do:"

    temp[5:6, 1] <- "RNA" # [row 5 and 6, col 1] are library types

    # You can also do this in your spread sheet program (excel, libre office)
    # Now save new version, if you did not use spread sheet.
    saveName <- paste0("/data/processed_data/experiment_tables_for_R/",
     exper_name,".csv")
    save.experiment(temp, saveName)

    # 5. Load experiment, this will validate that you actually made it correct
    df <- read.experiment(saveName)

    # Set experiment name not to be assigned in R variable names
    df@expInVarName <- FALSE
    df

    ## End(Not run)

[Package ORFik version 1.8.6 Index]