aliases {PhIPData} | R Documentation |
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.
getAliasPath() setAliasPath(path) getAlias(virus) setAlias(virus, pattern) deleteAlias(virus)
path |
path to |
virus |
character vector of the alias |
pattern |
character vector of regexpressions corresponding to the alias |
Aliases are saved 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.
The location of the alias database is returned and defined by
getAliasPath
and setAliasPath
, respectively. By default
getAliasPath
points to the extdata
package folder.
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
to edit the alias database rather than modify the
.rda file itself. 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_
.
getAliasPath()
returns the path to the alias database.
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_
.
getAliasPath
: return the path to the .rda file of aliases.
setAliasPath
: set the path to the .rda file of aliases.
getAlias
: return a regexpression corresponding to the alias.
setAlias
: define/modify the regexpression for an alias.
deleteAlias
: remove an alias from the database.
## Get and set path to alias.rda getAliasPath() ## Not run: setAliasPath("examplepath/alias.rda") ## End(Not run) ## 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))