Learn R Programming

Racmacs

The Racmacs package provides a toolkit for making antigenic maps from assay data such as HI assays, as described in Smith et al. 2004.

For an introduction to antigenic cartography, see the article an introduction to antigenic cartography. For a general introduction to using Racmacs to make an antigenic map from titer data see the article making an antigenic map from titer data. For documentation of the functions available see the references section.

Installation instructions

Installing the latest CRAN release

Pre-compiled version of Racmacs can now be installed directly from CRAN with:

install.packages("Racmacs")

Installing the latest development release

The latest developmental release of Racmacs can be installed from github but may require some setting up of your compiler toolchain as described below.

Install the devtools package

If not already installed, install the devtools package, this provides functions to help with installation.

install.packages("devtools")

Install Racmacs

Now you can install Racmacs directly from the latest development source code. In future pre-built binary versions will also be included.

# To build from github source
devtools::install_github("acorg/Racmacs")

Problems compiling on MacOS

When installing Racmacs on a mac os, compilation will most likely fail under the default setup since the necessary libraries that are linked to cannot be found. The recommended solution, which should both solve this problem and speed up the code, is for mac users to follow the instructions below for setting up your environment to use the gcc and associated fortran compiler.

Building Racmacs to run code in parallel

Racmacs uses OpenMP instructions to specify when code can be run in parallel to increase performance. The resulting speed-up can be significant, but you need to check whether the compiler you use supports OpenMP.

The default compiler on mac systems for example is clang which does not support OpenMP and will fail anyway by default because it does not include a fortran compiler by default.

Installing gcc and a fortran compiler
The solution for both OpenMP support and provision of a fortran compiler on a mac system is to follow the guidance from the R project page for mac and install the official GNU Fortran binaries from F.X.Coudert found here.

Note that you have to install the correct version according to your hardware e.g. an intel or M1 mac, and for your correct OS. Also if you have an M1 mac, make sure that you have installed the M1 version of the R installer and not the intel one, otherwise loading the package will fail since R will have been compiled for an intel system and Racmacs for an M1 system.

The easiest method of installation is through finding the appropriate .dmg file which will contain an automatic installer for you rather than the .tar.xz source versions where you will have to deal with installation yourself.

Changing the default compiler in R
Once you have installed your fortran compiler and the packaged gcc compiler you need to change the default compiler in R. To do this you specify it in your local Makevars file. This exists in the .R folder in your home folder, i.e. ~/.R/Makevars. It is possible you will have to create the .R folder and the Makevars text file.

Once done, add the following lines to the Makevars file and update the paths to the appropriate path for each of the respective executables, for example:

CC=/usr/local/gfortran/bin/gcc
CXX=/usr/local/gfortran/bin/g++
CXX1X=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
SHLIB_CXXLD=/usr/local/gfortran/bin/g++
FC=/usr/local/gfortran/bin/gfortran
F77=/usr/local/gfortran/bin/gfortran
MAKE=make -j8

SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp

Now when you try and install and build the package from source things should be setup to use g++, with support for OpenMP parallelization now included.

Finally, to check whether your version of Racmacs has been compiled to work in parallel or not you can run the command Racmacs:::parallel_mode(), which should return TRUE. It's not a problem if it returns FALSE, optimization code just won't run in parallel so will take a bit longer.

Copy Link

Version

Install

install.packages('Racmacs')

Monthly Downloads

1,733

Version

1.2.9

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

S. Wilks

Last Published

November 30th, 2023

Functions in Racmacs (1.2.9)

agSequences

Getting and setting antigen sequence information
applyMapTransform

Apply the current map transformation
agLabIDs

Getting and setting antigen lab id information
blob

Plot a blob object
blobsize

Calculate size of a blob object
agAttributes

Getting and setting antigen attributes
adjustedTiterTable

Get the reactivity adjusted titer table
dimensionTestMap

Perform dimension testing on a map object
edit_agNames

Edit antigen names in an acmap
deprecated_functions

Deprecated functions
dilutionStepsize

Get or set the dilution stepsize associated with a map
ggplot.acmap

Plot an antigenic map using ggplot
export_viewer

Export the map viewer
edit_srNames

Edit sera names in an acmap
getOptimization

Get optimization details from an acmap object
mapDescription

Getting and setting the map description
htmlMergeReport

Return an html formatted merge report
mapComment

Get or set an optimization run comment
htmlAdjustedTiterTable

Return an html formatted titer table with antigen reactivity adjustments applied
checkHemisphering

Check for hemisphering or trapped points
colBases

Getting and setting column bases
keepBestOptimization

Keep only the lowest stress map optimization
mapBootstrapCoords

Get bootstrap coordinates associated with a map
htmlTiterTable

Return an html formatted titer table
listOptimizations

Get all optimization details from an acmap object
layerNames

Get and set map layer names
mergeMaps

Merging maps
matchStrains

Find matching antigens or sera between 2 maps
mapStress

Calculate the current map stress
mapTransformation

Reading map transformation data
agCohesion

Check map cohesion
mapName

Getting and setting the map name
mapGadget

Open a shiny gadget to view the map
agReactivityAdjustments

Get and set antigen reactivity adjustments
bootstrapMap

Perform a bootstrap on a map
keepOptimizations

Keep specified optimization runs
bootstrapBlobs

Calculate bootstrap blob data for an antigenic map
procrustesData

Return procrustes data on a map comparison
procrustesMap

Return procrustes information
optimizeMap

Optimize an acmap
ptDrawingOrder

Get and set point drawing order in map
mergeReport

Return a merge report
moveTrappedPoints

Move trapped points
ptLeverage

Calculate point leverage
ptBootstrapBlob

Get antigen or serum bootstrap blob information
keepSingleOptimization

Keep only a single optimization run
optimizeAgReactivity

Optimize antigen reactivity adjustments
logtiterTableLayers

Return a list of logtiter table layers
ptBootstrapCoords

Get antigen or serum bootstrap coordinates information
optimizationProperties

Get optimization properties
logtiterTable

Get the log titers from an acmap
mapDimensions

Get the current map dimensions
make.acmap

Make an antigenic map from scratch
map-table-distances

Plot map vs table distances
mapRelaxed

Check if a map has been fully relaxed
pointStress

Get individual point stress
plot.acmap

Plot an antigenic map
sortOptimizations

Sort optimizations by stress
randomizeCoords

Randomize map coordinates
ptBaseCoords

Getting and setting base coordinates
ptAnnotations

Getting and setting point annotation information
mapResiduals

Get a table of residuals from an acmap
ptOpacity

Set point opacity in a map
ptTriangulationBlob

Get antigen or serum triangulation blob information
ptStyles

Getting and setting point plotting styles
removeOptimizations

Remove map optimizations
mapDistances

Return calculated map distances for an acmap
read.acmap

Read in acmap data from a file
subsetMap

Subset an antigenic map
orderPoints

Order antigens and sera
read.titerTable

Read in a table of titer data
save.acmap

Save acmap data to a file
subsetCommonPoints

Remove antigens and sera
removePoints

Remove antigens and sera
recalculateStress

Recalculate the stress associated with an acmap optimization
tableColbases

Calculate column bases for a titer table
splitTiterLayers

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
tableDistances

Return calculated table distances for an acmap
save.coords

Save acmap coordinate data to a file
srHomologousAgs

Get and set homologous antigens for sera
relaxMap

Relax a map
relaxMapOneStep

Relax a map one step in the optimiser
titerTableLayers

Getting and setting titer table layers
ptClades

Getting and setting point clade information
reflectMap

Reflect a map
view.default

Default method for viewing objects
view.acmap

Viewing racmap objects
ptCoords

Getting and setting point coordinates
rotateMap

Rotate a map
realignOptimizations

Realigns optimizations in the map
realignMap

Realign map to match another
triangulationBlobs

Calculate triangulation blobs data for an antigenic map
unstableMaps

Notes on unstable maps
srSequences

Getting and setting sera sequence information
runGUI

Open the Racmacs GUI
stressTable

Get a stress table from an acmap
standardizeStrainNames

Standardize strain names
update_ferret_seraNames

Update the ferret serum names to match antigens
setLegend

Set acmap legend
translateMap

Translate a map
save.titerTable

Save titer data to a file
view

S3 method for viewing objects
srGroups

Getting and setting sera groups
srAttributes

Getting and setting sera attributes
titerTable

Getting and setting map titers
titerTableFlat

Getting and setting the flat titer table
addOptimization

Add a new optimization to an acmap object
acmap

Generate a new acmap object
Racmacs-package

Racmacs: Antigenic Cartography Macros
RacOptimizer.options

Set acmap optimization options
acmapAttributes

Get acmap attributes
RacMerge.options

Set acmap merge options
RacViewer

Create a RacViewer widget
RacViewer-shiny

Shiny bindings for RacViewer
adjustedLogTiterTable

Get the reactivity adjusted log titer table
RacViewer.options

Set viewer options
as.json

Convert map to json format
applyPlotspec

Apply a plotspec from another acmap
agGroups

Getting and setting antigen groups
agHomologousSr

Get homologous sera for each antigen