aliases: Using aliases to subset virus data

Description Usage Arguments Details Value Functions Examples

Description

Rather than typing out full viruses names or repeating regexpressions, users can use aliases as a convenient tool to subset PhIPData objects by viral species.

Usage

1
2
3
4
5
getAlias(virus)

setAlias(virus, pattern)

deleteAlias(virus)

Arguments

virus

character vector of the alias

pattern

character vector of regexpressions corresponding to the alias

Details

Aliases are cached to an rda file containing only a data.frame with two columns: alias and pattern. The alias column contains the alias while the pattern column contains the corresponding regexpression of interest.

Once an alias is added to the database, it can always be accessed once the package is loaded. It is recommended to use the functions setAlias and deleteAlias. If an alias already exists in the database, setAlias replaces the matched pattern. If an alias does not exist in the database, getAlias returns NA_character_.

Value

getAlias() returns a vector of regexpressions corresponding to queried inputs. The returned vector is the same length as the input vector. Queries that do not exist in the database return NA_character_.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Edit and modify aliases in the database
setAlias("test_virus", "test_pattern")
getAlias("test_virus")
setAlias("test_virus", "test_pattern2")
getAlias("test_virus")
deleteAlias("test_virus")

## Edit and modify multiple aliases at once.
setAlias(c("virus_1", "virus_2"), c("pattern_1", "pattern_2"))
getAlias(c("virus_1", "virus_2"))
deleteAlias(c("virus_1", "virus_2"))

## Example of how to subset HIV using `getAlias`
## Often, it is useful to set the `ignore.case` of `grep`/`grepl` to TRUE.
counts_dat <- matrix(1:10, nrow = 5)
peptide_meta <- data.frame(species = c(
    rep("Epstein-Barr virus", 2),
    rep("human immunodeficiency virus", 3)
))

phip_obj <- PhIPData(counts = counts_dat, peptideInfo = peptide_meta)
subset(phip_obj, grepl(getAlias("HIV"), species, ignore.case = TRUE))

athchen/PhIPData documentation built on Feb. 10, 2022, 1:34 a.m.