Title: | Antigenic Cartography Macros |
---|---|
Description: | A toolkit for making antigenic maps from immunological assay data, in order to quantify and visualize antigenic differences between different pathogen strains as described in Smith et al. (2004) <doi:10.1126/science.1097211> and used in the World Health Organization influenza vaccine strain selection process. Additional functions allow for the diagnostic evaluation of antigenic maps and an interactive viewer is provided to explore antigenic relationships amongst several strains and incorporate the visualization of associated genetic information. |
Authors: | Sam Wilks [aut, cre] |
Maintainer: | Sam Wilks <[email protected]> |
License: | AGPL-3 |
Version: | 1.2.9 |
Built: | 2024-11-25 07:05:50 UTC |
Source: | CRAN |
This function generates a new acmap object, the base object for storing map data in the Racmacs package.
acmap( ag_names = NULL, sr_names = NULL, titer_table = NULL, ag_coords = NULL, sr_coords = NULL, check_duplicates = TRUE, ... )
acmap( ag_names = NULL, sr_names = NULL, titer_table = NULL, ag_coords = NULL, sr_coords = NULL, check_duplicates = TRUE, ... )
ag_names |
Antigen names |
sr_names |
Sera names |
titer_table |
Table of titer data |
ag_coords |
Antigenic coordinates for an optimization run record (optional) |
sr_coords |
Sera coordinates for an optimization run record (optional) |
check_duplicates |
Issue a warning if duplicate antigen or sera names are found |
... |
Further arguments passed to |
The fundamental unit of the Racmacs package is the acmap
object,
short for Antigenic Cartography MAP. This object contains all the
information about an antigenic map. You can read in a new acmap object from
a file with the function read.acmap()
and create a new acmap object
within an R session using the acmap()
function.
Returns the new acmap object
See optimizeMap()
for generating new optimizations estimating
antigen similarity from the acmap titer data.
Other functions for working with map data:
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Functions to get various attributes about an acmap object.
numAntigens(map) numSera(map) numSeraGroups(map) numPoints(map) numOptimizations(map) numLayers(map)
numAntigens(map) numSera(map) numSeraGroups(map) numPoints(map) numOptimizations(map) numLayers(map)
map |
The acmap data object |
A number relating to the attribute
Other map attribute functions:
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
Function to add a new optimization to an acmap object, with specified values.
addOptimization( map, ag_coords = NULL, sr_coords = NULL, number_of_dimensions = NULL, minimum_column_basis = "none", fixed_column_bases = NULL, ag_reactivity_adjustments = NULL )
addOptimization( map, ag_coords = NULL, sr_coords = NULL, number_of_dimensions = NULL, minimum_column_basis = "none", fixed_column_bases = NULL, ag_reactivity_adjustments = NULL )
map |
The acmap data object |
ag_coords |
Antigen coordinates for the new optimization (0 if not specified) |
sr_coords |
Sera coordinates for the new optimization (0 if not specified) |
number_of_dimensions |
The number of dimensions of the new optimization |
minimum_column_basis |
The minimum column basis to use for the new optimization |
fixed_column_bases |
A vector of fixed column bases with NA for sera where the minimum column basis should be applied |
ag_reactivity_adjustments |
A vector of antigen reactivity adjustments to apply to each antigen. Corresponding antigen titers will be adjusted by these amounts when calculating column bases and table distances. |
Returns the acmap data object with new optimization added (but not selected).
Other functions for working with map data:
acmap()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Return the log titer table plus any antigen reactivity adjustments.
adjustedLogTiterTable(map, optimization_number = 1)
adjustedLogTiterTable(map, optimization_number = 1)
map |
An acmap object |
optimization_number |
The optimization number from which to take any antigen reactivity adjustments |
A numeric matrix of adjusted log titers.
Other map attribute functions:
acmapAttributes
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
Return the titer table plus any antigen reactivity adjustments.
adjustedTiterTable(map, optimization_number = 1)
adjustedTiterTable(map, optimization_number = 1)
map |
An acmap object |
optimization_number |
The optimization number from which to take any antigen reactivity adjustments |
A character matrix of titers.
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
These functions get and set the antigen attributes for a map.
agIDs(map) agIDs(map) <- value agDates(map) agDates(map) <- value agReference(map) agReference(map) <- value agNames(map) agNames(map) <- value agExtra(map) agExtra(map) <- value agPassage(map) agPassage(map) <- value agLineage(map) agLineage(map) <- value agReassortant(map) agReassortant(map) <- value agStrings(map) agStrings(map) <- value agContinent(map) agContinent(map) <- value
agIDs(map) agIDs(map) <- value agDates(map) agDates(map) <- value agReference(map) agReference(map) <- value agNames(map) agNames(map) <- value agExtra(map) agExtra(map) <- value agPassage(map) agPassage(map) <- value agLineage(map) agLineage(map) <- value agReassortant(map) agReassortant(map) <- value agStrings(map) agStrings(map) <- value agContinent(map) agContinent(map) <- value
map |
The acmap data object |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
srAttributes()
Other antigen and sera attribute functions:
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
Checks the vertex connectivity of points in a map (the minimum number of
points needed to remove from the map to eliminate all paths from one point to
another point). This is for checking for example if after merging maps you
only have a small number of points in common between separate groups of
points, leading to a situation where groups of points cannot be robustly
positioned relative to each other. If the vertex connectivity is smaller than
the number of map dimensions + 1 then this will certainly be occurring and
will lead to an unstable map solution. mapCohesion()
returns the minimum
vertex connectivity found between any given points, while agCohesion()
and
srCohesion()
return the vertex connectivity between each pair of antigens
and sera as a table helping to diagnose which antigens and sera are forming
separate groups. Note that for these purposes only detectable titers count
as connections and non-detectable titers are ignored.
agCohesion(map) srCohesion(map) mapCohesion(map)
agCohesion(map) srCohesion(map) mapCohesion(map)
map |
An acmap object |
A scalar real value.
Other map diagnostic functions:
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
These functions get and set the antigen groupings for a map.
agGroups(map) agGroups(map) <- value
agGroups(map) agGroups(map) <- value
map |
The acmap object |
value |
A character or factor vector of groupings to apply to the antigens |
A factor vector of groupings.
Other antigen and sera attribute functions:
agAttributes
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
Gets the indices of homologous sera for each antigen in an antigenic map.
See also the function srHomologousAgs()
for getting and setting the
homologous antigens reciprocally.
agHomologousSr(map)
agHomologousSr(map)
map |
An acmap object |
A list, where each entry is a vector of indices for homologous sera, or a length 0 vector where no homologous serum is present
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
Getting and setting antigen lab id information
agLabIDs(map) agLabIDs(map) <- value
agLabIDs(map) agLabIDs(map) <- value
map |
The acmap data object |
value |
A list of character vectors with lab ids information for each point |
A character vector of antigen laboratory IDs
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
Get and set antigen reactivity adjustments
agReactivityAdjustments(map) agReactivityAdjustments(map) <- value
agReactivityAdjustments(map) agReactivityAdjustments(map) <- value
map |
The acmap object |
value |
A vector of antigen reactivity adjustments to apply |
A numeric vector of antigen reactivity adjustments
Other functions for working with map data:
acmap()
,
addOptimization()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Getting and setting antigen sequence information
agSequences(map, missing_value = ".") agSequences(map) <- value agNucleotideSequences(map, missing_value = ".") agNucleotideSequences(map) <- value
agSequences(map, missing_value = ".") agSequences(map) <- value agNucleotideSequences(map, missing_value = ".") agNucleotideSequences(map) <- value
map |
The acmap data object |
missing_value |
Character to use to fill in portions of the sequence matrix where sequence data is missing. |
value |
A character matrix of sequences with rows equal to the number of antigens |
A character matrix of sequences, where each row represents an antigen.
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
Applies the map transformation associated with a selected optimization run to a set of coordinates.
applyMapTransform(coords, map, optimization_number = 1)
applyMapTransform(coords, map, optimization_number = 1)
coords |
Coordinates to transform |
map |
The acmap object |
optimization_number |
The optimization number |
An acmap object with transformation applied
Other functions relating to map transformation:
reflectMap()
,
rotateMap()
,
translateMap()
Copy point style from matching antigens and sera in another acmap
applyPlotspec(map, source_map)
applyPlotspec(map, source_map)
map |
The acmap object |
source_map |
An acmap object from which to copy point styles |
Returns the acmap object with updated point styles (unmatched point styles unchanged)
Other map point style functions:
ptDrawingOrder()
,
ptOpacity
,
ptStyles
Convert map to json format
as.json(map, pretty = FALSE, round_titers = FALSE)
as.json(map, pretty = FALSE, round_titers = FALSE)
map |
The map data object |
pretty |
Should json be output prettily with new lines and indentation? |
round_titers |
Should titers be rounded to the nearest integer before outputting |
Returns map data as .ace json format
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Plot a blob object such as that return from agBootstrapBlob()
using the
polygon()
function.
blob(x, col, border, lwd, alpha = 1, ...)
blob(x, col, border, lwd, alpha = 1, ...)
x |
The blob object to plot |
col |
Color for the blob fill |
border |
Color for the blob outline |
lwd |
Line width for the blob outline |
alpha |
Blob opacity |
... |
Additional arguments to pass to |
No return value, called for the side effect of plotting the blobs.
Other additional plotting functions:
blobsize()
Returns either the area (for 2D blobs) or volume (for 3D blobs)
blobsize(blob)
blobsize(blob)
blob |
The blob object |
A numeric vector
Other additional plotting functions:
blob()
This function takes a map for which the function bootstrapMap()
has already
been applied and draws contour blobs for each point illustrating how point
position varies in each bootstrap repeat. The blobs are calculated using
kernal density estimates according to these point distribution and drawn
so as to encompass a given proportion of this variation according to the
parameter conf.level
. A conf.level
set at 0.95 for example will draw
blobs that are calculated to encompass 95% of the positional variation seen
in the bootstrap repeats. Note however that the accuracy of these estimates
will depend on the number of bootstrap repeats performed, for example whether
100 or 1000 repeats were performed in the initial calculations using
bootstrapMap()
.
bootstrapBlobs( map, conf.level = 0.68, smoothing = 6, gridspacing = 0.25, antigens = TRUE, sera = TRUE, method = "ks" )
bootstrapBlobs( map, conf.level = 0.68, smoothing = 6, gridspacing = 0.25, antigens = TRUE, sera = TRUE, method = "ks" )
map |
The acmap data object |
conf.level |
The proportion of positional variation captured by each blob |
smoothing |
The amount of smoothing to perform when performing the kernel density estimate, larger equates to more smoothing |
gridspacing |
grid spacing to use when calculating blobs, smaller values will produce more accurate blobs with smoother edges but will take longer to calculate. |
antigens |
Should blobs be calculated for antigens |
sera |
Should blobs be calculated for sera |
method |
One of "MASS", the default, or "ks", specifying the algorithm to use when calculating blobs in 2D. 3D will always use ks::kde. |
Returns an acmap object that will then show the corresponding bootstrap blobs when viewed or plotted.
Other map diagnostic functions:
agCohesion()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
This function takes the map and original titer table, and performs a version of bootstrapping defined by the method argument. For each bootstrap run this process is performed and a record of the coordinates of points in the lowest stress solution is kept. See details for a description of the bootstrapping methods you can apply.
bootstrapMap( map, method, bootstrap_repeats = 1000, bootstrap_ags = TRUE, bootstrap_sr = TRUE, reoptimize = TRUE, optimizations_per_repeat = 100, ag_noise_sd = 0.7, titer_noise_sd = 0.7, options = list() )
bootstrapMap( map, method, bootstrap_repeats = 1000, bootstrap_ags = TRUE, bootstrap_sr = TRUE, reoptimize = TRUE, optimizations_per_repeat = 100, ag_noise_sd = 0.7, titer_noise_sd = 0.7, options = list() )
map |
The map object |
method |
One of "resample", "bayesian" or "noisy" (see details) |
bootstrap_repeats |
The number of bootstrap repeats to perform |
bootstrap_ags |
For "resample" and "bayesian" methods, whether to apply bootstrapping across antigens |
bootstrap_sr |
For "resample" and "bayesian" methods, whether to apply bootstrapping across sera |
reoptimize |
Should the whole map be reoptimized with each bootstrap run. If FALSE, the map is simply relaxed from it's current optimization with each run. |
optimizations_per_repeat |
When re-optimizing the map from scratch, the number of optimization runs to perform |
ag_noise_sd |
The standard deviation (on the log titer scale) of measurement noise applied per antigen when using the "noisy" method |
titer_noise_sd |
The standard deviation (on the log titer scale) of measurement noise applied per titer when using the "noisy" method |
options |
Map optimizer options, see |
"resample": The resample bootstrap is the most standard bootstrap method, a random resample of the titer table data is taken with replacement. Depending on your specification, resampling is applied across either individual antigens, individual sera or both antigens and sera. In essence this method tries to let you see how robust the map is to inclusion of particular titer measurements or antigens or sera. Like most bootstrapping techniques it will prove give more reliable results the more antigens and sera you have in your map. It won't work very well for a map of 5 sera and antigens for example, in this case a "noisy" bootstrap may be better.
"bayesian": The bayesian bootstrap is akin to the resampling bootstrap, but rather than explicitly resampling data, weights are assigned to each part of the titer table data according to random draws from a dirichilet distribution. Under this scheme, every data point will play at least some role in making the map, even if only weighted slightly. Sometimes this is helpful, if you know for example that the points in your map are highly dependent upon the presence of a few antigens / sera / titers to achieve reasonable triangulation of point positions and you don't really want to risk removing them completely and ending up with bootstrap runs that are under-constrained, you might want to consider this approach. On the other hand this might be exactly what you don't want and you want to know uncertainty that can be generated when certain subsets of the data are excluded completely, in that case you probably want to stick with the "resample" method.
"noisy":
The noisy bootstrap, sometimes termed a
smooth bootstrap
involved adding normally distributed noise to each observation. The distribution of this noise can
be parameterised through the ag_noise_sd
and titer_noise_sd
arguments. titer_noise_sd
refers to the
standard deviation (on the log scale) of noise added to each individual titer measurement in the table,
while antigen_noise_sd
refers to the standard deviation of noise applied to titers for each antigen.
The reason for this distinction is that we have noticed with repeat measurements of influenza data there
is often both a random noise per titer and a random noise per antigen, i.e. in one repeat titers may all
be around one 2-fold higher on average, in addition to unbiased additional titer noise. If you wish to only
simulate additional noise per titer and not a per antigen effect, simply set antigen_noise_sd
to 0. Note
that in order to use this most effectively it is best to have an idea of the amount and type of measurement
noise you may expect in your data and set these parameters accordingly.
Returns the map object updated with bootstrap information
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Check for hemisphering or trapped points
checkHemisphering( map, optimization_number = 1, grid_spacing = 0.25, stress_lim = 0.1, options = list() )
checkHemisphering( map, optimization_number = 1, grid_spacing = 0.25, stress_lim = 0.1, options = list() )
map |
The acmap data object |
optimization_number |
The map optimization number |
grid_spacing |
When doing a grid search of more optimal point positions the grid spacing to use |
stress_lim |
The stress difference to use when classifying a point as "hemisphering" or not |
options |
A named list of options to pass to |
Returns a data frame with information on any points that were found to be hemisphering or trapped.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Functions to get and set column bases specified for an optimization run, either through the minimum column basis or through a vector of specified column bases.
minColBasis(map, optimization_number = 1) minColBasis(map, optimization_number = 1) <- value fixedColBases(map, optimization_number = 1) fixedColBases(map, optimization_number = 1) <- value
minColBasis(map, optimization_number = 1) minColBasis(map, optimization_number = 1) <- value fixedColBases(map, optimization_number = 1) fixedColBases(map, optimization_number = 1) <- value
map |
The acmap data object |
optimization_number |
The optimization run from which to get / set the data |
value |
New value to set |
In general a map can have column bases that are specified either
through a minimum column basis or a vector of fixed column bases for each
sera. When you call minColBasis()
, it will return the minimum column
basis if it has been set, or "fixed" if column bases have instead been
fixed directly. The colBases()
function will return the column bases as
calculated for a given optimization run. Setting column bases through this
function with colBases()<-
will fix the column bases to the supplied
vector of values.
Note that although the output from colBases()
might be the same in a case
where a minimum column basis was set or a case where column bases were set
explicitly, when a minimum column basis is set, the column bases will still
depend on the log titers recorded against a given sera, so changing the
titers may therefore change the actual column bases calculated. For fixed
column bases case, column bases will remain fixed at their values
independently of measured titers.
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
Other map optimization attribute functions:
mapComment()
,
mapDimensions()
,
mapStress()
,
mapTransformation()
,
ptBaseCoords()
,
ptCoords()
These functions still work but have been deprecated in favour of another function. Arguments will be passed onto the new function with a warning.
stressBlobs(...)
stressBlobs(...)
... |
Arguments to pass to the new function |
Values from the new function
This defaults to 1 but can be changed using this function with knock-on effects for how < values are treated when maps are optimized or relaxed and the way stress is calculated, see details.
dilutionStepsize(map) dilutionStepsize(map) <- value
dilutionStepsize(map) dilutionStepsize(map) <- value
map |
The acmap object from which to get or set the dilution stepsize |
value |
The dilution stepsize value to set |
Antigenic cartography was originally developed for HI titers which typically follow a 2-fold dilution series starting from 1/10, then 1/20, 1/40 etc. This represents a "dilution stepsize" of 1 when converted to the log2 scale. When no inhibition was recorded at the highest dilution, the value is typically recorded as <10 but the optimization regime effectively treats this as a <=5, the rationale being that, had the dilution series been continued to higher concentrations, the next lowest titer would have been a 5. Over time the method has also been applied to other neutralization assays that sometimes have a continuous read out with a lower end, in these cases a <10 really means a <10 since any other values like 9.8 or 7.62 would also be possible. To indicate these continuous cases, you can specify the dilution stepsize as 0. Equally, if the dilution regime followed a different pattern, you can also set that here.
A number giving the current dilution stepsize setting for a map.
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
Take a map object and perform cross-validation, seeing how well titers are predicted when they are excluded from the map.
dimensionTestMap( map, dimensions_to_test = 1:5, test_proportion = 0.1, minimum_column_basis = "none", fixed_column_bases = rep(NA, numSera(map)), number_of_optimizations = 1000, replicates_per_dimension = 100, options = list() )
dimensionTestMap( map, dimensions_to_test = 1:5, test_proportion = 0.1, minimum_column_basis = "none", fixed_column_bases = rep(NA, numSera(map)), number_of_optimizations = 1000, replicates_per_dimension = 100, options = list() )
map |
The acmap data object |
dimensions_to_test |
A numeric vector of dimensions to be tested |
test_proportion |
The proportion of data to be used as the test set for each test run |
minimum_column_basis |
The minimum column basis to use |
fixed_column_bases |
A vector of fixed column bases with NA for sera where the minimum column basis should be applied |
number_of_optimizations |
The number of optimizations to perform when creating each map for the dimension test |
replicates_per_dimension |
The number of tests to perform per dimension tested |
options |
Map optimizer options, see |
For each run, the ag-sr titers that were randomly excluded are predicted according to their relative positions in the map trained without them. An RMSE is then calculated by comparing predicted titers inferred from the map on the log scale to the actual log titers. This is done separately for detectable titers (e.g. 40) and non-detectable titers (e.g. <10). For non-detectable titers, if the predicted titer is the same or lower than the log-titer threshold, the error is set to 0.
Returns a data frame with the following columns. "dimensions" : the dimension tested, "mean_rmse_detectable" : mean prediction rmse for detectable titers across all runs. "var_rmse_detectable" the variance of the prediction rmse for detectable titers across all runs, useful for estimating confidence intervals. "mean_rmse_nondetectable" and "var_rmse_nondetectable" the equivalent for non-detectable titers
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Edit antigen names in an acmap
edit_agNames(map, old_names, new_names)
edit_agNames(map, old_names, new_names)
map |
The map data object to be updated |
old_names |
Old names to be replaced |
new_names |
Replacement for old names |
Returns the acmap object with antigen names updated.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Edit sera names in an acmap
edit_srNames(map, old_names, new_names)
edit_srNames(map, old_names, new_names)
map |
The map data object to be updated |
old_names |
Old names to be replaced |
new_names |
Replacement for old names |
Returns the acmap object with sera names updated.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Export a map in a standalone html viewer
export_viewer(map, file, selfcontained = TRUE, ...)
export_viewer(map, file, selfcontained = TRUE, ...)
map |
The acmap object |
file |
File to save HTML into |
selfcontained |
Whether to save the HTML as a single self-contained file (with external resources base64 encoded) or a file with external resources placed in an adjacent directory. |
... |
Further parameters to |
Called for the side effect of saving the viewer to an html file but invisibly returns the map viewer htmlwidget.
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view.default()
,
view()
Gets the details associated with the currently selected or specified acmap optimization as a list.
getOptimization(map, optimization_number = 1)
getOptimization(map, optimization_number = 1)
map |
The acmap data object |
optimization_number |
The optimization data to access |
Returns a list with information about the optimization
See listOptimizations()
for getting information about all
optimizations.
Method for plotting an antigenic map as a ggplot object
## S3 method for class 'acmap' ggplot( data = NULL, mapping = NULL, optimization_number = 1, xlim = NULL, ylim = NULL, plot_ags = TRUE, plot_sr = TRUE, plot_blobs = TRUE, plot_hemisphering = TRUE, show_procrustes = TRUE, show_error_lines = FALSE, plot_stress = FALSE, indicate_outliers = "arrowheads", grid.col = "grey90", grid.lwd = 0.5, grid.margin.col = "grey50", grid.margin.lwd = grid.lwd, fill.alpha = 0.8, outline.alpha = 0.8, padding = 1, arrow_angle = 25, arrow_length = 0.2, margins = rep(0.5, 4), ..., environment = NULL )
## S3 method for class 'acmap' ggplot( data = NULL, mapping = NULL, optimization_number = 1, xlim = NULL, ylim = NULL, plot_ags = TRUE, plot_sr = TRUE, plot_blobs = TRUE, plot_hemisphering = TRUE, show_procrustes = TRUE, show_error_lines = FALSE, plot_stress = FALSE, indicate_outliers = "arrowheads", grid.col = "grey90", grid.lwd = 0.5, grid.margin.col = "grey50", grid.margin.lwd = grid.lwd, fill.alpha = 0.8, outline.alpha = 0.8, padding = 1, arrow_angle = 25, arrow_length = 0.2, margins = rep(0.5, 4), ..., environment = NULL )
data |
The acmap to plot |
mapping |
Default list of aesthetic mappings to use for plot, not currently used |
optimization_number |
The optimization number to plot |
xlim |
optional x axis limits |
ylim |
optional y axis limits |
plot_ags |
logical, should antigens be plotted |
plot_sr |
logical, should antigens be plotted |
plot_blobs |
logical, should stress blobs be plotted if present |
plot_hemisphering |
logical, should hemisphering points be indicated, if
tested for already with |
show_procrustes |
logical, should procrustes lines be shown, if present |
show_error_lines |
logical, should error lines be drawn |
plot_stress |
logical, should map stress be plotted in lower left corner |
indicate_outliers |
how should points outside the plotting region be indicated, either FALSE, for not shown, or "arrowheads" for small arrowheads like in the viewer. |
grid.col |
grid line color |
grid.lwd |
grid line width |
grid.margin.col |
grid margin color |
grid.margin.lwd |
grid margin line width |
fill.alpha |
alpha for point fill |
outline.alpha |
alpha for point outline |
padding |
padding at limits of the antigenic map, ignored if xlim or ylim set explicitly |
arrow_angle |
angle of arrow heads drawn for procrustes lines |
arrow_length |
length of arrow heads drawn for procrustes lines in cm |
margins |
margins in inches for the plot |
... |
additional arguments, not used |
environment |
not used |
Returns the ggplot plot
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view.default()
,
view()
Prints an html formatted titer table, visualising with colors things like which titers are the maximum for each sera.
htmlAdjustedTiterTable(map, optimization_number = 1)
htmlAdjustedTiterTable(map, optimization_number = 1)
map |
An acmap object |
optimization_number |
The optimization number from which to take the antigen reactivity adjustments. |
A list() with a Rac_html_merge_report and shiny.tag class that can be converted into an HTML string via as.character() and saved to a file with save_html().
Prints an html formatted table merge report of a set of merged maps, visualising with colors how different titers have been merged together.
htmlMergeReport(map)
htmlMergeReport(map)
map |
An acmap object that was the result of merging several maps |
A list() with a Rac_html_merge_report and shiny.tag class that can be converted into an HTML string via as.character() and saved to a file with save_html().
Other map merging functions:
RacMerge.options()
,
mergeMaps()
,
mergeReport()
,
splitTiterLayers()
Prints an html formatted titer table, visualising with colors things like which titers are the maximum for each sera.
htmlTiterTable(map)
htmlTiterTable(map)
map |
An acmap object |
A list() with a Rac_html_merge_report and shiny.tag class that can be converted into an HTML string via as.character() and saved to a file with save_html().
htmlAdjustedTiterTable
Keep only the lowest stress map optimization
keepBestOptimization(map)
keepBestOptimization(map)
map |
The acmap object |
An acmap object with only the lowest stress optimization kept
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Keep only data from specified optimization runs.
keepOptimizations(map, optimization_numbers)
keepOptimizations(map, optimization_numbers)
map |
The acmap object |
optimization_numbers |
Optimizations to keep |
Returns the updated acmap object
Other functions to work with map optimizations:
optimizationProperties
,
removeOptimizations()
,
sortOptimizations()
Keep only a single optimization run
keepSingleOptimization(map, optimization_number = 1)
keepSingleOptimization(map, optimization_number = 1)
map |
The acmap object |
optimization_number |
The optimization run to keep |
An acmap object with only one optimization kept
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Get and set map layer names
layerNames(map) layerNames(map) <- value
layerNames(map) layerNames(map) <- value
map |
The acmap object |
value |
A vector of new layer names to apply to the map |
A character vector of layer names
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Gets the details associated with the all the optimizations of an acmap object as a list.
listOptimizations(map)
listOptimizations(map)
map |
The acmap data object |
Returns a list of lists with information about the optimizations
See getOptimization()
for getting information about a single
optimization.
Converts titers to the log scale via via the transformation $log2(x/10)$, lessthan values are reduced by 1 on the log scale and greater than values are increased by 1, hence <10 => -1 and >1280 => 8
logtiterTable(map)
logtiterTable(map)
map |
The acmap object |
Returns a matrix of titers converted to the log scale
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
mapDistances()
,
mapResiduals()
,
pointStress
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
Return a list of logtiter table layers
logtiterTableLayers(map)
logtiterTableLayers(map)
map |
An acmap data object |
A list of numeric matrices with logtiter values
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
This is a wrapper function for first making a map with table data then,
running optimizations to make the map otherwise done with acmap()
followed by optimizeMap()
.
make.acmap( titer_table = NULL, ag_names = NULL, sr_names = NULL, number_of_dimensions = 2, number_of_optimizations = 100, minimum_column_basis = "none", fixed_column_bases = NULL, sort_optimizations = TRUE, check_convergence = TRUE, verbose = TRUE, options = list(), ... )
make.acmap( titer_table = NULL, ag_names = NULL, sr_names = NULL, number_of_dimensions = 2, number_of_optimizations = 100, minimum_column_basis = "none", fixed_column_bases = NULL, sort_optimizations = TRUE, check_convergence = TRUE, verbose = TRUE, options = list(), ... )
titer_table |
A table of titer data |
ag_names |
A vector of antigen names |
sr_names |
A vector of sera names |
number_of_dimensions |
The number of dimensions in the map |
number_of_optimizations |
The number of optimization runs to perform |
minimum_column_basis |
The minimum column basis for the map |
fixed_column_bases |
A vector of fixed values to use as column bases directly, rather than calculating them from the titer table. |
sort_optimizations |
Should optimizations be sorted by stress afterwards? |
check_convergence |
Should a basic check for convergence of lowest stress optimization runs onto a similar solution be performed. |
verbose |
Should progress messages be reported, see also
|
options |
List of named optimizer options, see |
... |
Further arguments to pass to |
Returns an acmap object that has optimization run results.
Other map optimization functions:
RacOptimizer.options()
,
moveTrappedPoints()
,
optimizeMap()
,
randomizeCoords()
,
relaxMapOneStep()
,
relaxMap()
Plot map vs table distances
plot_map_table_distance( map, optimization_number = 1, xlim, ylim, line_of_equality = TRUE ) plotly_map_table_distance( map, optimization_number = 1, xlim, ylim, line_of_equality = TRUE )
plot_map_table_distance( map, optimization_number = 1, xlim, ylim, line_of_equality = TRUE ) plotly_map_table_distance( map, optimization_number = 1, xlim, ylim, line_of_equality = TRUE )
map |
The acmap data object |
optimization_number |
The optimization number from which to take map and table distances |
xlim |
The x limits of the plot |
ylim |
The y limits of the plot |
line_of_equality |
Should the line x=y be added |
Returns the ggplot2 object
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
This can be used to get information about the bootstrap run results
after bootstrapMap()
has been run.
mapBootstrap_ptBaseCoords(map) mapBootstrap_agCoords(map) mapBootstrap_srCoords(map)
mapBootstrap_ptBaseCoords(map) mapBootstrap_agCoords(map) mapBootstrap_srCoords(map)
map |
The map object |
Returns a list of coordinate matrices for the points in each of the bootstrap runs
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Get or set an optimization run comment
mapComment(map, optimization_number = 1) mapComment(map, optimization_number = 1) <- value
mapComment(map, optimization_number = 1) mapComment(map, optimization_number = 1) <- value
map |
The acmap data object |
optimization_number |
The optimization run from which to get / set the data |
value |
New value to set |
Gets or sets map comments for the optimization run.
Other map optimization attribute functions:
colBases()
,
mapDimensions()
,
mapStress()
,
mapTransformation()
,
ptBaseCoords()
,
ptCoords()
Getting and setting the map description
mapDescription(map) mapDescription(map) <- value
mapDescription(map) mapDescription(map) <- value
map |
The acmap data object |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
Get the current map dimensions
mapDimensions(map, optimization_number = 1)
mapDimensions(map, optimization_number = 1)
map |
The acmap data object |
optimization_number |
The optimization run from which to get / set the data |
Returns the number of dimensions for the optimization run.
Other map optimization attribute functions:
colBases()
,
mapComment()
,
mapStress()
,
mapTransformation()
,
ptBaseCoords()
,
ptCoords()
Takes the acmap object and calculates euclidean distances between antigens and sera for the currently selected or specified optimization.
mapDistances(map, optimization_number = 1)
mapDistances(map, optimization_number = 1)
map |
The acmap data object |
optimization_number |
The optimization number |
Returns a matrix of map distances with antigens as rows and sera as columns.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapResiduals()
,
pointStress
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
This function is equivalent to running runGUI()
and loading a map file, but this
takes the acmap object to open as an input argument.
mapGadget(map)
mapGadget(map)
map |
The acmap object to open in the GUI |
No value returned, called for the side effect of starting the gadget.
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view.default()
,
view()
Getting and setting the map name
mapName(map) mapName(map) <- value
mapName(map) mapName(map) <- value
map |
The acmap data object |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
titerTableFlat()
,
titerTableLayers()
,
titerTable()
Checks if the map optimization run can be relaxed further.
mapRelaxed(map, optimization_number = 1, options = list())
mapRelaxed(map, optimization_number = 1, options = list())
map |
The acmap data object |
optimization_number |
The map optimization number |
options |
List of named optimizer options, see |
Returns TRUE or FALSE
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
This is the difference between the table distance and the map distance
mapResiduals(map, exclude_nd = FALSE, optimization_number = 1)
mapResiduals(map, exclude_nd = FALSE, optimization_number = 1)
map |
The acmap object |
exclude_nd |
Should values associated with non-detectable measurements like <10 be set to NA |
optimization_number |
The optimization number |
Returns a matrix of residuals, showing the residual error between map distance and table distance for each antigen-sera pair.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapDistances()
,
pointStress
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
Calculate the current map stress
mapStress(map, optimization_number = 1)
mapStress(map, optimization_number = 1)
map |
The acmap object |
optimization_number |
The optimization number for which to calculate stress |
A number giving the map stress
Other map optimization attribute functions:
colBases()
,
mapComment()
,
mapDimensions()
,
mapTransformation()
,
ptBaseCoords()
,
ptCoords()
These functions can be used to query and if necessary set the map transformation and map translation attributes for a given optimization run.
mapTransformation(map, optimization_number = 1) mapTransformation(map, optimization_number = 1) <- value mapTranslation(map, optimization_number = 1) mapTranslation(map, optimization_number = 1) <- value
mapTransformation(map, optimization_number = 1) mapTransformation(map, optimization_number = 1) <- value mapTranslation(map, optimization_number = 1) mapTranslation(map, optimization_number = 1) <- value
map |
The acmap data object |
optimization_number |
The optimization run from which to get / set the data |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
Other map optimization attribute functions:
colBases()
,
mapComment()
,
mapDimensions()
,
mapStress()
,
ptBaseCoords()
,
ptCoords()
Find matching antigens or sera between 2 maps
match_mapAntigens(map1, map2) match_mapSera(map1, map2)
match_mapAntigens(map1, map2) match_mapSera(map1, map2)
map1 |
The map to match names from. |
map2 |
The map to match names to. |
Returns the indices of matching strains in map 2, or NA in the position of strains not found.
Other functions to compare maps:
procrustesData()
,
procrustesMap()
,
realignMap()
,
realignOptimizations()
Functions to merge together two tables or maps.
mergeMaps( ..., method = "table", number_of_dimensions, number_of_optimizations, minimum_column_basis = "none", optimizer_options = list(), merge_options = list(), verbose = TRUE )
mergeMaps( ..., method = "table", number_of_dimensions, number_of_optimizations, minimum_column_basis = "none", optimizer_options = list(), merge_options = list(), verbose = TRUE )
... |
acmaps to merge provided as either a list, or a series of separate arguments |
method |
The merge method to use, see details. |
number_of_dimensions |
For merging that generates new optimization runs, the number of dimensions. |
number_of_optimizations |
For merging that generates new optimization runs, the number of optimization runs to do. |
minimum_column_basis |
For merging that generates new optimization runs, the minimum column basis to use. |
optimizer_options |
For merging that generates new optimization runs, optimizer
settings (see |
merge_options |
Options to use when merging titers (see |
verbose |
Should progress messages be output? |
Maps can be merged in a number of ways depending upon the desired result.
As you would expect, this merges the tables of the two maps but does not attempt to create any new optimizations and any existing optimizations are lost.
This merges the tables and then
does a specified number of fresh optimizations from random starting
coordinates, ignoring any pre-existing optimization runs. It's exactly the
same as doing a 'table' merge and running optimizeMap()
on the merged
table.
This takes the currently selected optimization in the first map and then merges in the additional maps in turn. Each time any points not already found in the first map (or the last map in the incremental merge chain) are randomised and everything is relaxed, this is repeated the specified number of times and the process is repeated.
This fixes the positions of points in each map and tries to best match them simply through re-orientation. Once the best re-orientation is found, points that are in common between the maps are moved to the average position.
This is the same as the frozen-overlay but points in the resulting map are then allowed to relax.
In this version, positions of all points in the first map are fixed and remain fixed, so the original map does not change. The second map is then realigned to the first as closely as possible and then all the new points appearing in the second map are allowed to relax into their new positions. This is a way to merge in new antigens and sera into a map without affecting the first one at all (and was first implemented in lisp).
Returns the merged map object
Other map merging functions:
RacMerge.options()
,
htmlMergeReport()
,
mergeReport()
,
splitTiterLayers()
Prints a raw text merge report from merging two map tables.
mergeReport(map)
mergeReport(map)
map |
An acmap object that was the result of merging several maps |
Returns a character matrix of information on merged titers.
Other map merging functions:
RacMerge.options()
,
htmlMergeReport()
,
mergeMaps()
,
splitTiterLayers()
Sometimes points in a map optimization run get trapped in local optima, this function tries to combat this by doing a grid search for each point individually moving points if a better optima is found. Note that this only performs grid searches individually so won't find cases where a group of points are trapped together in a local optima.
moveTrappedPoints( map, optimization_number = 1, grid_spacing = 0.25, max_iterations = 10, options = list() )
moveTrappedPoints( map, optimization_number = 1, grid_spacing = 0.25, max_iterations = 10, options = list() )
map |
The acmap data object |
optimization_number |
The map optimization number to apply it to |
grid_spacing |
Grid spacing in antigenic units of the search grid to use when searching for more optimal positions |
max_iterations |
The maximum number of iterations of searching for trapped points then relaxing the map to be performed |
options |
List of named optimizer options, see |
The search is iterative, searching for and moving points that are found to be
trapped before relaxing the map and searching again, stopping either when no
more trapped points are found or max_iterations
is reached.
Returns the acmap object with updated coordinates (if any trapped points found)
Other map optimization functions:
RacOptimizer.options()
,
make.acmap()
,
optimizeMap()
,
randomizeCoords()
,
relaxMapOneStep()
,
relaxMap()
Utility functions to get a vector of all the map optimization properties.
allMapStresses(map) allMapDimensions(map)
allMapStresses(map) allMapDimensions(map)
map |
The acmap object |
A numeric vector of values
Other functions to work with map optimizations:
keepOptimizations()
,
removeOptimizations()
,
sortOptimizations()
optimizeAgReactivity( map, optimization_number = 1, reactivity_stress_weighting = 1, fixed_ag_reactivities = rep(NA, numAntigens(map)), start_pars = rep(0, numAntigens(map)), reoptimize = FALSE, number_of_optimizations = 100, options = list() )
optimizeAgReactivity( map, optimization_number = 1, reactivity_stress_weighting = 1, fixed_ag_reactivities = rep(NA, numAntigens(map)), start_pars = rep(0, numAntigens(map)), reoptimize = FALSE, number_of_optimizations = 100, options = list() )
map |
The acmap object |
optimization_number |
The optimization number for which to optimize antigen reactivity adjustments |
reactivity_stress_weighting |
The weighting to apply when calculating how much antigen reactivity changes should additionally contribute to stress in the optimization regime (see details). |
fixed_ag_reactivities |
A vector of fixed antigen reactivities, use NA values to distinguish the positions you would still like to be optimized. |
start_pars |
A vector of starting parameters to use for the optimizer,
you can still supply starting parameters for antigens listed in
|
reoptimize |
Should the map be reoptimized from scratch (slower but more likely to explore other optima) when testing each reactivity adjustment or simply relaxed from it's current coordinates (default) |
number_of_optimizations |
If reoptimizing from scratch, how many optimization runs should be performed each time. |
options |
A named list of additional options to pass to
|
The acmap object is returned with antigen reactivity adjustments
set to the value calculated in the optimizer. This can be queried with
agReactivityAdjustments()
.
Take an acmap object with a table of titer data and perform optimization runs to try and find the best arrangement of antigens and sera to represent their antigenic similarity. Optimizations generated from each run with different random starting conditions will be added to the acmap object.
optimizeMap( map, number_of_dimensions, number_of_optimizations, minimum_column_basis = "none", fixed_column_bases = NULL, titer_weights = NULL, sort_optimizations = TRUE, check_convergence = TRUE, verbose = TRUE, options = list() )
optimizeMap( map, number_of_dimensions, number_of_optimizations, minimum_column_basis = "none", fixed_column_bases = NULL, titer_weights = NULL, sort_optimizations = TRUE, check_convergence = TRUE, verbose = TRUE, options = list() )
map |
The acmap data object |
number_of_dimensions |
The number of dimensions for the new map |
number_of_optimizations |
The number of optimization runs to perform |
minimum_column_basis |
The minimum column basis to use (see details) |
fixed_column_bases |
A vector of fixed values to use as column bases directly, rather than calculating them from the titer table. |
titer_weights |
An optional matrix of weights to assign each titer when optimizing |
sort_optimizations |
Should optimizations be sorted by stress afterwards? |
check_convergence |
Should a basic check for convergence of lowest stress optimization runs onto a similar solution be performed. |
verbose |
Should progress messages be reported, see also
|
options |
List of named optimizer options, see |
This is the core function to run map optimizations. In essence, for
each optimization run, points are randomly distributed in n-dimensional
space, the L-BFGS gradient-based optimization algorithm is applied to move
points into an optimal position. Depending on the map, this may not be a
trivial optimization process and results will depend upon the starting
conditions so multiple optimization runs may be required. For a full
explanation see vignette("intro-to-antigenic-cartography")
.
Fixed column bases is a vector of fixed column bases for each sera, where
NA is specified (the default) column bases will be calculated according to
the minimum_column_basis
setting. Again for a full explanation of column
bases and what they mean see vignette("intro-to-antigenic-cartography")
.
Returns the acmap object updated with new optimizations.
See relaxMap()
for optimizing a given optimization starting from
its current coordinates.
Other map optimization functions:
RacOptimizer.options()
,
make.acmap()
,
moveTrappedPoints()
,
randomizeCoords()
,
relaxMapOneStep()
,
relaxMap()
Functions to change the order of antigens and sera in a map
orderAntigens(map, order) orderSera(map, order)
orderAntigens(map, order) orderSera(map, order)
map |
The map data object |
order |
The new order of points |
An acmap object with points reordered
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Method for plotting an antigenic map in two dimensions
## S3 method for class 'acmap' plot( x, optimization_number = 1, xlim = NULL, ylim = NULL, plot_ags = TRUE, plot_sr = TRUE, plot_labels = FALSE, plot_blobs = TRUE, point_opacity = "automatic", show_procrustes = TRUE, show_error_lines = FALSE, plot_stress = FALSE, indicate_outliers = "arrowheads", grid.col = "grey90", grid.margin.col = "grey50", outlier.arrow.col = grid.col, fill.alpha = 0.8, outline.alpha = 0.8, procrustes.lwd = 2, procrustes.col = "black", procrustes.arr.type = "triangle", procrustes.arr.length = 0.2, procrustes.arr.width = 0.15, label.offset = 0, padding = 1, cex = 1, margins = rep(0.5, 4), ... )
## S3 method for class 'acmap' plot( x, optimization_number = 1, xlim = NULL, ylim = NULL, plot_ags = TRUE, plot_sr = TRUE, plot_labels = FALSE, plot_blobs = TRUE, point_opacity = "automatic", show_procrustes = TRUE, show_error_lines = FALSE, plot_stress = FALSE, indicate_outliers = "arrowheads", grid.col = "grey90", grid.margin.col = "grey50", outlier.arrow.col = grid.col, fill.alpha = 0.8, outline.alpha = 0.8, procrustes.lwd = 2, procrustes.col = "black", procrustes.arr.type = "triangle", procrustes.arr.length = 0.2, procrustes.arr.width = 0.15, label.offset = 0, padding = 1, cex = 1, margins = rep(0.5, 4), ... )
x |
The acmap to plot |
optimization_number |
The optimization number to plot |
xlim |
optional x axis limits |
ylim |
optional y axis limits |
plot_ags |
logical, should antigens be plotted |
plot_sr |
logical, should antigens be plotted |
plot_labels |
should point labels be plotted, can be true, false or "antigens" or "sera" |
plot_blobs |
logical, should stress blobs be plotted if present |
point_opacity |
Either "automatic" or "fixed". "fixed" fixes point
opacity to match those in |
show_procrustes |
logical, should procrustes lines be shown, if present |
show_error_lines |
logical, should error lines be drawn |
plot_stress |
logical, should map stress be plotted in lower left corner |
indicate_outliers |
how should points outside the plotting region be indicated, either FALSE, for not shown, "arrowheads" for small arrowheads like in the viewer, or "arrows" for arrows pointing from the edge of the plot margin, default is "arrowheads". |
grid.col |
grid line color |
grid.margin.col |
grid margin color |
outlier.arrow.col |
outlier arrow color |
fill.alpha |
alpha for point fill |
outline.alpha |
alpha for point outline |
procrustes.lwd |
procrustes arrow line width |
procrustes.col |
procrustes arrow color |
procrustes.arr.type |
procrustes arrow type (see |
procrustes.arr.length |
procrustes arrow length (see |
procrustes.arr.width |
procrustes arrow width (see |
label.offset |
amount by which any point labels should be offset from point coordinates in fractions of a character width |
padding |
padding at limits of the antigenic map, ignored if xlim or ylim set explicitly |
cex |
point size expansion factor |
margins |
margins in inches for the plot, use |
... |
additional arguments, not used |
Called for the side effect of plotting the map but invisibly returns the map object.
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
setLegend()
,
view.acmap()
,
view.default()
,
view()
Functions to get stress associated with individual points in a map.
agStress(map, antigens = TRUE, optimization_number = 1) srStress(map, sera = TRUE, optimization_number = 1) srStressPerTiter(map, sera = TRUE, optimization_number = 1) agStressPerTiter(map, antigens = TRUE, optimization_number = 1)
agStress(map, antigens = TRUE, optimization_number = 1) srStress(map, sera = TRUE, optimization_number = 1) srStressPerTiter(map, sera = TRUE, optimization_number = 1) agStressPerTiter(map, antigens = TRUE, optimization_number = 1)
map |
The acmap data object |
antigens |
Which antigens to check stress for, specified by index or name (defaults to all antigens). |
optimization_number |
The optimization number |
sera |
Which sera to check stress for, specified by index or name (defaults to all sera). |
A numeric vector of point stresses
See mapStress()
for getting the total map stress directly.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapDistances()
,
mapResiduals()
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
Returns information about how similar point positions are in two maps, to get an idea of how similar antigenic positions are in for example maps made from two different datasets.
procrustesData( map, comparison_map, optimization_number = 1, comparison_optimization_number = 1, antigens = TRUE, sera = TRUE, translation = TRUE, scaling = FALSE )
procrustesData( map, comparison_map, optimization_number = 1, comparison_optimization_number = 1, antigens = TRUE, sera = TRUE, translation = TRUE, scaling = FALSE )
map |
The acmap data object |
comparison_map |
The acmap data object to procrustes against |
optimization_number |
The map optimization to use in the procrustes calculation (other optimization runs are discarded) |
comparison_optimization_number |
The optimization run int the comparison map to compare against |
antigens |
Antigens to include (specified by name or index or TRUE/FALSE for all/none) |
sera |
Sera to include (specified by name or index or TRUE/FALSE for all/none) |
translation |
Should translation be allowed |
scaling |
Should scaling be allowed (generally not recommended unless comparing maps made with different assays) |
Returns a list with information on antigenic distances between the aligned maps, and the rmsd of the point differences split by antigen points, serum points and total, or all points. The distances are a vector matching the number of points in the main map, with NA in the position of any points not found in the comparison map.
Other functions to compare maps:
matchStrains
,
procrustesMap()
,
realignMap()
,
realignOptimizations()
Returns information from one map procrusted to another.
procrustesMap( map, comparison_map, optimization_number = 1, comparison_optimization_number = 1, antigens = TRUE, sera = TRUE, translation = TRUE, scaling = FALSE, keep_optimizations = FALSE )
procrustesMap( map, comparison_map, optimization_number = 1, comparison_optimization_number = 1, antigens = TRUE, sera = TRUE, translation = TRUE, scaling = FALSE, keep_optimizations = FALSE )
map |
The acmap data object |
comparison_map |
The acmap data object to procrustes against |
optimization_number |
The map optimization to use in the procrustes calculation (other optimization runs are discarded) |
comparison_optimization_number |
The optimization run int the comparison map to compare against |
antigens |
Antigens to include (specified by name or index or TRUE/FALSE for all/none) |
sera |
Sera to include (specified by name or index or TRUE/FALSE for all/none) |
translation |
Should translation be allowed |
scaling |
Should scaling be allowed (generally not recommended unless comparing maps made with different assays) |
keep_optimizations |
Should all optimization runs be kept or only the one to which the procrustes was applied. |
Returns an acmap object with procrustes information added, which will
be shown when the map is plotted. To avoid ambiguity about which
optimization run the procrustes was applied to, only the optimization run
specified by optimization_number
is kept in the map returned.
Other functions to compare maps:
matchStrains
,
procrustesData()
,
realignMap()
,
realignOptimizations()
Getting and setting point annotation information
agAnnotations(map) srAnnotations(map) agAnnotations(map) <- value srAnnotations(map) <- value
agAnnotations(map) srAnnotations(map) agAnnotations(map) <- value srAnnotations(map) <- value
map |
The acmap data object |
value |
A list of character vectors with annotations information for each point |
A character vector of point annotations.
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
These functions get and set the base coordinates for a given optimization run.
ptBaseCoords(map, optimization_number = 1) agBaseCoords(map, optimization_number = 1) agBaseCoords(map, optimization_number = 1) <- value srBaseCoords(map, optimization_number = 1) srBaseCoords(map, optimization_number = 1) <- value
ptBaseCoords(map, optimization_number = 1) agBaseCoords(map, optimization_number = 1) agBaseCoords(map, optimization_number = 1) <- value srBaseCoords(map, optimization_number = 1) srBaseCoords(map, optimization_number = 1) <- value
map |
The acmap data object |
optimization_number |
The optimization run from which to get / set the data |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
agCoords()
srCoords()
Other map optimization attribute functions:
colBases()
,
mapComment()
,
mapDimensions()
,
mapStress()
,
mapTransformation()
,
ptCoords()
Get antigen or serum bootstrap blob information for plotting with the blob()
function.
agBootstrapBlob(map, antigen, optimization_number = 1) srBootstrapBlob(map, serum, optimization_number = 1) agBootstrapBlobs(map, optimization_number = 1) srBootstrapBlobs(map, optimization_number = 1) ptBootstrapBlobs(map, optimization_number = 1)
agBootstrapBlob(map, antigen, optimization_number = 1) srBootstrapBlob(map, serum, optimization_number = 1) agBootstrapBlobs(map, optimization_number = 1) srBootstrapBlobs(map, optimization_number = 1) ptBootstrapBlobs(map, optimization_number = 1)
map |
An acmap object |
antigen |
The antigen to get the blob for |
optimization_number |
Optimization number from which to get blob information |
serum |
The serum to get the blob for |
Returns an object of class "blob" that can be plotted using the blob()
function.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Get antigen or serum bootstrap coordinates information
ptBootstrapCoords(map, point) agBootstrapCoords(map, antigen) srBootstrapCoords(map, serum)
ptBootstrapCoords(map, point) agBootstrapCoords(map, antigen) srBootstrapCoords(map, serum)
map |
An acmap object |
point |
The point from which to get the bootstrap coords (numbered antigens then sera) |
antigen |
The antigen to get the bootstrap coords |
serum |
The serum from which to get the bootstrap coords |
Returns a matrix of coordinates for the point in each of the bootstrap runs
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Getting and setting point clade information
agClades(map) srClades(map) agClades(map) <- value srClades(map) <- value
agClades(map) srClades(map) agClades(map) <- value srClades(map) <- value
map |
The acmap data object |
value |
A list of character vectors with clade information for each point |
A character vector of clade information.
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
srAttributes
,
srGroups()
,
srHomologousAgs()
,
srSequences()
Getting and setting of antigen and serum coordinates in a map optimization run (by default the currently selected one).
agCoords(map, optimization_number = 1) srCoords(map, optimization_number = 1) ptCoords(map, optimization_number = 1) ptCoords(map, optimization_number = 1) <- value agCoords(map, optimization_number = 1) <- value srCoords(map, optimization_number = 1) <- value
agCoords(map, optimization_number = 1) srCoords(map, optimization_number = 1) ptCoords(map, optimization_number = 1) ptCoords(map, optimization_number = 1) <- value agCoords(map, optimization_number = 1) <- value srCoords(map, optimization_number = 1) <- value
map |
The acmap object |
optimization_number |
The optimization number from which to get / set the coordinates |
value |
A matrix of new coordinates to set |
These functions get and set point coordinates in a map. By default
these coordinates refer to the currently selected optimization run, unless
otherwise specified through the optimization_number
argument.
99\
want to use but you should note that the outputs are actually the map base
coordinates after the transformation and translation associated with the
optimization run has been applied (see mapTransformation()
and
mapTranslation()
for more details). When you set the antigen or serum
coordinates through these functions, the transformed coordinates are
"baked" in and the map transformation and translation are reset.
Consequently if you want to apply a transformation to all coordinates
generally, you are better off modifying the map translation and
transformation directly, as is done by functions like rotateMap()
and
translateMap()
.
Returns a matrix of point coordinates.
agBaseCoords()
srBaseCoords()
mapTransformation()
mapTranslation()
Other map optimization attribute functions:
colBases()
,
mapComment()
,
mapDimensions()
,
mapStress()
,
mapTransformation()
,
ptBaseCoords()
Point drawing order is a vector of indices defining the order in which points should be draw when plotting or viewing a map. Points are indexed in the same order as antigens then followed by sera.
ptDrawingOrder(map) ptDrawingOrder(map) <- value
ptDrawingOrder(map) ptDrawingOrder(map) <- value
map |
An acmap object |
value |
The point drawing order |
A numeric vector of point drawing order information
Other map point style functions:
applyPlotspec()
,
ptOpacity
,
ptStyles
These functions attempt to estimate leverage of each antigen, sera or titer
by removing it from the data, relaxing the map, then calculating the rmsd of
the procrustes comparison between the original and newly relaxed map. Column
bases will be recalculated unless you have specified them as fixed with
fixedColBases()
.
agLeverage(map, antigens = TRUE, sera = TRUE) srLeverage(map, antigens = TRUE, sera = TRUE) titerLeverage(map, antigens = TRUE, sera = TRUE)
agLeverage(map, antigens = TRUE, sera = TRUE) srLeverage(map, antigens = TRUE, sera = TRUE) titerLeverage(map, antigens = TRUE, sera = TRUE)
map |
An acmap object |
antigens |
Antigens to include when calculating the rmsd of the procrustes (specified by name or index or TRUE/FALSE for all/none) |
sera |
Sera to include when calculating the rmsd of the procrustes (specified by name or index or TRUE/FALSE for all/none) |
Returns a numeric vector of the leverage calculated for each of the points.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
These are helper functions to quickly set the opacity of points in a map,
they set both the fill and outline color opacity by modifying the fill
and outline colors to include an alpha channel for opacity. If you need
more control, for example different opacities for the fill and outline
colors, you alter the fill and outline opacities yourself, for example
with the grDevices::adjustcolor()
function.
agOpacity(map) <- value srOpacity(map) <- value
agOpacity(map) <- value srOpacity(map) <- value
map |
An acmap object |
value |
A vector of opacities |
A numeric vector of point opacities.
Other map point style functions:
applyPlotspec()
,
ptDrawingOrder()
,
ptStyles
These functions get and set the styles to use for each point when plotting.
agShown(map) srShown(map) agShown(map) <- value srShown(map) <- value agSize(map) srSize(map) agSize(map) <- value srSize(map) <- value agFill(map) srFill(map) agFill(map) <- value srFill(map) <- value agOutline(map) srOutline(map) agOutline(map) <- value srOutline(map) <- value agOutlineWidth(map) srOutlineWidth(map) agOutlineWidth(map) <- value srOutlineWidth(map) <- value agRotation(map) srRotation(map) agRotation(map) <- value srRotation(map) <- value agAspect(map) srAspect(map) agAspect(map) <- value srAspect(map) <- value agShape(map) srShape(map) agShape(map) <- value srShape(map) <- value
agShown(map) srShown(map) agShown(map) <- value srShown(map) <- value agSize(map) srSize(map) agSize(map) <- value srSize(map) <- value agFill(map) srFill(map) agFill(map) <- value srFill(map) <- value agOutline(map) srOutline(map) agOutline(map) <- value srOutline(map) <- value agOutlineWidth(map) srOutlineWidth(map) agOutlineWidth(map) <- value srOutlineWidth(map) <- value agRotation(map) srRotation(map) agRotation(map) <- value srRotation(map) <- value agAspect(map) srAspect(map) agAspect(map) <- value srAspect(map) <- value agShape(map) srShape(map) agShape(map) <- value srShape(map) <- value
map |
The acmap data object |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
Other map point style functions:
applyPlotspec()
,
ptDrawingOrder()
,
ptOpacity
Get antigen or serum triangulation blob information for plotting with the blob()
function.
agTriangulationBlob(map, antigen, optimization_number = 1) srTriangulationBlob(map, serum, optimization_number = 1) agTriangulationBlobs(map, optimization_number = 1) srTriangulationBlobs(map, optimization_number = 1) ptTriangulationBlobs(map, optimization_number = 1)
agTriangulationBlob(map, antigen, optimization_number = 1) srTriangulationBlob(map, serum, optimization_number = 1) agTriangulationBlobs(map, optimization_number = 1) srTriangulationBlobs(map, optimization_number = 1) ptTriangulationBlobs(map, optimization_number = 1)
map |
An acmap object |
antigen |
The antigen to get the blob for |
optimization_number |
Optimization number from which to get blob information |
serum |
The serum to get the blob for |
Returns an object of class "blob" that can be plotted using the blob()
function.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
This function facilitates setting options for the acmap titer merging process by returning a list of option settings.
RacMerge.options(sd_limit = NULL, dilution_stepsize = 1, method = NULL)
RacMerge.options(sd_limit = NULL, dilution_stepsize = 1, method = NULL)
sd_limit |
When merging titers, titers that have a standard deviation of this amount or greater on the log2 scale will be set to "*" and excluded. Setting this to NA removes any limit. The default value will be NA, unless the titer merge method is specified as "lispmds" in which case the default is 1 and standard deviation is calculated by division by n, instead of n-1, in order to maintain backwards compatibility with previous approaches. |
dilution_stepsize |
The dilution stepsize to assume when merging titers (see
|
method |
The titer merging method to use, either a string of "conservative" or "likelihood", or a user defined function. See details. |
When merging measured titers, the general approach is to take the geometric mean and use that as the merged titer, however in particular when < values are present there are different options that can be employed. In older versions of Racmacs, < values were converted to maximum possible numeric titer after accounting for the dilution_stepsize factor, then the geometric mean was taken. This approach can be used by specifying the method as "likelihood" since, this approach gives a very rough approximation of the most likely mean numeric value. In contrast, the "conservative" method and current default returns the highest < value that satisfies all the values that were measured. As an example merging <10 and 20, (assuming dilution_stepsize = 1) would return a value of 10 with the "likelihood" method and <40 with the "conservative" method.
Returns a named list of merging options
Other map merging functions:
htmlMergeReport()
,
mergeMaps()
,
mergeReport()
,
splitTiterLayers()
This function facilitates setting options for the acmap optimizer process by returning a list of option settings.
RacOptimizer.options( dim_annealing = FALSE, method = "L-BFGS", maxit = 1000, num_basis = 10, armijo_constant = 1e-04, wolfe = 0.9, min_gradient_norm = 1e-06, factr = 1e-15, max_line_search_trials = 50, min_step = 1e-20, max_step = 1e+20, num_cores = getOption("RacOptimizer.num_cores"), report_progress = NULL, ignore_disconnected = FALSE, progress_bar_length = options()$width )
RacOptimizer.options( dim_annealing = FALSE, method = "L-BFGS", maxit = 1000, num_basis = 10, armijo_constant = 1e-04, wolfe = 0.9, min_gradient_norm = 1e-06, factr = 1e-15, max_line_search_trials = 50, min_step = 1e-20, max_step = 1e+20, num_cores = getOption("RacOptimizer.num_cores"), report_progress = NULL, ignore_disconnected = FALSE, progress_bar_length = options()$width )
dim_annealing |
Should dimensional annealing be performed |
method |
The optimization method to use |
maxit |
The maximum number of iterations to use in the optimizer |
num_basis |
Number of memory points to be stored (default 10). |
armijo_constant |
Controls the accuracy of the line search routine for determining the Armijo condition. |
wolfe |
Parameter for detecting the Wolfe condition. |
min_gradient_norm |
Minimum gradient norm required to continue the optimization. |
factr |
Minimum relative function value decrease to continue the optimization. |
max_line_search_trials |
The maximum number of trials for the line search (before giving up). |
min_step |
The minimum step of the line search. |
max_step |
The maximum step of the line search. |
num_cores |
The number of cores to run in parallel when running optimizations |
report_progress |
Should progress be reported |
ignore_disconnected |
Should the check for disconnected points be skipped |
progress_bar_length |
Progress bar length when progress is reported |
For more details, for example on "dimensional annealing" see
vignette("intro-to-antigenic-cartography")
. For details on optimizer
settings like maxit
see the underlying optimizer documentation at
ensmallen.org.
Returns a named list of optimizer options
Other map optimization functions:
make.acmap()
,
moveTrappedPoints()
,
optimizeMap()
,
randomizeCoords()
,
relaxMapOneStep()
,
relaxMap()
This creates an html widget for viewing antigenic maps.
RacViewer( map, show_procrustes = FALSE, show_group_legend = FALSE, options = list(), width = NULL, height = NULL, elementId = NULL )
RacViewer( map, show_procrustes = FALSE, show_group_legend = FALSE, options = list(), width = NULL, height = NULL, elementId = NULL )
map |
The map data object |
show_procrustes |
should procrustes lines be shown |
show_group_legend |
Show an interactive legend detailing different
groups as set by |
options |
A named list of viewer options supplied to
|
width |
Width of the widget |
height |
Height of the widget |
elementId |
DOM element ID |
An object of class htmlwidget that will intelligently print itself into HTML in a variety of contexts including the R console, within R Markdown documents, and within Shiny output bindings.
Other functions to view maps:
RacViewer.options()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view.default()
,
view()
Output and render functions for using RacViewer within Shiny applications and interactive Rmd documents.
RacViewerOutput(outputId, width = "100%", height = "100%") renderRacViewer(expr, env = parent.frame(), quoted = FALSE)
RacViewerOutput(outputId, width = "100%", height = "100%") renderRacViewer(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a RacViewer |
env |
The environment in which to evaluate |
quoted |
Is |
An output or render function that enables the use of the widget within Shiny applications.
Other shiny app functions:
runGUI()
,
view.acmap()
This function facilitates setting racviewer options by returning a list of option settings.
RacViewer.options( point.opacity = NA, viewer.controls = "hidden", grid.display = "static", grid.col = "#cfcfcf", background.col = "#ffffff", show.names = FALSE, show.errorlines = FALSE, show.connectionlines = FALSE, show.titers = FALSE, xlim = NULL, ylim = NULL, translation = c(0, 0, 0), rotation = c(0, 0, 0), zoom = NULL )
RacViewer.options( point.opacity = NA, viewer.controls = "hidden", grid.display = "static", grid.col = "#cfcfcf", background.col = "#ffffff", show.names = FALSE, show.errorlines = FALSE, show.connectionlines = FALSE, show.titers = FALSE, xlim = NULL, ylim = NULL, translation = c(0, 0, 0), rotation = c(0, 0, 0), zoom = NULL )
point.opacity |
Default opacity for unselected points, or "inherit" to take opacity from the color values themselves. |
viewer.controls |
Should viewer controls be shown or hidden by default? |
grid.display |
For 3d maps, should the grid be fixed in the background or enclose and rotate along with the map |
grid.col |
Color to use for the grid shown behind the map |
background.col |
Color for the viewer background |
show.names |
Toggle name labels on, can be true or false or "antigens" or "sera" |
show.errorlines |
Toggle error lines on |
show.connectionlines |
Toggle connection lines on |
show.titers |
Toggle titer labels on |
xlim |
x limits to zoom the plot to |
ylim |
y limits to zoom the plot to |
translation |
Plot starting translation |
rotation |
Plot starting rotation as an XYZ Euler rotation |
zoom |
Plot starting zoom factor |
Returns a named list of viewer options
Other functions to view maps:
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view.default()
,
view()
Moves map coordinates back into random starting conditions, as performed
before each optimization run. The maximum table distance is calculated
then points are randomized in a box with side length equal to maximum
table distance multiplied by table_dist_factor
randomizeCoords(map, optimization_number = 1, table_dist_factor = 2)
randomizeCoords(map, optimization_number = 1, table_dist_factor = 2)
map |
The acmap data object |
optimization_number |
The map optimization number to randomize |
table_dist_factor |
The expansion factor for the box size in which points are randomized. |
Returns an updated map object
Other map optimization functions:
RacOptimizer.options()
,
make.acmap()
,
moveTrappedPoints()
,
optimizeMap()
,
relaxMapOneStep()
,
relaxMap()
Reads an antigenic map file and converts it into an acmap data object.
read.acmap( filename, optimization_number = NULL, sort_optimizations = FALSE, align_optimizations = FALSE )
read.acmap( filename, optimization_number = NULL, sort_optimizations = FALSE, align_optimizations = FALSE )
filename |
Path to the file. |
optimization_number |
Numeric vector of optimization runs to keep, the default, NULL, keeps information on all optimization runs |
sort_optimizations |
Should optimizations be sorted in order of stress when the map data is read? |
align_optimizations |
Should optimizations be rotated and translated to match the orientation of the first optimization as closely as possible? |
Returns the acmap data object.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Reads in a table of titer data, converting it to a matrix of titers with labelled column and row names. Missing titers should be represented by an asterisk character.
read.titerTable(filepath)
read.titerTable(filepath)
filepath |
Path to the table of titer data |
Currently supported file formats are .csv and .xls and .txt
Returns a matrix of titers.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Realigns the coordinates of a map to match a target map as closely as possible, based on a procrustes analysis. Note that all optimization runs will be separately aligned to match as closely as possible the first optimization run of the target map.
realignMap(map, target_map, translation = TRUE, scaling = FALSE)
realignMap(map, target_map, translation = TRUE, scaling = FALSE)
map |
The acmap to realign. |
target_map |
The acmap to realign to. |
translation |
Should translation be allowed |
scaling |
Should scaling be allowed (generally not recommended unless comparing maps made with different assays) |
Returns a map object aligned to the target map
Other functions to compare maps:
matchStrains
,
procrustesData()
,
procrustesMap()
,
realignOptimizations()
Realigns all map optimizations through rotation and translation to match point positions as closely as possible to the first optimization run. This is done by default when optimizing a map and makes comparing point positions in each optimization run much easier to do by eye.
realignOptimizations(map)
realignOptimizations(map)
map |
The acmap data object |
Returns the map with realigned optimizations
Other functions to compare maps:
matchStrains
,
procrustesData()
,
procrustesMap()
,
realignMap()
Recalculates the stress associated with the currently selected or user-specified optimization.
recalculateStress(map, optimization_number = 1)
recalculateStress(map, optimization_number = 1)
map |
The acmap data object |
optimization_number |
The optimization number |
Returns the recalculated map stress for a given optimization
See pointStress()
for getting the stress of individual points.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapDistances()
,
mapResiduals()
,
pointStress
,
stressTable()
,
tableColbases()
,
tableDistances()
Reflects map coordinates
reflectMap(map, axis = "x", optimization_number = NULL)
reflectMap(map, axis = "x", optimization_number = NULL)
map |
The acmap object |
axis |
Axis of reflection |
optimization_number |
The optimization number (or NULL to apply to all optimizations) |
An acmap object with reflection applied
Other functions relating to map transformation:
applyMapTransform()
,
rotateMap()
,
translateMap()
Optimize antigen and serum positions starting from their current coordinates in the selected or specified optimization.
relaxMap( map, optimization_number = 1, fixed_antigens = FALSE, fixed_sera = FALSE, titer_weights = NULL, options = list() )
relaxMap( map, optimization_number = 1, fixed_antigens = FALSE, fixed_sera = FALSE, titer_weights = NULL, options = list() )
map |
The acmap object |
optimization_number |
The optimization number to relax |
fixed_antigens |
Antigens to set fixed positions for when relaxing |
fixed_sera |
Sera to set fixed positions for when relaxing |
titer_weights |
An optional matrix of weights to assign each titer when optimizing |
options |
List of named optimizer options, see |
Returns an acmap object with the optimization relaxed.
See optimizeMap()
for performing new optimization runs from random
starting coordinates.
Other map optimization functions:
RacOptimizer.options()
,
make.acmap()
,
moveTrappedPoints()
,
optimizeMap()
,
randomizeCoords()
,
relaxMapOneStep()
Relax a map one step in the optimiser
relaxMapOneStep( map, optimization_number = 1, fixed_antigens = FALSE, fixed_sera = FALSE, options = list() )
relaxMapOneStep( map, optimization_number = 1, fixed_antigens = FALSE, fixed_sera = FALSE, options = list() )
map |
The acmap data object |
optimization_number |
The map optimization number |
fixed_antigens |
Antigens to set fixed positions for when relaxing |
fixed_sera |
Sera to set fixed positions for when relaxing |
options |
List of named optimizer options, see |
Returns an updated map object
Other map optimization functions:
RacOptimizer.options()
,
make.acmap()
,
moveTrappedPoints()
,
optimizeMap()
,
randomizeCoords()
,
relaxMap()
Remove all optimization run data from a map object
removeOptimizations(map)
removeOptimizations(map)
map |
The acmap object |
An acmap object with all optimizations removed
Other functions to work with map optimizations:
keepOptimizations()
,
optimizationProperties
,
sortOptimizations()
Functions to remove antigens and sera from a map
removeAntigens(map, antigens) removeSera(map, sera)
removeAntigens(map, antigens) removeSera(map, sera)
map |
The map data object |
antigens |
Antigens to remove (specified by name or index) |
sera |
Sera to remove (specified by name or index) |
An acmap object with points removed
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Apply a rotation to an antigenic map
rotateMap(map, degrees, axis = NULL, optimization_number = NULL)
rotateMap(map, degrees, axis = NULL, optimization_number = NULL)
map |
The acmap object |
degrees |
Degrees of rotation |
axis |
Axis of rotation (if 3D), specified as "x", "y", or "z" |
optimization_number |
The optimization number (or NULL to apply to all optimizations) |
An acmap object with rotation applied
Other functions relating to map transformation:
applyMapTransform()
,
reflectMap()
,
translateMap()
This function opens the Racmacs GUI in a new window
runGUI()
runGUI()
Nothing returned, called only for the side effect of starting the viewer.
Other shiny app functions:
RacViewer-shiny
,
view.acmap()
Save acmap data to a file. The preferred extension is ".ace", although the format of the file will be a json file of map data compressed using 'xz' compression.
save.acmap( map, filename, compress = FALSE, pretty = !compress, round_titers = FALSE )
save.acmap( map, filename, compress = FALSE, pretty = !compress, round_titers = FALSE )
map |
The acmap data object. |
filename |
Path to the file. |
compress |
Should the file be xz compressed |
pretty |
Should json be output prettily with new lines and indentation |
round_titers |
Should titers be rounded when outputted (this is needed for acmacs web and lispmds compatibility) |
No return value, called for the side effect of saving the map data to the file.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Saves acmap coordinate data of all or specified antigens and sera to a .csv file.
save.coords( map, filename, optimization_number = 1, antigens = TRUE, sera = TRUE )
save.coords( map, filename, optimization_number = 1, antigens = TRUE, sera = TRUE )
map |
The acmap data object. |
filename |
Path to the file. |
optimization_number |
Optimization number from which to take coordinates |
antigens |
Antigens to include, either as a numeric vector of indices or character vector of names. |
sera |
Sera to include, either as a numeric vector of indices or character vector of names. |
No return value, called for the side effect of saving the coordinate data.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.titerTable()
,
subsetCommonPoints
,
subsetMap()
Saves titer data of all or specified antigens and sera to a .csv file.
save.titerTable(map, filename, antigens = TRUE, sera = TRUE)
save.titerTable(map, filename, antigens = TRUE, sera = TRUE)
map |
The acmap data object. |
filename |
Path to the file. |
antigens |
Antigens to include, either as a numeric vector of indices or character vector of names. |
sera |
Sera to include, either as a numeric vector of indices or character vector of names. |
No return value, called for the side effect of saving the titer data to the file.
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
subsetCommonPoints
,
subsetMap()
This sets the acmap legend used when viewing a map for example.
setLegend(map, legend, fill, style.bottom = "8px", style.right = "8px")
setLegend(map, legend, fill, style.bottom = "8px", style.right = "8px")
map |
The acmap object |
legend |
A character vector of legend labels |
fill |
The fill color to be used with the boxes that appear alongside the legend labels |
style.bottom |
"bottom" style of the div, specifying how far from the bottom of the viewport the bottom of the legend is spaced. |
style.right |
"right" style of the div, specifying how far from the right of the viewport the bottom of the legend is spaced. |
Returns the updated acmap object
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
view.acmap()
,
view.default()
,
view()
Sorts all the optimization runs for a given map object by stress
(lowest to highest). Note that this is done by default when running
optimizeMap()
.
sortOptimizations(map)
sortOptimizations(map)
map |
The acmap object |
An acmap object with optimizations sorted by stress.
Other functions to work with map optimizations:
keepOptimizations()
,
optimizationProperties
,
removeOptimizations()
Split a map made up from titer layers into a list of separate maps each with a titer table corresponding to one of the layers
splitTiterLayers(map)
splitTiterLayers(map)
map |
An acmap object with titer table layers |
A list of acmap objects
Other map merging functions:
RacMerge.options()
,
htmlMergeReport()
,
mergeMaps()
,
mergeReport()
These functions get and set the sera attributes for a map.
srIDs(map) srIDs(map) <- value srDates(map) srDates(map) <- value srReference(map) srReference(map) <- value srNames(map) srNames(map) <- value srExtra(map) srExtra(map) <- value srPassage(map) srPassage(map) <- value srLineage(map) srLineage(map) <- value srReassortant(map) srReassortant(map) <- value srStrings(map) srStrings(map) <- value srSpecies(map) srSpecies(map) <- value
srIDs(map) srIDs(map) <- value srDates(map) srDates(map) <- value srReference(map) srReference(map) <- value srNames(map) srNames(map) <- value srExtra(map) srExtra(map) <- value srPassage(map) srPassage(map) <- value srLineage(map) srLineage(map) <- value srReassortant(map) srReassortant(map) <- value srStrings(map) srStrings(map) <- value srSpecies(map) srSpecies(map) <- value
map |
The acmap data object |
value |
New value to set |
Returns either the requested attribute when using a getter function or
the updated acmap object when using the setter function.
agAttributes()
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srGroups()
,
srHomologousAgs()
,
srSequences()
These functions get and set the sera groupings for a map.
srGroups(map) srGroups(map) <- value
srGroups(map) srGroups(map) <- value
map |
The acmap object |
value |
A character or factor vector of groupings to apply to the sera |
A factor vector of serum groups
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srHomologousAgs()
,
srSequences()
Get and set indices of homologous antigens to sera in an antigenic map
srHomologousAgs(map) srHomologousAgs(map) <- value
srHomologousAgs(map) srHomologousAgs(map) <- value
map |
An acmap object |
value |
A list, where each entry is a vector of indices for homologous antigens, or a length 0 vector where no homologous antigen is present |
A list, where each entry is a vector of indices for homologous antigens, or a length 0 vector where no homologous antigen is present.
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srSequences()
Getting and setting sera sequence information
srSequences(map, missing_value = ".") srSequences(map) <- value srNucleotideSequences(map, missing_value = ".") srNucleotideSequences(map) <- value
srSequences(map, missing_value = ".") srSequences(map) <- value srNucleotideSequences(map, missing_value = ".") srNucleotideSequences(map) <- value
map |
The acmap data object |
missing_value |
Character to use to fill in portions of the sequence matrix where sequence data is missing. |
value |
A character matrix of sequences with rows equal to the number of sera |
A character matrix of sequences with rows equal to the number of sera.
Other antigen and sera attribute functions:
agAttributes
,
agGroups()
,
agHomologousSr()
,
agLabIDs()
,
agSequences()
,
ptAnnotations
,
ptClades
,
srAttributes
,
srGroups()
,
srHomologousAgs()
This is a utility function to help standardise antigen names into a more consistent format, also attempting to break apart different components of the name.
standardizeStrainNames( names, default_species = NA, default_virus_type = "A", default_virus_subtype = "HXNX" )
standardizeStrainNames( names, default_species = NA, default_virus_type = "A", default_virus_subtype = "HXNX" )
names |
Strain names to be standardised |
default_species |
Are the strains isolated from a particular species? |
default_virus_type |
Default virus type to be used (if no type found in name) |
default_virus_subtype |
Default virus subtype to be used (if no subtype found in name) |
Returns a tibble of standardised names and extracted information
Get a stress table from an acmap
stressTable(map, optimization_number = 1)
stressTable(map, optimization_number = 1)
map |
The acmap object |
optimization_number |
The optimization number for which to calculate stresses |
Returns a matrix of stresses, showing how much each antigen and sera measurement contributes to stress in the selected or specified optimization.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapDistances()
,
mapResiduals()
,
pointStress
,
recalculateStress()
,
tableColbases()
,
tableDistances()
Functions to subset a list of maps to include only antigens, antigen groups, sera or serum groups that are in common between them.
subsetCommonAgs(maps) subsetCommonSrGroups(maps)
subsetCommonAgs(maps) subsetCommonSrGroups(maps)
maps |
A list of map data objects |
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetMap()
Subset an antigenic map to contain only specified antigens and sera
subsetMap(map, antigens = TRUE, sera = TRUE)
subsetMap(map, antigens = TRUE, sera = TRUE)
map |
The antigenic map object |
antigens |
Antigens to keep, defaults to all. |
sera |
Sera to keep, defaults to all. |
Returns a new antigenic map containing only match antigens and sera
Other functions for working with map data:
acmap()
,
addOptimization()
,
agReactivityAdjustments()
,
as.json()
,
edit_agNames()
,
edit_srNames()
,
keepBestOptimization()
,
keepSingleOptimization()
,
layerNames()
,
orderPoints
,
read.acmap()
,
read.titerTable()
,
removePoints
,
save.acmap()
,
save.coords()
,
save.titerTable()
,
subsetCommonPoints
For more information on column bases, what they mean and how they are
calculated see vignette("intro-to-antigenic-cartography")
tableColbases( titer_table, minimum_column_basis = "none", fixed_column_bases = rep(NA, ncol(titer_table)), ag_reactivity_adjustments = rep(0, nrow(titer_table)) )
tableColbases( titer_table, minimum_column_basis = "none", fixed_column_bases = rep(NA, ncol(titer_table)), ag_reactivity_adjustments = rep(0, nrow(titer_table)) )
titer_table |
The titer table |
minimum_column_basis |
The minimum column basis to assume |
fixed_column_bases |
Fixed column bases to apply |
ag_reactivity_adjustments |
Reactivity adjustments to apply on a per-antigen basis |
Returns a numeric vector of the log-converted column bases for the table
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableDistances()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapDistances()
,
mapResiduals()
,
pointStress
,
recalculateStress()
,
stressTable()
,
tableDistances()
Takes the acmap object and, assuming the column bases associated with the
currently selected or specified optimization, returns the table distances
calculated from the titer data. For more information on column bases and
their role in antigenic cartography see
vignette("intro-to-antigenic-cartography")
tableDistances(map, optimization_number = 1)
tableDistances(map, optimization_number = 1)
map |
The acmap data object |
optimization_number |
The optimization number |
Returns a matrix of numeric table distances
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
triangulationBlobs()
,
unstableMaps
Other functions relating to map stress calculation:
logtiterTable()
,
mapDistances()
,
mapResiduals()
,
pointStress
,
recalculateStress()
,
stressTable()
,
tableColbases()
Functions to get and set the map titer table. Note that when setting the titer table like this any titer table layer information is lost, this is normally not a problem unless the map is a result of merging two titer tables together previously and you then go on the merge the titers again.
titerTable(map) titerTable(map) <- value
titerTable(map) titerTable(map) <- value
map |
The acmap object |
value |
A character matrix of titers to set |
Returns a character matrix of titers.
adjustedTiterTable()
, htmlTiterTable()
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTableLayers()
These are underlying functions to get and set the "flat" version of the titer
table only. When a map is merged, the titer tables are merged but a record of
the original titers associated with each map are kept as titer table layers
so that information on the original set of titers that made up the merge is
not lost. At the same time, the merged titer version of the titer table is
created and saved as the titer_table_flat attribute. When you access titers
through the titerTable()
function, the flat version of the titer table is
retrieved (only really a relevant distinction for merged maps). When you set
titers through titerTable<-()
titer table layers are lost. These functions
allow you to manipulate the flat version without affecting the titer table
layers information.
titerTableFlat(map) titerTableFlat(map) <- value
titerTableFlat(map) titerTableFlat(map) <- value
map |
The acmap object |
value |
A character matrix of titers to set |
Returns a character matrix of titers.
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableLayers()
,
titerTable()
Functions to get and set the underlying titer table layers of a map (see details).
titerTableLayers(map) titerTableLayers(map) <- value
titerTableLayers(map) titerTableLayers(map) <- value
map |
The acmap object |
value |
A list of titer table character vectors to set |
When you merge maps with mergeMaps()
repeated antigen - serum
titers are merged to create a new titer table but information on the
original titers is not lost. The original titer tables, aligned to their
new positions in the merged table, are kept as separate layers that can be
accessed with these functions. If you have merged a whole bunch of
different maps, these functions can be useful to check for example,
variation in titer seen between a single antigen and serum pair.
A list of character matrices of titers.
Other map attribute functions:
acmapAttributes
,
adjustedLogTiterTable()
,
adjustedTiterTable()
,
dilutionStepsize()
,
logtiterTableLayers()
,
mapDescription()
,
mapName()
,
titerTableFlat()
,
titerTable()
Translates map coordinates
translateMap(map, translation, optimization_number = NULL)
translateMap(map, translation, optimization_number = NULL)
map |
The acmap object |
translation |
Translation to apply (as vector or n x 1 matrix) |
optimization_number |
The optimization number (or NULL to apply to all optimizations) |
An acmap object with transformation applied
Other functions relating to map transformation:
applyMapTransform()
,
reflectMap()
,
rotateMap()
This function is to help give an idea of how well coordinated each point is in a map, and to give some idea of uncertainty in it's position. It works by moving each point in a grid search and seeing how the total map stress changes, see details.
triangulationBlobs( map, optimization_number = 1, stress_lim = 1, grid_spacing = 0.25, antigens = TRUE, sera = TRUE, .check_relaxation = TRUE, .options = list() )
triangulationBlobs( map, optimization_number = 1, stress_lim = 1, grid_spacing = 0.25, antigens = TRUE, sera = TRUE, .check_relaxation = TRUE, .options = list() )
map |
The acmap data object |
optimization_number |
The optimization number to check |
stress_lim |
The blob stress limit |
grid_spacing |
Grid spacing to use when searching map space and inferring the blob |
antigens |
Should triangulation blobs be calculated for antigens |
sera |
Should triangulation blobs be calculated for sera |
.check_relaxation |
Should a check be performed that the map is fully relaxed (all points in a local optima) before the search is performed |
.options |
List of named optimizer options to use when checking map
relaxation, see |
The region or regions of the plot where total map stress is not
increased above a certain threshold (stress_lim
) are shown when the map
is plotted. This function is really to check whether point positions are
clearly very uncertain, for example the underlying titers may support an
antigen being a certain distance away from a group of other points but due
to the positions of the sera against which it was titrated the direction
would be unclear, and you might see a blob that forms an arc or "banana"
that represents this. Note that it is not really a confidence interval
since a point may be well coordinated in terms of the optimization but
it's position may still be defined by perhaps only one particular titer
which is itself uncertain. For something more akin to confidence intervals
you can use other diagnostic functions like bootstrapMap()
.
Returns the acmap data object with triangulation blob information added, which will be shown when the map is plotted
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
unstableMaps
Tips for exploring maps that are difficult to find a consistent optimal solution for.
Maps may be difficult to optimize or unstable for a variety of reasons, a common one with larger maps being simply that it is difficult to find a global optima and so many different local optima are found each time.
One approach that can sometimes
help is to consider running the optimizer with options = list(dim_annealing = TRUE)
(see see vignette("intro-to-antigenic-cartography")
for an explanation of the
dimensional annealing approach). However be wary that in our experience, while applying
dimensional annealing can sometimes significantly speed up finding a better minima, it
can also sometimes be more prone to getting stuck in worse local optima.
If there are many missing or non-detectable titers it is also
possible that points in map are too poorly connected to find a robust
solution, to check this see mapCohesion()
.
Other map diagnostic functions:
agCohesion()
,
bootstrapBlobs()
,
bootstrapMap()
,
checkHemisphering()
,
dimensionTestMap()
,
logtiterTable()
,
map-table-distances
,
mapBootstrapCoords
,
mapDistances()
,
mapRelaxed()
,
mapResiduals()
,
pointStress
,
ptBootstrapBlob
,
ptBootstrapCoords()
,
ptLeverage
,
ptTriangulationBlob
,
recalculateStress()
,
stressTable()
,
tableColbases()
,
tableDistances()
,
triangulationBlobs()
S3 method for viewing objects
view(x, ...)
view(x, ...)
x |
The object to view |
... |
Additional arguments, not used. |
When called on an acmap object, returns an htmlwidget object that can be used to interactively view the map. Otherwise by default it simply calls the print method of the respective object with no return value.
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view.default()
View a racmap object in the interactive viewer.
## S3 method for class 'acmap' view( x, optimization_number = 1, ..., .jsCode = NULL, .jsData = NULL, select_ags = NULL, select_sr = NULL, show_procrustes = NULL, show_diagnostics = NULL, num_optimizations = 1, options = list() )
## S3 method for class 'acmap' view( x, optimization_number = 1, ..., .jsCode = NULL, .jsData = NULL, select_ags = NULL, select_sr = NULL, show_procrustes = NULL, show_diagnostics = NULL, num_optimizations = 1, options = list() )
x |
The acmap data object |
optimization_number |
The optimization number to view |
... |
Additional arguments to be passed to |
.jsCode |
Additional javascript code to be run after map has been loaded and rendered |
.jsData |
Any data to supply to the .jsCode function |
select_ags |
A vector of antigen indices to select in the plot |
select_sr |
A vector of serum indices to select in the plot |
show_procrustes |
If the map contains procrustes information, should procrustes lines be shown by default? |
show_diagnostics |
If the map contains diagnostics information like stress blobs or hemisphering, should it be shown by default? |
num_optimizations |
Number of optimization runs to send to the viewer for inclusion in the "optimizations" pane. |
options |
A named list of viewer options to pass to
|
Returns an htmlwidget object
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.default()
,
view()
Other shiny app functions:
RacViewer-shiny
,
runGUI()
Default method for viewing objects
## Default S3 method: view(x, ...)
## Default S3 method: view(x, ...)
x |
The object to view |
... |
Additional arguments, passed to print. |
No value returned, simply calls the print method on the object
Other functions to view maps:
RacViewer.options()
,
RacViewer()
,
export_viewer()
,
ggplot.acmap()
,
mapGadget()
,
plot.acmap()
,
setLegend()
,
view.acmap()
,
view()