outputLibs {ORFik} | R Documentation

## Output NGS libraries to R as variables

### Description

By default loads the original files of the experiment into the global environment, named by the rows of the experiment required to make all libraries have unique names.
Uses multiple cores to load, defined by multicoreParam

### Usage

    outputLibs(
      df,
      chrStyle = NULL,
      type = "default",
      param = NULL,
      strandMode = 0,
      naming = "minimum",
      output.mode = "envir",
      envir = envExp(df),
      BPPARAM = bpparam()
    )

### Arguments

`df` | an ORFik `experiment`
`chrStyle` | a GRanges object, TxDb, FaFile, or a `seqlevelsStyle` (Default: NULL) to get seqlevelsStyle from. Is chromosome 1 called chr1 or 1, is mitocondrial chromosome called MT or chrM etc. Will use 1st seqlevel-style if more are present. Like: c("NCBI", "UCSC") -> pick "NCBI"
`type` | a character(default: "default"), load files in experiment or some precomputed variant, either "ofst", "bedo", "bedoc" or "pshifted". These are made with ORFik:::convertLibs() or shiftFootprintsByExperiment(). Can also be custom user made folders inside the experiments bam folder. It acts in a recursive manner with priority: If you state "pshifted", but it does not exist, it checks "ofst". If no .ofst files, it uses "default", which always exists.
`param` | `NULL` or a ScanBamParam object. Like for `scanBam`, this influences what fields and which records are imported. However, note that the fields specified thru this ScanBamParam object will be loaded in addition to any field required for generating the returned object (GAlignments, GAlignmentPairs, or GappedReads object), but only the fields requested by the user will actually be kept as metadata columns of the object. By default (i.e. `param=NULL` or `param=ScanBamParam()`), no additional field is loaded. The flag used is `scanBamFlag(isUnmappedQuery=FALSE)` for `readGAlignments`, `readGAlignmentsList`, and `readGappedReads`. (i.e. only records corresponding to mapped reads are loaded), and `scanBamFlag(isUnmappedQuery=FALSE, isPaired=TRUE, hasUnmappedMate=FALSE)` for `readGAlignmentPairs` (i.e. only records corresponding to paired-end reads with both ends mapped are loaded).
`strandMode` | numeric, default 0. Only used for paired end bam files. One of (0: strand = *, 1: first read of pair is +, 2: first read of pair is -). See ?strandMode. Note: Sets default to 0 instead of 1, as readGAlignmentPairs uses 1. This is to guarantee hits, but will also make mismatches of overlapping transcripts in opposite directions.
`naming` | a character (default: "minimum"). Name files as minimum information needed to make all files unique. Set to "full" to get full names.
`output.mode` | character, default "envir". Output libraries to environment. Alternative: "list", return as list. "envirlist", output to envir and return as list. If output is list format, the list elements are named from: `bamVarName(df.rfp)` (Full or minimum naming based on 'naming' argument)
`envir` | environment to save to, default `envExp(df)`, which defaults to .GlobalEnv
`BPPARAM` | how many cores/threads to use? default: bpparam(). To see number of threads used, do `bpparam()$workers`. You can also add a time remaining bar, for a more detailed pipeline.

### Value

NULL (libraries set by envir assignment), unless output.mode is "list" or "envirlist": Then you get a list of the libraries.

### See Also

Other ORFik_experiment: `ORFik.template.experiment.zf()`, `ORFik.template.experiment()`, `bamVarName()`, `create.experiment()`, `experiment-class`, `filepath()`, `libraryTypes()`, `organism,experiment-method`, `read.experiment()`, `save.experiment()`, `validateExperiments()`

### Examples

    ## Load a template ORFik experiment
    df <- ORFik.template.experiment()
    ## Default library type load, usually bam files
    # outputLibs(df, type = "default")
    ## .ofst file load, if ofst files does not exists
    ## it will load default
    # outputLibs(df, type = "ofst")
    ## .wig file load, if wiggle files does not exists
    ## it will load default
    # outputLibs(df, type = "wig")
    ## Load as list
    outputLibs(df, output.mode = "list")
    ## Load libs to new environment (called ORFik in Global)
    # outputLibs(df, envir = assign(name(df), new.env(parent = .GlobalEnv)))
    ## Load to hidden environment given by experiment
    # envExp(df) <- new.env()
    # outputLibs(df)

[Package ORFik version 1.14.7 Index]