annotations_matrix {act} | R Documentation |
Search and replace contents of annotations using a matrix
Description
This functions performs a search and replace in the contents of an annotation. A simple matrix consisting of two columns will be used. The first column of the matrix needs to contain the search string, the second column the replacement string. The matrix needs to be in CSV format.
Usage
annotations_matrix(x, path_replacementMatrixCSV, filterTranscriptNames = NULL)
Arguments
x |
Corpus object. |
path_replacementMatrixCSV |
Character string; path to replacement matrix (a CSV file). |
filterTranscriptNames |
Vector of character strings; names of the transcripts to be included. |
Value
Corpus object.
See Also
matrix_load()
for loading the matrix
and matrix_save()
for saving the matrix to a CSV file.
If only certain transcripts or tiers should be affected set the parameter filterTranscriptNames
.
In case that you want to select transcripts by using regular expressions use the function act::search_makefilter
first.
media_delete, media_getPathToExistingFile
Examples
library(act)
# An example replacement matrix comes with the package.
# It replaces most of the GAT conventions.
path <- system.file("extdata", "normalization", "normalizationMatrix.csv", package="act")
# Have a look at the matrix
mymatrix <- act::matrix_load(path)
mymatrix
# Apply matrix to examplecorpus
test <- act::annotations_matrix(x=examplecorpus, path_replacementMatrixCSV=path)
# Compare some annotations in the original examplecorpus object and
# in the modified corpus object test
examplecorpus@transcripts[[1]]@annotations$content[[1]]
test@transcripts[[1]]@annotations$content[[1]]
examplecorpus@transcripts[[2]]@annotations$content[[3]]
test@transcripts[[2]]@annotations$content[[3]]