applyDict: Apply a PGCA dictionary to data files

Description Usage Arguments Details Value See Also Examples

View source: R/utilities.R

Description

Apply the dictionary to the data files and write the translated files to disk.

Usage

1
2
applyDict(..., dict, out.dir = NULL, out.suffix = "", out.prefix = "",
  col.mapping, out.pg.col = "PGC")

Arguments

...

input (see details).

dict

the PGCA dictionary to use.

out.dir

the directory to save the translated files in (see details). If NULL, the translated data frames will be returned directly.

out.suffix, out.prefix

suffix and prefix that will be added to the translated files.

col.mapping

the column mapping for the input files. Defaults to the same as used to build the dictionary.

out.pg.col

the name of the column to store the protein group.

Details

The dictionary is applied to the data specified argument. If no input is provided, the dictionary is applied to the files used to create the dictionary. The inputs can be directory names, file names, or data.framess.

If the output directory out.dir is specified, the translated files will be saved in this directory. Otherwise the files will be written to the same directory as the input files. The function will not overwrite existing files and will fail if the files already exist. Parameters out.suffix and out.prefix can be used to ensure unique new file names. In case the input is a list of data.frames and no output directory is specified, the data.frames will be translated and returned as a list. The function will also return the translated data.frames as list if the out.dir=NULL.

Value

Either a list of data.frames or nothing (see details).

See Also

pgcaDict to create the dictionary

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Build PGCA dictionary from all files in a directory
dict <- pgcaDict(
         system.file("extdata", package="pgca"),
         col.mapping=c(gene.symbol="Gene_Symbol")
)

# Translate all files in the directory and return as a list of data.frames
trans <- applyDict(system.file("extdata", package="pgca"), dict=dict,
                   out.dir=NULL)

# Translate only some files in the directory and return as a list of
# data.frames
trans <- applyDict(
    system.file("extdata", "BET1947_v339.txt", package="pgca"),
    system.file("extdata", "BET2047_v339.txt", package="pgca"),
    dict=dict
)
str(trans)

# Translate all files in the directory and save to another directory
out.dir <- tempdir()
applyDict(system.file("extdata", package="pgca"), dict=dict,
          out.dir=out.dir)

pgca documentation built on Nov. 8, 2020, 8:30 p.m.