diff --git a/DESCRIPTION b/DESCRIPTION index 485e1e17..8ceefd73 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Racmacs Type: Package Title: R Antigenic Cartography Macros -Version: 1.1.30 +Version: 1.1.35 Date: 2022-02-23 Author: Sam Wilks Maintainer: Sam Wilks @@ -24,7 +24,8 @@ Imports: ellipsis, MASS, lifecycle, - igraph + igraph, + brotli LazyData: TRUE Suggests: testthat, diff --git a/NAMESPACE b/NAMESPACE index 6a349331..2c3548b5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export("agAnnotations<-") export("agAspect<-") export("agBaseCoords<-") export("agClades<-") +export("agContinent<-") export("agCoords<-") export("agDates<-") export("agExtra<-") @@ -16,20 +17,22 @@ export("agFill<-") export("agGroups<-") export("agIDs<-") export("agLabIDs<-") +export("agLineage<-") export("agNames<-") -export("agNamesAbbreviated<-") -export("agNamesFull<-") +export("agNucleotideSequences<-") export("agOpacity<-") export("agOutline<-") export("agOutlineWidth<-") export("agPassage<-") export("agReactivityAdjustments<-") +export("agReassortant<-") export("agReference<-") export("agRotation<-") export("agSequences<-") export("agShape<-") export("agShown<-") export("agSize<-") +export("agStrings<-") export("dilutionStepsize<-") export("fixedColBases<-") export("layerNames<-") @@ -52,19 +55,22 @@ export("srFill<-") export("srGroups<-") export("srHomologousAgs<-") export("srIDs<-") +export("srLineage<-") export("srNames<-") -export("srNamesAbbreviated<-") -export("srNamesFull<-") +export("srNucleotideSequences<-") export("srOpacity<-") export("srOutline<-") export("srOutlineWidth<-") export("srPassage<-") +export("srReassortant<-") export("srReference<-") export("srRotation<-") export("srSequences<-") export("srShape<-") export("srShown<-") export("srSize<-") +export("srSpecies<-") +export("srStrings<-") export("titerTable<-") export(RacMerge.options) export(RacOptimizer.options) @@ -82,6 +88,7 @@ export(agBootstrapBlob) export(agBootstrapCoords) export(agClades) export(agCohesion) +export(agContinent) export(agCoords) export(agDates) export(agExtra) @@ -90,13 +97,14 @@ export(agGroups) export(agIDs) export(agLabIDs) export(agLeverage) +export(agLineage) export(agNames) -export(agNamesAbbreviated) -export(agNamesFull) +export(agNucleotideSequences) export(agOutline) export(agOutlineWidth) export(agPassage) export(agReactivityAdjustments) +export(agReassortant) export(agReference) export(agRotation) export(agSequences) @@ -106,6 +114,7 @@ export(agSize) export(agStress) export(agStressBlobSize) export(agStressPerTiter) +export(agStrings) export(agTriangulationBlobSize) export(allMapDimensions) export(allMapStresses) @@ -163,6 +172,7 @@ export(numSera) export(numSeraGroups) export(optimizeAgReactivity) export(optimizeMap) +export(optimizeSubsetAgsIndividually) export(orderAntigens) export(orderSera) export(plot_map_table_distance) @@ -209,21 +219,24 @@ export(srGroups) export(srHomologousAgs) export(srIDs) export(srLeverage) +export(srLineage) export(srNames) -export(srNamesAbbreviated) -export(srNamesFull) +export(srNucleotideSequences) export(srOutline) export(srOutlineWidth) export(srPassage) +export(srReassortant) export(srReference) export(srRotation) export(srSequences) export(srShape) export(srShown) export(srSize) +export(srSpecies) export(srStress) export(srStressBlobSize) export(srStressPerTiter) +export(srStrings) export(srTriangulationBlobSize) export(standardizeStrainNames) export(stressBlobs) diff --git a/NEWS.md b/NEWS.md index 1bdf611c..e9a186ae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,4 @@ + # Racmacs 1.1.11 * Added a `NEWS.md` file to track changes to the package. * Added test and correction for error where coordinates of under-constrained points were set to NaN for the first optimization run only, not all. @@ -137,3 +138,27 @@ # Racmacs 1.1.31 * Added checks for disconnected groups of points and functions `mapCohesion()`, `agCohesion()`, `srCohesion()` to diagnose poorly connected groups of points * Add support for point transparency set either through `agOpacity()` and `srOpacity()` or appropriate hex code to the point fill or outline attribute e.g. `"#FF000099"`. + +# Racmacs 1.1.32 +* Disconnected maps now return an error rather than a warning +* `agStressPerTiter()` and `srStressPerTiter()` now return a matrix with columns corresponding to stress per titer when nd values are excluded and when they are included +* Corrected error when coloring maps by stress or showing error lines with disconnected points +* If a titer table has column or row names but not sera or antigen names provided, names will be taken from the row and column names when creating a map. +* Add support for reading maps with brotli compression +* `agSequences()` and `srSequences()` now works when the stored sequences have different lengths or are missing for some points +* Correct error where maps with duplicate antigen or serum names would not optimize + +# Racmacs 1.1.33 +* Add some basic support for viewing 1D maps +* Fix an issue viewing sequence data where sequence data is not present for all antigens / sera +* Fix an error reoptimize merging maps with no optimizations +* Add verbosity argument to `mergeMaps()` +* Verbosity argument also suppresses optimization progress messages +* Issue a warning if duplicate antigen or serum names are found when creating a map + +# Racmacs 1.1.34 +* Add support for getting and setting serum species with `srSpecies()`. +* Redundant attributes `agNamesAbbreviated`, `agNamesFull`, `srNamesAbbreviated`, `srNamesFull` removed + +# Racmacs 1.1.35 +* Add antigen and sera attributes: `agLineage()`, `srLineage()`, `agReassortant()`, `srReassortant()`, `agStrings()`, `srStrings()`, `agContinent()`, `agNucleotideSequences()`, `srNucleotideSequences()` diff --git a/R/RcppExports.R b/R/RcppExports.R index 2cd30ef1..b536a6cf 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -93,16 +93,24 @@ ac_ag_get_name <- function(ag) { .Call('_Racmacs_ac_ag_get_name', PACKAGE = 'Racmacs', ag) } -ac_ag_get_name_full <- function(ag) { - .Call('_Racmacs_ac_ag_get_name_full', PACKAGE = 'Racmacs', ag) +ac_ag_get_extra <- function(ag) { + .Call('_Racmacs_ac_ag_get_extra', PACKAGE = 'Racmacs', ag) } -ac_ag_get_name_abbreviated <- function(ag) { - .Call('_Racmacs_ac_ag_get_name_abbreviated', PACKAGE = 'Racmacs', ag) +ac_ag_get_lineage <- function(ag) { + .Call('_Racmacs_ac_ag_get_lineage', PACKAGE = 'Racmacs', ag) } -ac_ag_get_extra <- function(ag) { - .Call('_Racmacs_ac_ag_get_extra', PACKAGE = 'Racmacs', ag) +ac_ag_get_reassortant <- function(ag) { + .Call('_Racmacs_ac_ag_get_reassortant', PACKAGE = 'Racmacs', ag) +} + +ac_ag_get_strings <- function(ag) { + .Call('_Racmacs_ac_ag_get_strings', PACKAGE = 'Racmacs', ag) +} + +ac_ag_get_continent <- function(ag) { + .Call('_Racmacs_ac_ag_get_continent', PACKAGE = 'Racmacs', ag) } ac_ag_get_match_id <- function(ag) { @@ -149,16 +157,24 @@ ac_ag_set_name <- function(ag, value) { .Call('_Racmacs_ac_ag_set_name', PACKAGE = 'Racmacs', ag, value) } -ac_ag_set_name_full <- function(ag, value) { - .Call('_Racmacs_ac_ag_set_name_full', PACKAGE = 'Racmacs', ag, value) +ac_ag_set_extra <- function(ag, value) { + .Call('_Racmacs_ac_ag_set_extra', PACKAGE = 'Racmacs', ag, value) +} + +ac_ag_set_lineage <- function(ag, value) { + .Call('_Racmacs_ac_ag_set_lineage', PACKAGE = 'Racmacs', ag, value) } -ac_ag_set_name_abbreviated <- function(ag, value) { - .Call('_Racmacs_ac_ag_set_name_abbreviated', PACKAGE = 'Racmacs', ag, value) +ac_ag_set_reassortant <- function(ag, value) { + .Call('_Racmacs_ac_ag_set_reassortant', PACKAGE = 'Racmacs', ag, value) } -ac_ag_set_extra <- function(ag, value) { - .Call('_Racmacs_ac_ag_set_extra', PACKAGE = 'Racmacs', ag, value) +ac_ag_set_strings <- function(ag, value) { + .Call('_Racmacs_ac_ag_set_strings', PACKAGE = 'Racmacs', ag, value) +} + +ac_ag_set_continent <- function(ag, value) { + .Call('_Racmacs_ac_ag_set_continent', PACKAGE = 'Racmacs', ag, value) } ac_ag_set_group <- function(ag, value) { @@ -345,6 +361,10 @@ ac_sr_get_passage <- function(sr) { .Call('_Racmacs_ac_sr_get_passage', PACKAGE = 'Racmacs', sr) } +ac_sr_get_species <- function(sr) { + .Call('_Racmacs_ac_sr_get_species', PACKAGE = 'Racmacs', sr) +} + ac_sr_get_clade <- function(sr) { .Call('_Racmacs_ac_sr_get_clade', PACKAGE = 'Racmacs', sr) } @@ -357,16 +377,24 @@ ac_sr_get_name <- function(sr) { .Call('_Racmacs_ac_sr_get_name', PACKAGE = 'Racmacs', sr) } -ac_sr_get_name_full <- function(sr) { - .Call('_Racmacs_ac_sr_get_name_full', PACKAGE = 'Racmacs', sr) +ac_sr_get_extra <- function(sr) { + .Call('_Racmacs_ac_sr_get_extra', PACKAGE = 'Racmacs', sr) } -ac_sr_get_name_abbreviated <- function(sr) { - .Call('_Racmacs_ac_sr_get_name_abbreviated', PACKAGE = 'Racmacs', sr) +ac_sr_get_lineage <- function(sr) { + .Call('_Racmacs_ac_sr_get_lineage', PACKAGE = 'Racmacs', sr) } -ac_sr_get_extra <- function(sr) { - .Call('_Racmacs_ac_sr_get_extra', PACKAGE = 'Racmacs', sr) +ac_sr_get_reassortant <- function(sr) { + .Call('_Racmacs_ac_sr_get_reassortant', PACKAGE = 'Racmacs', sr) +} + +ac_sr_get_strings <- function(sr) { + .Call('_Racmacs_ac_sr_get_strings', PACKAGE = 'Racmacs', sr) +} + +ac_sr_get_continent <- function(sr) { + .Call('_Racmacs_ac_sr_get_continent', PACKAGE = 'Racmacs', sr) } ac_sr_get_match_id <- function(sr) { @@ -401,6 +429,10 @@ ac_sr_set_passage <- function(sr, value) { .Call('_Racmacs_ac_sr_set_passage', PACKAGE = 'Racmacs', sr, value) } +ac_sr_set_species <- function(sr, value) { + .Call('_Racmacs_ac_sr_set_species', PACKAGE = 'Racmacs', sr, value) +} + ac_sr_set_clade <- function(sr, value) { .Call('_Racmacs_ac_sr_set_clade', PACKAGE = 'Racmacs', sr, value) } @@ -413,16 +445,24 @@ ac_sr_set_name <- function(sr, value) { .Call('_Racmacs_ac_sr_set_name', PACKAGE = 'Racmacs', sr, value) } -ac_sr_set_name_full <- function(sr, value) { - .Call('_Racmacs_ac_sr_set_name_full', PACKAGE = 'Racmacs', sr, value) +ac_sr_set_extra <- function(sr, value) { + .Call('_Racmacs_ac_sr_set_extra', PACKAGE = 'Racmacs', sr, value) } -ac_sr_set_name_abbreviated <- function(sr, value) { - .Call('_Racmacs_ac_sr_set_name_abbreviated', PACKAGE = 'Racmacs', sr, value) +ac_sr_set_lineage <- function(sr, value) { + .Call('_Racmacs_ac_sr_set_lineage', PACKAGE = 'Racmacs', sr, value) } -ac_sr_set_extra <- function(sr, value) { - .Call('_Racmacs_ac_sr_set_extra', PACKAGE = 'Racmacs', sr, value) +ac_sr_set_reassortant <- function(sr, value) { + .Call('_Racmacs_ac_sr_set_reassortant', PACKAGE = 'Racmacs', sr, value) +} + +ac_sr_set_strings <- function(sr, value) { + .Call('_Racmacs_ac_sr_set_strings', PACKAGE = 'Racmacs', sr, value) +} + +ac_sr_set_continent <- function(sr, value) { + .Call('_Racmacs_ac_sr_set_continent', PACKAGE = 'Racmacs', sr, value) } ac_sr_set_homologous_ags <- function(sr, value) { @@ -469,8 +509,8 @@ ac_merge_tables <- function(maps, merge_options) { .Call('_Racmacs_ac_merge_tables', PACKAGE = 'Racmacs', maps, merge_options) } -ac_merge_reoptimized <- function(maps, num_dims, num_optimizations, optimizer_options, merge_options) { - .Call('_Racmacs_ac_merge_reoptimized', PACKAGE = 'Racmacs', maps, num_dims, num_optimizations, optimizer_options, merge_options) +ac_merge_reoptimized <- function(maps, num_dims, num_optimizations, min_col_basis, optimizer_options, merge_options) { + .Call('_Racmacs_ac_merge_reoptimized', PACKAGE = 'Racmacs', maps, num_dims, num_optimizations, min_col_basis, optimizer_options, merge_options) } ac_merge_frozen_overlay <- function(maps, merge_options) { diff --git a/R/map_loadsave.R b/R/map_loadsave.R index 58119e57..da6783ec 100644 --- a/R/map_loadsave.R +++ b/R/map_loadsave.R @@ -30,7 +30,17 @@ read.acmap <- function( # Read the data from the file jsondata <- paste(readLines(filename, warn = FALSE), collapse = "\n") - map <- json_to_acmap(jsondata) + map <- tryCatch( + json_to_acmap(jsondata), + error = function(e) { + tryCatch( + read_brotli(filename), + error = function(e) { + stop("File '", filename, "' could not be parsed", call. = FALSE) + } + ) + } + ) # Apply arguments if (!is.null(optimization_number)) { @@ -48,6 +58,13 @@ read.acmap <- function( } +# Function to read brotli compressed maps +read_brotli <- function(filepath) { + bin_file <- readBin(filepath, "raw", file.info(filepath)$size) + bin_uncompressed <- brotli::brotli_decompress(bin_file) + json_to_acmap(rawToChar(bin_uncompressed)) +} + #' Save acmap data to a file #' diff --git a/R/map_merge.R b/R/map_merge.R index 5b84d344..47508211 100644 --- a/R/map_merge.R +++ b/R/map_merge.R @@ -14,6 +14,7 @@ #' @param merge_options Options to use when merging titers (see `RacMerge.options()`). #' @param optimizer_options For merging that generates new optimization runs, optimizer #' settings (see `RacOptimizer.options()`). +#' @param verbose Should progress messages be output? #' #' @details Maps can be merged in a number of ways depending upon the desired #' result. @@ -62,7 +63,8 @@ mergeMaps <- function( number_of_optimizations, minimum_column_basis = "none", optimizer_options = list(), - merge_options = list() + merge_options = list(), + verbose = TRUE ) { # Process input @@ -93,6 +95,7 @@ mergeMaps <- function( # Set options for any relaxation or optimizations optimizer_options <- do.call(RacOptimizer.options, optimizer_options) merge_options <- do.call(RacMerge.options, merge_options) + if (!verbose) optimizer_options$report_progress <- FALSE # Set the dilution stepsize for merging merge_options$dilution_stepsize <- mean(vapply(maps, dilutionStepsize, numeric(1))) @@ -113,6 +116,7 @@ mergeMaps <- function( maps = maps, num_dims = number_of_dimensions, num_optimizations = number_of_optimizations, + min_col_basis = minimum_column_basis, optimizer_options = optimizer_options, merge_options = merge_options ) diff --git a/R/map_new.R b/R/map_new.R index ae44b532..d77985ff 100644 --- a/R/map_new.R +++ b/R/map_new.R @@ -10,6 +10,8 @@ #' @param ag_coords Antigenic coordinates for an optimization run record #' (optional) #' @param sr_coords Sera coordinates for an optimization run record (optional) +#' @param check_duplicates Issue a warning if duplicate antigen or sera names +#' are found #' @param ... Further arguments passed to `addOptimization()` #' #' @return Returns the new acmap object @@ -32,6 +34,7 @@ acmap <- function( titer_table = NULL, ag_coords = NULL, sr_coords = NULL, + check_duplicates = TRUE, ... ) { @@ -60,8 +63,18 @@ acmap <- function( ) # Populate the map - if (!is.null(ag_names)) agNames(map) <- ag_names - if (!is.null(sr_names)) srNames(map) <- sr_names + if (!is.null(ag_names)) { + agNames(map) <- ag_names + } else if (!is.null(rownames(titer_table))) { + agNames(map) <- rownames(titer_table) + } + + if (!is.null(sr_names)) { + srNames(map) <- sr_names + } else if (!is.null(colnames(titer_table))) { + srNames(map) <- colnames(titer_table) + } + if (!is.null(titer_table)) titerTable(map) <- titer_table if (!is.null(ag_coords) || !is.null(sr_coords)) { @@ -77,6 +90,12 @@ acmap <- function( } } + # Check for duplicate names + if (check_duplicates) { + if (sum(duplicated(agNames(map))) > 0) warning("Map contains duplicate antigen names") + if (sum(duplicated(srNames(map))) > 0) warning("Map contains duplicate sera names") + } + # Return the new map map diff --git a/R/map_optimize.R b/R/map_optimize.R index 514e62a9..f95d5e58 100644 --- a/R/map_optimize.R +++ b/R/map_optimize.R @@ -69,6 +69,7 @@ optimizeMap <- function( # Get optimizer options options <- do.call(RacOptimizer.options, options) + if (!verbose) options$report_progress <- FALSE # Perform the optimization runs tstart <- Sys.time() @@ -90,7 +91,13 @@ optimizeMap <- function( if (sum(sr_underconstrained) > 0) warn_underconstrained("SERA", srNames(map)[sr_underconstrained], number_of_dimensions) # Check for unconnected sets of points - if (mapDisconnected(map)) warning(no_cohesion_warning(), call. = F) + if (!options$ignore_disconnected && mapDisconnected(map)) { + stop(singleline( + "Map contains disconnected points (points that are not connected through + any path of detectable titers so cannot be coordinated relative to each other). + To optimize anyway, rerun with 'options = list(ignore_disconnected = TRUE)'." + ), call. = F) + } map <- ac_optimize_map( map = map, @@ -126,10 +133,12 @@ optimizeMap <- function( # Check procrustes of the top 2 runs to see if there is much difference between them if (check_convergence && numOptimizations(map) > 1) { - procrustes_dists <- c( - procrustesData(map, map, comparison_optimization_number = 2)$ag_dists, - procrustesData(map, map, comparison_optimization_number = 2)$sr_dists - ) + pcmap <- map + agNames(pcmap) <- paste("AG", seq_len(numAntigens(pcmap))) + srNames(pcmap) <- paste("SR", seq_len(numSera(pcmap))) + + procrustes_data <- procrustesData(pcmap, pcmap, comparison_optimization_number = 2) + procrustes_dists <- c(procrustes_data$ag_dists, procrustes_data$sr_dists) if (max(procrustes_dists, na.rm = T) > 0.5) { warning(sprintf( @@ -228,6 +237,7 @@ make.acmap <- function( #' @param maxit The maximum number of iterations to use in the optimizer #' @param num_cores The number of cores to run in parallel #' @param report_progress Should progress be reported +#' @param ignore_disconnected Should the check for disconnected points be skipped #' @param progress_bar_length Progress bar length when progress is reported #' #' @details For more details, for example on "dimensional annealing" see @@ -246,11 +256,13 @@ RacOptimizer.options <- function( maxit = 1000, num_cores = parallel::detectCores(), report_progress = NULL, + ignore_disconnected = FALSE, progress_bar_length = options()$width ) { # Check input check.logical(dim_annealing) + check.logical(ignore_disconnected) check.string(method) check.numeric(maxit) check.numeric(num_cores) @@ -269,6 +281,7 @@ RacOptimizer.options <- function( method = method, maxit = maxit, num_cores = num_cores, + ignore_disconnected = ignore_disconnected, report_progress = report_progress, progress_bar_length = progress_bar_length ) @@ -588,6 +601,76 @@ moveTrappedPoints <- function( } + +#' Optimize a subset of antigens individually +#' +#' You may have a large subset of antigens that distort the positions of +#' reference antigens and antisera. It can be useful to make a map containing +#' only reference antigens and antisera, and add each antigen in the subset to +#' the reference map individually. The resulting reference maps containing one +#' additional antigen are then aligned, and the positions of the additional +#' antigen in their individual map are shown. +#' +#' A common use case might be if you want to introduce many tens, or even +#' hundreds, of mutants into an existing map, without the geometric patterns in +#' the mutant's titrations swamping those between the existing antigens and +#' sera. +#' +#' @param map The acmap object +#' @param subset A list of antigen names to optimize individually. +#' @param ... Arguments passed to optimizeMap. number_of_dimensions and +#' number_of_optimizations are mandatory. +#' +#' @return List containing 'merge' and 'individual'. 'merge' is the reference +#' map with with the positions of antigens in the subset overlain. +#' 'individual' is a list containing each of the individual maps. +#' @family {map optimization functions} +#' @export +#' +optimizeSubsetAgsIndividually <- function(map, subset, ...) { + + # Map lacking any antigen in the subset + refMap <- optimizeMap(removeAntigens(map, subset), ...) + + # For storing coordinates of antigens in the subset + subsetCoords <- matrix(nrow = length(subset), ncol = mapDimensions(map)) + + maps <- list() + + for (i in 1:length(subset)) { + # Remove all antigens in subset, except the ith + subsetMap <- removeAntigens(map, subset[-i]) + + # Optimize and align to reference + subsetMap <- optimizeMap(subsetMap, ...) + subsetMap <- realignMap(subsetMap, target_map = refMap) + coords <- agCoords(subsetMap) + + # Find coordinates of remaining antigen in subset + ag <- subset[i] # Name of the antigen + pos <- match(ag, agNames(subsetMap)) # Position of the antigen + subsetCoords[i,] <- coords[pos,] + + # Store map + maps[ag] <- list(subsetMap) + } + + # Make an acmap object, stitching together ag coordinates from the reference + # map, and coordinates of antigens in the subset + merge = acmap( + ag_names = c(agNames(refMap), subset), + sr_names = srNames(map), + ag_coords = rbind(agCoords(refMap), subsetCoords), + sr_coords = srCoords(refMap), + titer_table = titerTable(map), + ) + merge <- applyPlotspec(map = merge, source_map = map) + + # Return the merge and the individual maps + list(merge = merge, individual = maps) + +} + # Functions for fetching hemisphering information agHemisphering <- function(map, optimization_number = 1) { lapply(agDiagnostics(map, optimization_number), function(ag) ag$hemi) @@ -629,15 +712,6 @@ warn_disconnected <- function(type, strains, number_of_dimensions) { ) } -# Warnings to use -no_cohesion_warning <- function() { - singleline( - "Some sets of points are entirely disconnected from each other meaning that the - resulting map will consist of disconnected sets of points that are not coordinated - relative to each other." - ) -} - # Calculate map connectivity mapConnectivityGraph <- function(map) { diff --git a/R/map_props_points_antigens.R b/R/map_props_points_antigens.R index a18abf06..eeb003ab 100644 --- a/R/map_props_points_antigens.R +++ b/R/map_props_points_antigens.R @@ -58,10 +58,12 @@ antigens_setter <- function(fn, type) { #' "agDates", "agDates<-", #' "agReference", "agReference<-", #' "agNames", "agNames<-", -#' "agNamesFull", "agNamesFull<-", -#' "agNamesAbbreviated", "agNamesAbbreviated<-", #' "agExtra", "agExtra<-", -#' "agPassage", "agPassage<-" +#' "agPassage", "agPassage<-", +#' "agLineage", "agLineage<-", +#' "agReassortant", "agReassortant<-", +#' "agStrings", "agStrings<-", +#' "agContinent", "agContinent<-" #' ), #' args = c("map") #' ) @@ -70,10 +72,12 @@ agIDs <- antigens_getter(ac_ag_get_id) agDates <- antigens_getter(ac_ag_get_date) agReference <- antigens_getter(ac_ag_get_reference) agNames <- antigens_getter(ac_ag_get_name) -agNamesFull <- antigens_getter(ac_ag_get_name_full) -agNamesAbbreviated <- antigens_getter(ac_ag_get_name_abbreviated) agExtra <- antigens_getter(ac_ag_get_extra) agPassage <- antigens_getter(ac_ag_get_passage) +agLineage <- antigens_getter(ac_ag_get_lineage) +agReassortant <- antigens_getter(ac_ag_get_reassortant) +agStrings <- antigens_getter(ac_ag_get_strings) +agContinent <- antigens_getter(ac_ag_get_continent) agGroupValues <- antigens_getter(ac_ag_get_group) # Not exported agMatchIDs <- antigens_getter(ac_ag_get_match_id) # Not exported @@ -81,10 +85,12 @@ agMatchIDs <- antigens_getter(ac_ag_get_match_id) # Not exported `agDates<-` <- antigens_setter(ac_ag_set_date, "character") `agReference<-` <- antigens_setter(ac_ag_set_reference, "character") `agNames<-` <- antigens_setter(ac_ag_set_name, "character") -`agNamesFull<-` <- antigens_setter(ac_ag_set_name_full, "character") -`agNamesAbbreviated<-` <- antigens_setter(ac_ag_set_name_abbreviated, "character") `agExtra<-` <- antigens_setter(ac_ag_set_extra, "character") `agPassage<-` <- antigens_setter(ac_ag_set_passage, "character") +`agLineage<-` <- antigens_setter(ac_ag_set_lineage, "character") +`agReassortant<-` <- antigens_setter(ac_ag_set_reassortant, "character") +`agStrings<-` <- antigens_setter(ac_ag_set_strings, "character") +`agContinent<-` <- antigens_setter(ac_ag_set_continent, "character") `agGroupValues<-` <- antigens_setter(ac_ag_set_group, "numeric") # Not exported @@ -134,6 +140,8 @@ agGroups <- function(map) { #' Getting and setting antigen sequence information #' #' @param map The acmap data object +#' @param missing_value Character to use to fill in portions of the sequence matrix +#' where sequence data is missing. #' @param value A character matrix of sequences with rows equal to the number of #' antigens #' @@ -143,13 +151,13 @@ agGroups <- function(map) { #' @rdname agSequences #' @export -agSequences <- function(map) { +agSequences <- function(map, missing_value = ".") { check.acmap(map) - do.call( - rbind, + rbind_list_to_matrix( lapply(map$antigens, function(ag) { strsplit(ag$sequence, "")[[1]] - }) + }), + missing_value ) } @@ -166,6 +174,35 @@ agSequences <- function(map) { map } +#' @rdname agSequences +#' @export +agNucleotideSequences <- function(map, missing_value = ".") { + check.acmap(map) + rbind_list_to_matrix( + lapply(map$antigens, function(ag) { + strsplit(ag$nucleotidesequence, "")[[1]] + }), + missing_value + ) +} + +#' @rdname agSequences +#' @export +`agNucleotideSequences<-` <- function(map, value) { + check.acmap(map) + if (nrow(value) != numAntigens(map)) { + stop("Number of sequences does not match number of antigens") + } + for (x in seq_len(numAntigens(map))) { + map$antigens[[x]]$nucleotidesequence <- paste0(value[x, ], collapse = "") + } + map +} + + + + + #' Getting and setting point clade information #' diff --git a/R/map_props_points_sera.R b/R/map_props_points_sera.R index cb94af2e..102f90ce 100644 --- a/R/map_props_points_sera.R +++ b/R/map_props_points_sera.R @@ -56,10 +56,12 @@ sera_setter <- function(fn, type) { #' "srDates", "srDates<-", #' "srReference", "srReference<-", #' "srNames", "srNames<-", -#' "srNamesFull", "srNamesFull<-", -#' "srNamesAbbreviated", "srNamesAbbreviated<-", #' "srExtra", "srExtra<-", -#' "srPassage", "srPassage<-" +#' "srPassage", "srPassage<-", +#' "srLineage", "srLineage<-", +#' "srReassortant", "srReassortant<-", +#' "srStrings", "srStrings<-", +#' "srSpecies", "srSpecies<-" #' ), #' args = c("map") #' ) @@ -68,10 +70,12 @@ srIDs <- sera_getter(ac_sr_get_id) srDates <- sera_getter(ac_sr_get_date) srReference <- sera_getter(ac_sr_get_reference) srNames <- sera_getter(ac_sr_get_name) -srNamesFull <- sera_getter(ac_sr_get_name_full) -srNamesAbbreviated <- sera_getter(ac_sr_get_name_abbreviated) srExtra <- sera_getter(ac_sr_get_extra) srPassage <- sera_getter(ac_sr_get_passage) +srLineage <- sera_getter(ac_sr_get_lineage) +srReassortant <- sera_getter(ac_sr_get_reassortant) +srStrings <- sera_getter(ac_sr_get_strings) +srSpecies <- sera_getter(ac_sr_get_species) srGroupValues <- sera_getter(ac_sr_get_group) # Not exported srMatchIDs <- sera_getter(ac_sr_get_match_id) # Not exported @@ -79,10 +83,12 @@ srMatchIDs <- sera_getter(ac_sr_get_match_id) # Not exported `srDates<-` <- sera_setter(ac_sr_set_date, "character") `srReference<-` <- sera_setter(ac_sr_set_reference, "character") `srNames<-` <- sera_setter(ac_sr_set_name, "character") -`srNamesFull<-` <- sera_setter(ac_sr_set_name_full, "character") -`srNamesAbbreviated<-` <- sera_setter(ac_sr_set_name_abbreviated, "character") `srExtra<-` <- sera_setter(ac_sr_set_extra, "character") `srPassage<-` <- sera_setter(ac_sr_set_passage, "character") +`srLineage<-` <- sera_setter(ac_sr_set_lineage, "character") +`srReassortant<-` <- sera_setter(ac_sr_set_reassortant, "character") +`srStrings<-` <- sera_setter(ac_sr_set_strings, "character") +`srSpecies<-` <- sera_setter(ac_sr_set_species, "character") `srGroupValues<-` <- sera_setter(ac_sr_set_group, "numeric") @@ -163,6 +169,8 @@ srGroups <- function(map) { #' Getting and setting sera sequence information #' #' @param map The acmap data object +#' @param missing_value Character to use to fill in portions of the sequence matrix +#' where sequence data is missing. #' @param value A character matrix of sequences with rows equal to the number of #' sera #' @@ -172,13 +180,13 @@ srGroups <- function(map) { #' @rdname srSequences #' @export -srSequences <- function(map) { +srSequences <- function(map, missing_value = ".") { check.acmap(map) - do.call( - rbind, + rbind_list_to_matrix( lapply(map$sera, function(sr) { strsplit(sr$sequence, "")[[1]] - }) + }), + missing_value ) } @@ -194,3 +202,28 @@ srSequences <- function(map) { } map } + +#' @rdname srSequences +#' @export +srNucleotideSequences <- function(map, missing_value = ".") { + check.acmap(map) + rbind_list_to_matrix( + lapply(map$sera, function(sr) { + strsplit(sr$nucleotidesequence, "")[[1]] + }), + missing_value + ) +} + +#' @rdname srSequences +#' @export +`srNucleotideSequences<-` <- function(map, value) { + check.acmap(map) + if (nrow(value) != numSera(map)) { + stop("Number of sequences does not match number of sera") + } + for (x in seq_len(numSera(map))) { + map$sera[[x]]$nucleotidesequence <- paste0(value[x, ], collapse = "") + } + map +} diff --git a/R/map_stress.R b/R/map_stress.R index 27433de3..73f4b268 100644 --- a/R/map_stress.R +++ b/R/map_stress.R @@ -282,8 +282,6 @@ recalculateStress <- function( #' name (defaults to all antigens). #' @param sera Which sera to check stress for, specified by index or name #' (defaults to all sera). -#' @param exclude_nd Should non-detectable values (e.g. <10) be excluded when -#' calculating point stress? #' #' @seealso See `mapStress()` for getting the total map stress directly. #' @family {map diagnostic functions} @@ -334,8 +332,7 @@ srStress <- function( srStressPerTiter <- function( map, sera = TRUE, - optimization_number = 1, - exclude_nd = FALSE + optimization_number = 1 ) { # Convert to indices @@ -348,12 +345,21 @@ srStressPerTiter <- function( ) # Exclude nd values - if (exclude_nd) stress_table[titertypesTable(map) != 1] <- NA + stress_table_nd_excluded <- stress_table + stress_table_nd_excluded[titertypesTable(map) != 1] <- NA # Calculate the antigen stress per titer stresses <- colMeans(stress_table, na.rm = T) stresses[is.na(srCoords(map))[,1]] <- NA - stresses[sera] + + stresses_nd_excluded <- colMeans(stress_table_nd_excluded, na.rm = T) + stresses_nd_excluded[is.na(srCoords(map))[,1]] <- NA + + # Return a matrix + result <- cbind(stresses, stresses_nd_excluded) + colnames(result) <- c("nd_included", "nd_excluded") + rownames(result) <- srNames(map) + result[sera, , drop = F] } @@ -363,8 +369,7 @@ srStressPerTiter <- function( agStressPerTiter <- function( map, antigens = TRUE, - optimization_number = 1, - exclude_nd = FALSE + optimization_number = 1 ) { # Convert to indices @@ -377,12 +382,21 @@ agStressPerTiter <- function( ) # Exclude nd values - if (exclude_nd) stress_table[titertypesTable(map) != 1] <- NA + stress_table_nd_excluded <- stress_table + stress_table_nd_excluded[titertypesTable(map) != 1] <- NA # Calculate the antigen stress per titer stresses <- rowMeans(stress_table, na.rm = T) stresses[is.na(agCoords(map))[,1]] <- NA - stresses[antigens] + + stresses_nd_excluded <- rowMeans(stress_table_nd_excluded, na.rm = T) + stresses_nd_excluded[is.na(agCoords(map))[,1]] <- NA + + # Return a matrix + result <- cbind(stresses, stresses_nd_excluded) + colnames(result) <- c("nd_included", "nd_excluded") + rownames(result) <- agNames(map) + result[antigens, , drop = F] } diff --git a/R/plot_diagnostics.R b/R/plot_diagnostics.R index 029d63e4..e2c1efb6 100644 --- a/R/plot_diagnostics.R +++ b/R/plot_diagnostics.R @@ -220,20 +220,34 @@ plotly_sr_titers <- function( } -agMeanResiduals <- function(map, exclude_nd = TRUE) { +agMeanResiduals <- function(map) { residuals <- mapResiduals(map) - if (exclude_nd) residuals[titertypesTable(map) != 1] <- NA - rowMeans(residuals, na.rm = T) + residuals_nd_excluded <- residuals + residuals_nd_excluded[titertypesTable(map) != 1] <- NA + result <- cbind( + rowMeans(residuals, na.rm = T), + rowMeans(residuals_nd_excluded, na.rm = T) + ) + rownames(result) <- agNames(map) + colnames(result) <- c("nd_included", "nd_excluded") + result } -srMeanResiduals <- function(map, exclude_nd = TRUE) { +srMeanResiduals <- function(map) { residuals <- mapResiduals(map) - if (exclude_nd) residuals[titertypesTable(map) != 1] <- NA - colMeans(residuals, na.rm = T) + residuals_nd_excluded <- residuals + residuals_nd_excluded[titertypesTable(map) != 1] <- NA + result <- cbind( + colMeans(residuals, na.rm = T), + colMeans(residuals_nd_excluded, na.rm = T) + ) + rownames(result) <- srNames(map) + colnames(result) <- c("nd_included", "nd_excluded") + result } @@ -241,13 +255,9 @@ srMeanResiduals <- function(map, exclude_nd = TRUE) { plot_agMeanResiduals <- function(map, exclude_nd = TRUE, .plot = TRUE) { hist_ggplot( names = agNames(map), - values = agMeanResiduals(map, exclude_nd), + values = agMeanResiduals(map)[,ifelse(exclude_nd, "nd_excluded", "nd_included")], title = "Antigen mean residual error", - subtitle = switch( - exclude_nd, - "TRUE" = "(nd excluded)", - "FALSE" = "(nd excluded)" - ), + subtitle = ifelse(exclude_nd, "(nd excluded)", "(nd excluded)"), vline = 0, .plot = .plot ) @@ -257,13 +267,9 @@ plot_agMeanResiduals <- function(map, exclude_nd = TRUE, .plot = TRUE) { plot_srMeanResiduals <- function(map, exclude_nd = TRUE, .plot = TRUE) { hist_ggplot( names = srNames(map), - values = srMeanResiduals(map, exclude_nd), + values = srMeanResiduals(map)[,ifelse(exclude_nd, "nd_excluded", "nd_included")], title = "Serum mean residual error", - subtitle = switch( - exclude_nd, - "TRUE" = "(nd excluded)", - "FALSE" = "(nd excluded)" - ), + subtitle = ifelse(exclude_nd, "(nd excluded)", "(nd excluded)"), vline = 0, .plot = .plot ) @@ -283,7 +289,7 @@ plot_agStressPerTiter <- function( hist_ggplot( names = agNames(map), - values = agStressPerTiter(map, exclude_nd = exclude_nd), + values = agStressPerTiter(map)[,ifelse(exclude_nd, "nd_excluded", "nd_included")], title = "Antigen stress per titer", subtitle = switch( exclude_nd, @@ -309,7 +315,7 @@ plot_srStressPerTiter <- function( hist_ggplot( names = srNames(map), - values = srStressPerTiter(map, exclude_nd = exclude_nd), + values = srStressPerTiter(map)[,ifelse(exclude_nd, "nd_excluded", "nd_included")], title = "Serum stress per titer", subtitle = switch( exclude_nd, diff --git a/R/utils_matrix_getters.R b/R/utils_matrix_getters.R index 757cf464..9cf0c2c4 100644 --- a/R/utils_matrix_getters.R +++ b/R/utils_matrix_getters.R @@ -68,3 +68,12 @@ srGroupOutline <- function(map) { names(sr_group_outlines) <- sr_groups sr_group_outlines } + +rbind_list_to_matrix <- function(x, missing_value = ".") { + maxlen <- max(vapply(x, length, numeric(1))) + x <- lapply(x, function(xi) { + missing_length <- maxlen - length(xi) + c(xi, rep(missing_value, missing_length)) + }) + do.call(rbind, x) +} diff --git a/R/utils_type_checking.R b/R/utils_type_checking.R index 6deaf137..f9bf9f80 100644 --- a/R/utils_type_checking.R +++ b/R/utils_type_checking.R @@ -27,6 +27,13 @@ check.numeric <- function(x) { x } +check.integer <- function(x) { + if (length(x) > 1 || !is.wholenumber(x)) { + stop("Input must be a single integer", call. = FALSE) + } + x +} + check.numericmatrix <- function(x) { if (!is.matrix(x) || !is.numeric(x)) { stop("Input must be a numeric matrix", call. = FALSE) diff --git a/inst/htmlwidgets/RacViewer/lib/functions/agsr.js b/inst/htmlwidgets/RacViewer/lib/functions/agsr.js index d25fd1df..727df209 100644 --- a/inst/htmlwidgets/RacViewer/lib/functions/agsr.js +++ b/inst/htmlwidgets/RacViewer/lib/functions/agsr.js @@ -118,6 +118,7 @@ Racmacs.Point = class Point { this.coords_na = args.coords === null || isNaN(args.coords[0]) || args.coords[0] === null; if(this.coords_na){ this.coords3 = [0,0,0]; + this.shown = false; } else { this.coords3 = args.coords.slice(); while(this.coords3.length < 3){ this.coords3.push(0) } @@ -177,15 +178,17 @@ Racmacs.Point = class Point { // Show point information showInfo(){ - this.infoDiv = document.createElement("div"); - this.infoDiv.innerHTML = this.name; + if (this.shown) { + this.infoDiv = document.createElement("div"); + this.infoDiv.innerHTML = this.name; - if(this.viewer.coloring == "stress"){ - this.infoDiv.innerHTML += ", Stress : "+this.stress.toFixed(2); - this.infoDiv.innerHTML += ", Mean stress : "+this.meanstress.toFixed(2); + if(this.viewer.coloring == "stress"){ + this.infoDiv.innerHTML += ", Stress : "+this.stressval.toFixed(2); + this.infoDiv.innerHTML += ", Mean stress : "+this.meanstress.toFixed(2); + } + + this.viewer.addHoverInfo(this.infoDiv); } - - this.viewer.addHoverInfo(this.infoDiv); } @@ -293,9 +296,10 @@ Racmacs.Point = class Point { if(this.blob){ this.removeBlob(); } - + if(isNaN(to[0]) || isNaN(to[1]) || isNaN(to[2])){ this.coords_na = true; + this.shown = false; to[0] = 0; to[1] = 0; to[2] = 0; @@ -454,7 +458,8 @@ Racmacs.Point = class Point { this.fillopacity = 0; } else { // If color is not transparent - this.element.setFillOpacity(this.opacity); + if (this.fillopacity == 0) this.fillopacity = this.viewer.styleset.noselections.unhovered.unselected.opacity; + this.element.setFillOpacity(this.fillopacity); this.element.setFillColor(col); } } @@ -528,17 +533,19 @@ Racmacs.Point = class Point { // Calculate the mean stress for this point calcMeanStress(){ + if (this.coords_na) return(NaN); var num_detectable = 0; var stress = 0; for(var i=0; i p.A.split("") )); - else return(this.data.c.a[i].A.split("")); - } else if(this.data.c.x && this.data.c.x.a && this.data.c.x.a[0].q){ - if(i === undefined) return(this.data.c.x.a.map( p => p.q.split("") )); - else return(this.data.c.x.a[i].q.split("")); - } else { - return(null); - } + agSequences(){ + + let seqs = this.data.c.a.map((p, i) => { + if (p.A) { + return(p.A.split("")); + } else if (this.data.c.x && this.data.c.x.a && this.data.c.x.a[i].q) { + return(this.data.c.x.a[i].q.split("")); + } else { + return([]); + } + }); + let maxlen = Math.max(...seqs.map(s => s.length)); + seqs = seqs.map(s => { + while(s.length < maxlen) { + s.push("."); + } + return(s); + }); + return(seqs); + } - srSequences(i){ - if(this.data.c.s[0].A) { - if(i === undefined) return(this.data.c.s.map( p => p.A.split("") )); - else return(this.data.c.s[i].A.split("")); - } else if(this.data.c.x && this.data.c.x.s && this.data.c.x.s[0].q){ - if(i === undefined) return(this.data.c.x.s.map( p => p.q.split("") )); - else return(this.data.c.x.s[i].q.split("")); - } else { - return(null); - } + srSequences(){ + + let seqs = this.data.c.s.map((p, i) => { + if (p.A) { + return(p.A.split("")); + } else if (this.data.c.x && this.data.c.x.s && this.data.c.x.s[i].q) { + return(this.data.c.x.s[i].q.split("")); + } else { + return([]); + } + }); + let maxlen = Math.max(...seqs.map(s => s.length)); + seqs = seqs.map(s => { + while(s.length < maxlen) { + s.push("."); + } + return(s); + }); + return(seqs); + } colbases(i=null){ diff --git a/inst/htmlwidgets/RacViewer/lib/functions/dimensions.js b/inst/htmlwidgets/RacViewer/lib/functions/dimensions.js index f962ba13..408049c5 100644 --- a/inst/htmlwidgets/RacViewer/lib/functions/dimensions.js +++ b/inst/htmlwidgets/RacViewer/lib/functions/dimensions.js @@ -10,7 +10,7 @@ Racmacs.Viewer.prototype.setPlotDims = function(plotdims){ ); // this.scene.plotPoints.scale.set(1,1,1); - if(plotdims.dimensions == 2){ + if(plotdims.dimensions <= 2){ // Rebind navigation this.mouseMove = this.panScene; @@ -84,7 +84,7 @@ Racmacs.Viewer.prototype.setDims = function( if (mapdims.zlim) this.mapdims.lims[2] = mapdims.zlim; // Work out map lims and aspect - if(this.mapdims.dimensions == 2) { + if(this.mapdims.dimensions <= 2) { // Set map limits this.mapdims.lims[2] = [-1, 1]; diff --git a/inst/htmlwidgets/RacViewer/lib/functions/graphics.js b/inst/htmlwidgets/RacViewer/lib/functions/graphics.js index eaf4b5a7..7e5281a4 100644 --- a/inst/htmlwidgets/RacViewer/lib/functions/graphics.js +++ b/inst/htmlwidgets/RacViewer/lib/functions/graphics.js @@ -57,8 +57,10 @@ Racmacs.Viewer.prototype.colorPointsByStress = function(){ for(var i=0; i max_stress || i==0){ max_stress = stress } - if(stress < min_stress || i==0){ min_stress = stress } + if (points[i].shown) { + if(stress > max_stress || max_stress === undefined){ max_stress = stress } + if(stress < min_stress || min_stress === undefined){ min_stress = stress } + } } for(var i=0; i { - if(unique_seq.indexOf(s[i]) === -1){ + if(s[i] != "." && unique_seq.indexOf(s[i]) === -1){ unique_seq.push(s[i]); } }); @@ -495,6 +495,7 @@ Racmacs.Viewer.prototype.colorPointsBySequence = function(pos){ // Make missing aas grey aa_cols[unique_aas.indexOf("-")] = new THREE.Color("#cccccc"); + aa_cols[unique_aas.indexOf(".")] = new THREE.Color("#cccccc"); // Color points by aa aas.map((aa, i) => { diff --git a/inst/htmlwidgets/RacViewer/lib/functions/utils.js b/inst/htmlwidgets/RacViewer/lib/functions/utils.js index edacc1b2..376b9378 100644 --- a/inst/htmlwidgets/RacViewer/lib/functions/utils.js +++ b/inst/htmlwidgets/RacViewer/lib/functions/utils.js @@ -183,7 +183,11 @@ Racmacs.utils.transformCoords = function( if(coords[0] === null) return(coords); - if(coords.length == 2){ + if(coords.length == 1){ + + return(coords[0]*transformation[0]); + + } else if(coords.length == 2){ if(transformation.length == 4){ // Standard 2D transform @@ -200,7 +204,7 @@ Racmacs.utils.transformCoords = function( ]); } - } else { + } else if(coords.length == 3) { if(transformation.length == 9){ // Standard 3D transform @@ -218,6 +222,10 @@ Racmacs.utils.transformCoords = function( ]); } + } else { + + throw("Cannot view more than 3 dimensions."); + } } @@ -229,8 +237,12 @@ Racmacs.utils.translateCoords = function( ){ if(coords[0] === null) return(coords); - - if(coords.length == 2){ + + if(coords.length == 1){ + + return(coords[0]+translation[0]); + + } else if(coords.length == 2){ if(translation.length == 2){ // Standard 2D translation @@ -247,7 +259,7 @@ Racmacs.utils.translateCoords = function( ]); } - } else { + } else if(coords.length == 3) { if(translation.length == 3){ // Standard 3D translation @@ -265,6 +277,10 @@ Racmacs.utils.translateCoords = function( ]); } + } else { + + throw("Cannot view more than 3 dimensions."); + } } diff --git a/inst/htmlwidgets/RacViewer/lib/r3js/lib/functions/element_lines.js b/inst/htmlwidgets/RacViewer/lib/r3js/lib/functions/element_lines.js index 4d27cd96..bcadffc8 100644 --- a/inst/htmlwidgets/RacViewer/lib/r3js/lib/functions/element_lines.js +++ b/inst/htmlwidgets/RacViewer/lib/r3js/lib/functions/element_lines.js @@ -49,7 +49,7 @@ R3JS.element.Line = class Line extends R3JS.element.base { } else { if(args.lwd > 0){ - if(args.dimensions == 2){ + if(args.dimensions <= 2){ var geo = R3JS.Geometries.line2d({ from: args.from, to: args.to, diff --git a/man/RacOptimizer.options.Rd b/man/RacOptimizer.options.Rd index 56e959cf..243d6aa5 100644 --- a/man/RacOptimizer.options.Rd +++ b/man/RacOptimizer.options.Rd @@ -10,6 +10,7 @@ RacOptimizer.options( maxit = 1000, num_cores = parallel::detectCores(), report_progress = NULL, + ignore_disconnected = FALSE, progress_bar_length = options()$width ) } @@ -24,6 +25,8 @@ RacOptimizer.options( \item{report_progress}{Should progress be reported} +\item{ignore_disconnected}{Should the check for disconnected points be skipped} + \item{progress_bar_length}{Progress bar length when progress is reported} } \value{ @@ -44,6 +47,7 @@ Other {map optimization functions}: \code{\link{make.acmap}()}, \code{\link{moveTrappedPoints}()}, \code{\link{optimizeMap}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{randomizeCoords}()}, \code{\link{relaxMapOneStep}()}, \code{\link{relaxMap}()} diff --git a/man/acmap.Rd b/man/acmap.Rd index d1e37300..004c5bb8 100644 --- a/man/acmap.Rd +++ b/man/acmap.Rd @@ -10,6 +10,7 @@ acmap( titer_table = NULL, ag_coords = NULL, sr_coords = NULL, + check_duplicates = TRUE, ... ) } @@ -25,6 +26,9 @@ acmap( \item{sr_coords}{Sera coordinates for an optimization run record (optional)} +\item{check_duplicates}{Issue a warning if duplicate antigen or sera names +are found} + \item{...}{Further arguments passed to \code{addOptimization()}} } \value{ diff --git a/man/agAttributes.Rd b/man/agAttributes.Rd index 4c957c57..6556f2b3 100644 --- a/man/agAttributes.Rd +++ b/man/agAttributes.Rd @@ -10,14 +10,18 @@ \alias{agReference<-} \alias{agNames} \alias{agNames<-} -\alias{agNamesFull} -\alias{agNamesFull<-} -\alias{agNamesAbbreviated} -\alias{agNamesAbbreviated<-} \alias{agExtra} \alias{agExtra<-} \alias{agPassage} \alias{agPassage<-} +\alias{agLineage} +\alias{agLineage<-} +\alias{agReassortant} +\alias{agReassortant<-} +\alias{agStrings} +\alias{agStrings<-} +\alias{agContinent} +\alias{agContinent<-} \title{Getting and setting antigen attributes} \usage{ agIDs(map) @@ -28,14 +32,18 @@ agReference(map) agReference(map) <- value agNames(map) agNames(map) <- value -agNamesFull(map) -agNamesFull(map) <- value -agNamesAbbreviated(map) -agNamesAbbreviated(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 } \arguments{ \item{map}{The acmap data object} diff --git a/man/agSequences.Rd b/man/agSequences.Rd index 8fc1723b..b373b000 100644 --- a/man/agSequences.Rd +++ b/man/agSequences.Rd @@ -3,15 +3,24 @@ \name{agSequences} \alias{agSequences} \alias{agSequences<-} +\alias{agNucleotideSequences} +\alias{agNucleotideSequences<-} \title{Getting and setting antigen sequence information} \usage{ -agSequences(map) +agSequences(map, missing_value = ".") agSequences(map) <- value + +agNucleotideSequences(map, missing_value = ".") + +agNucleotideSequences(map) <- value } \arguments{ \item{map}{The acmap data object} +\item{missing_value}{Character to use to fill in portions of the sequence matrix +where sequence data is missing.} + \item{value}{A character matrix of sequences with rows equal to the number of antigens} } diff --git a/man/make.acmap.Rd b/man/make.acmap.Rd index e8be5b7f..30911e39 100644 --- a/man/make.acmap.Rd +++ b/man/make.acmap.Rd @@ -61,6 +61,7 @@ Other {map optimization functions}: \code{\link{RacOptimizer.options}()}, \code{\link{moveTrappedPoints}()}, \code{\link{optimizeMap}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{randomizeCoords}()}, \code{\link{relaxMapOneStep}()}, \code{\link{relaxMap}()} diff --git a/man/mergeMaps.Rd b/man/mergeMaps.Rd index 92e9114f..1dfae2c9 100644 --- a/man/mergeMaps.Rd +++ b/man/mergeMaps.Rd @@ -11,7 +11,8 @@ mergeMaps( number_of_optimizations, minimum_column_basis = "none", optimizer_options = list(), - merge_options = list() + merge_options = list(), + verbose = TRUE ) } \arguments{ @@ -32,6 +33,8 @@ the minimum column basis to use.} settings (see \code{RacOptimizer.options()}).} \item{merge_options}{Options to use when merging titers (see \code{RacMerge.options()}).} + +\item{verbose}{Should progress messages be output?} } \value{ Returns the merged map object diff --git a/man/moveTrappedPoints.Rd b/man/moveTrappedPoints.Rd index eaed8884..de9d1d3a 100644 --- a/man/moveTrappedPoints.Rd +++ b/man/moveTrappedPoints.Rd @@ -46,6 +46,7 @@ Other {map optimization functions}: \code{\link{RacOptimizer.options}()}, \code{\link{make.acmap}()}, \code{\link{optimizeMap}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{randomizeCoords}()}, \code{\link{relaxMapOneStep}()}, \code{\link{relaxMap}()} diff --git a/man/optimizeMap.Rd b/man/optimizeMap.Rd index 1dfdf63c..8d6862cb 100644 --- a/man/optimizeMap.Rd +++ b/man/optimizeMap.Rd @@ -75,6 +75,7 @@ Other {map optimization functions}: \code{\link{RacOptimizer.options}()}, \code{\link{make.acmap}()}, \code{\link{moveTrappedPoints}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{randomizeCoords}()}, \code{\link{relaxMapOneStep}()}, \code{\link{relaxMap}()} diff --git a/man/optimizeSubsetAgsIndividually.Rd b/man/optimizeSubsetAgsIndividually.Rd new file mode 100644 index 00000000..f267e828 --- /dev/null +++ b/man/optimizeSubsetAgsIndividually.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/map_optimize.R +\name{optimizeSubsetAgsIndividually} +\alias{optimizeSubsetAgsIndividually} +\title{Optimize a subset of antigens individually} +\usage{ +optimizeSubsetAgsIndividually(map, subset, ...) +} +\arguments{ +\item{map}{The acmap object} + +\item{subset}{A list of antigen names to optimize individually.} + +\item{...}{Arguments passed to optimizeMap. number_of_dimensions and +number_of_optimizations are mandatory.} +} +\value{ +List containing 'merge' and 'individual'. 'merge' is the reference +map with with the positions of antigens in the subset overlain. +'individual' is a list containing each of the individual maps. +} +\description{ +You may have a large subset of antigens that distort the positions of +reference antigens and antisera. It can be useful to make a map containing +only reference antigens and antisera, and add each antigen in the subset to +the reference map individually. The resulting reference maps containing one +additional antigen are then aligned, and the positions of the additional +antigen in their individual map are shown. +} +\details{ +A common use case might be if you want to introduce many tens, or even +hundreds, of mutants into an existing map, without the geometric patterns in +the mutant's titrations swamping those between the existing antigens and +sera. +} +\seealso{ +Other {map optimization functions}: +\code{\link{RacOptimizer.options}()}, +\code{\link{make.acmap}()}, +\code{\link{moveTrappedPoints}()}, +\code{\link{optimizeMap}()}, +\code{\link{randomizeCoords}()}, +\code{\link{relaxMapOneStep}()}, +\code{\link{relaxMap}()} +} +\concept{{map optimization functions}} diff --git a/man/pointStress.Rd b/man/pointStress.Rd index 993fae14..0a293147 100644 --- a/man/pointStress.Rd +++ b/man/pointStress.Rd @@ -12,14 +12,9 @@ agStress(map, antigens = TRUE, optimization_number = 1) srStress(map, sera = TRUE, optimization_number = 1) -srStressPerTiter(map, sera = TRUE, optimization_number = 1, exclude_nd = FALSE) +srStressPerTiter(map, sera = TRUE, optimization_number = 1) -agStressPerTiter( - map, - antigens = TRUE, - optimization_number = 1, - exclude_nd = FALSE -) +agStressPerTiter(map, antigens = TRUE, optimization_number = 1) } \arguments{ \item{map}{The acmap data object} @@ -31,9 +26,6 @@ name (defaults to all antigens).} \item{sera}{Which sera to check stress for, specified by index or name (defaults to all sera).} - -\item{exclude_nd}{Should non-detectable values (e.g. <10) be excluded when -calculating point stress?} } \description{ Functions to get stress associated with individual points in a map. diff --git a/man/randomizeCoords.Rd b/man/randomizeCoords.Rd index c3515f82..14ed187d 100644 --- a/man/randomizeCoords.Rd +++ b/man/randomizeCoords.Rd @@ -29,6 +29,7 @@ Other {map optimization functions}: \code{\link{make.acmap}()}, \code{\link{moveTrappedPoints}()}, \code{\link{optimizeMap}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{relaxMapOneStep}()}, \code{\link{relaxMap}()} } diff --git a/man/relaxMap.Rd b/man/relaxMap.Rd index 7fbf6b31..6ac8c1cd 100644 --- a/man/relaxMap.Rd +++ b/man/relaxMap.Rd @@ -42,6 +42,7 @@ Other {map optimization functions}: \code{\link{make.acmap}()}, \code{\link{moveTrappedPoints}()}, \code{\link{optimizeMap}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{randomizeCoords}()}, \code{\link{relaxMapOneStep}()} } diff --git a/man/relaxMapOneStep.Rd b/man/relaxMapOneStep.Rd index 23f2782f..83de691b 100644 --- a/man/relaxMapOneStep.Rd +++ b/man/relaxMapOneStep.Rd @@ -35,6 +35,7 @@ Other {map optimization functions}: \code{\link{make.acmap}()}, \code{\link{moveTrappedPoints}()}, \code{\link{optimizeMap}()}, +\code{\link{optimizeSubsetAgsIndividually}()}, \code{\link{randomizeCoords}()}, \code{\link{relaxMap}()} } diff --git a/man/srAttributes.Rd b/man/srAttributes.Rd index bcc5e1cd..e5cfca15 100644 --- a/man/srAttributes.Rd +++ b/man/srAttributes.Rd @@ -10,14 +10,18 @@ \alias{srReference<-} \alias{srNames} \alias{srNames<-} -\alias{srNamesFull} -\alias{srNamesFull<-} -\alias{srNamesAbbreviated} -\alias{srNamesAbbreviated<-} \alias{srExtra} \alias{srExtra<-} \alias{srPassage} \alias{srPassage<-} +\alias{srLineage} +\alias{srLineage<-} +\alias{srReassortant} +\alias{srReassortant<-} +\alias{srStrings} +\alias{srStrings<-} +\alias{srSpecies} +\alias{srSpecies<-} \title{Getting and setting sera attributes} \usage{ srIDs(map) @@ -28,14 +32,18 @@ srReference(map) srReference(map) <- value srNames(map) srNames(map) <- value -srNamesFull(map) -srNamesFull(map) <- value -srNamesAbbreviated(map) -srNamesAbbreviated(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 } \arguments{ \item{map}{The acmap data object} diff --git a/man/srSequences.Rd b/man/srSequences.Rd index 925ea5e4..5b3633c4 100644 --- a/man/srSequences.Rd +++ b/man/srSequences.Rd @@ -3,15 +3,24 @@ \name{srSequences} \alias{srSequences} \alias{srSequences<-} +\alias{srNucleotideSequences} +\alias{srNucleotideSequences<-} \title{Getting and setting sera sequence information} \usage{ -srSequences(map) +srSequences(map, missing_value = ".") srSequences(map) <- value + +srNucleotideSequences(map, missing_value = ".") + +srNucleotideSequences(map) <- value } \arguments{ \item{map}{The acmap data object} +\item{missing_value}{Character to use to fill in portions of the sequence matrix +where sequence data is missing.} + \item{value}{A character matrix of sequences with rows equal to the number of sera} } diff --git a/src/Racmacs_types.h b/src/Racmacs_types.h index 2baaade0..60649717 100644 --- a/src/Racmacs_types.h +++ b/src/Racmacs_types.h @@ -168,6 +168,11 @@ SEXP wrap(const AcAntigen& ag){ _["clade"] = ag.get_clade(), _["annotations"] = ag.get_annotations(), _["labids"] = ag.get_labids(), + _["lineage"] = ag.get_lineage(), + _["reassortant"] = ag.get_reassortant(), + _["strings"] = ag.get_strings(), + _["continent"] = ag.get_continent(), + _["nucleotidesequence"] = ag.get_nucleotidesequence(), // Plotspec _["plotspec"] = as(wrap(ag.plotspec)) @@ -190,16 +195,20 @@ SEXP wrap(const AcSerum& sr){ // Attributes _["name"] = sr.get_name(), _["extra"] = sr.get_extra(), - // _["name_abbreviated"] = sr.get_name_abbreviated(), - // _["name_full"] = sr.get_name_full(), _["id"] = sr.get_id(), _["date"] = sr.get_date(), _["group"] = sr.get_group(), _["homologous_ags"] = sr.get_homologous_ags(), _["sequence"] = sr.get_sequence(), _["passage"] = sr.get_passage(), + _["species"] = sr.get_species(), _["clade"] = sr.get_clade(), _["annotations"] = sr.get_annotations(), + _["lineage"] = sr.get_lineage(), + _["reassortant"] = sr.get_reassortant(), + _["strings"] = sr.get_strings(), + _["continent"] = sr.get_continent(), + _["nucleotidesequence"] = sr.get_nucleotidesequence(), // Plotspec _["plotspec"] = as(wrap(sr.plotspec)) @@ -493,8 +502,6 @@ AcAntigen as(SEXP sxp){ // Attributes if(list.containsElementNamed("name")) ag.set_name(list["name"]); if(list.containsElementNamed("extra")) ag.set_extra(list["extra"]); - // if(list.containsElementNamed("name_abbreviated")) ag.set_name_abbreviated(list["name_abbreviated"]); - // if(list.containsElementNamed("name_full")) ag.set_name_full(list["name_full"]); if(list.containsElementNamed("id")) ag.set_id(list["id"]); if(list.containsElementNamed("date")) ag.set_date(list["date"]); if(list.containsElementNamed("group")) ag.set_group(list["group"]); @@ -503,6 +510,11 @@ AcAntigen as(SEXP sxp){ if(list.containsElementNamed("clade")) ag.set_clade(list["clade"]); if(list.containsElementNamed("annotations")) ag.set_annotations(list["annotations"]); if(list.containsElementNamed("labids")) ag.set_labids(list["labids"]); + if(list.containsElementNamed("lineage")) ag.set_lineage(list["lineage"]); + if(list.containsElementNamed("reassortant")) ag.set_reassortant(list["reassortant"]); + if(list.containsElementNamed("strings")) ag.set_strings(list["strings"]); + if(list.containsElementNamed("continent")) ag.set_continent(list["continent"]); + if(list.containsElementNamed("nucleotidesequence")) ag.set_nucleotidesequence(list["nucleotidesequence"]); // Plotspec if(list.containsElementNamed("plotspec")) ag.plotspec = as(list["plotspec"]); @@ -530,8 +542,14 @@ AcSerum as(SEXP sxp){ if(list.containsElementNamed("homologous_ags")) sr.set_homologous_ags(list["homologous_ags"]); if(list.containsElementNamed("sequence")) sr.set_sequence(list["sequence"]); if(list.containsElementNamed("passage")) sr.set_passage(list["passage"]); + if(list.containsElementNamed("species")) sr.set_species(list["species"]); if(list.containsElementNamed("clade")) sr.set_clade(list["clade"]); if(list.containsElementNamed("annotations")) sr.set_annotations(list["annotations"]); + if(list.containsElementNamed("lineage")) sr.set_lineage(list["lineage"]); + if(list.containsElementNamed("reassortant")) sr.set_reassortant(list["reassortant"]); + if(list.containsElementNamed("strings")) sr.set_strings(list["strings"]); + if(list.containsElementNamed("continent")) sr.set_continent(list["continent"]); + if(list.containsElementNamed("nucleotidesequence")) sr.set_nucleotidesequence(list["nucleotidesequence"]); // Plotspec if(list.containsElementNamed("plotspec")) sr.plotspec = as(list["plotspec"]); diff --git a/src/Racmacs_wrappers_antigens.cpp b/src/Racmacs_wrappers_antigens.cpp index 446e4c82..3400f92e 100644 --- a/src/Racmacs_wrappers_antigens.cpp +++ b/src/Racmacs_wrappers_antigens.cpp @@ -31,11 +31,15 @@ std::vector ac_ag_get_labids( const AcAntigen &ag ){ return ag.get_ // [[Rcpp::export(rng = false)]] std::string ac_ag_get_name( const AcAntigen &ag ){ return ag.get_name(); } // [[Rcpp::export(rng = false)]] -std::string ac_ag_get_name_full( const AcAntigen &ag ){ return ag.get_name_full(); } +std::string ac_ag_get_extra( const AcAntigen &ag ){ return ag.get_extra(); } // [[Rcpp::export(rng = false)]] -std::string ac_ag_get_name_abbreviated( const AcAntigen &ag ){ return ag.get_name_abbreviated(); } +std::string ac_ag_get_lineage( const AcAntigen &ag ){ return ag.get_lineage(); } // [[Rcpp::export(rng = false)]] -std::string ac_ag_get_extra( const AcAntigen &ag ){ return ag.get_extra(); } +std::string ac_ag_get_reassortant( const AcAntigen &ag ){ return ag.get_reassortant(); } +// [[Rcpp::export(rng = false)]] +std::string ac_ag_get_strings( const AcAntigen &ag ){ return ag.get_strings(); } +// [[Rcpp::export(rng = false)]] +std::string ac_ag_get_continent( const AcAntigen &ag ){ return ag.get_continent(); } // [[Rcpp::export(rng = false)]] std::string ac_ag_get_match_id( const AcAntigen &ag ){ return ag.get_match_id(); } @@ -64,11 +68,15 @@ AcAntigen ac_ag_set_labids( AcAntigen ag, std::vector value ){ ag.s // [[Rcpp::export(rng = false)]] AcAntigen ac_ag_set_name( AcAntigen ag, std::string value ){ ag.set_name(value); return ag; } // [[Rcpp::export(rng = false)]] -AcAntigen ac_ag_set_name_full( AcAntigen ag, std::string value ){ ag.set_name_full(value); return ag; } +AcAntigen ac_ag_set_extra( AcAntigen ag, std::string value ){ ag.set_extra(value); return ag; } // [[Rcpp::export(rng = false)]] -AcAntigen ac_ag_set_name_abbreviated( AcAntigen ag, std::string value ){ ag.set_name_abbreviated(value); return ag; } +AcAntigen ac_ag_set_lineage( AcAntigen ag, std::string value ){ ag.set_lineage(value); return ag; } // [[Rcpp::export(rng = false)]] -AcAntigen ac_ag_set_extra( AcAntigen ag, std::string value ){ ag.set_extra(value); return ag; } +AcAntigen ac_ag_set_reassortant( AcAntigen ag, std::string value ){ ag.set_reassortant(value); return ag; } +// [[Rcpp::export(rng = false)]] +AcAntigen ac_ag_set_strings( AcAntigen ag, std::string value ){ ag.set_strings(value); return ag; } +// [[Rcpp::export(rng = false)]] +AcAntigen ac_ag_set_continent( AcAntigen ag, std::string value ){ ag.set_continent(value); return ag; } // [[Rcpp::export(rng = false)]] AcAntigen ac_ag_set_group( AcAntigen ag, int value ){ ag.set_group(value); return ag; } diff --git a/src/Racmacs_wrappers_sera.cpp b/src/Racmacs_wrappers_sera.cpp index 9f36b64f..97c6258c 100644 --- a/src/Racmacs_wrappers_sera.cpp +++ b/src/Racmacs_wrappers_sera.cpp @@ -23,17 +23,23 @@ bool ac_sr_get_reference( const AcSerum &sr ){ return sr.get_reference(); } // [[Rcpp::export(rng = false)]] std::string ac_sr_get_passage( const AcSerum &sr ){ return sr.get_passage(); } // [[Rcpp::export(rng = false)]] +std::string ac_sr_get_species( const AcSerum &sr ){ return sr.get_species(); } +// [[Rcpp::export(rng = false)]] std::vector ac_sr_get_clade( const AcSerum &sr ){ return sr.get_clade(); } // [[Rcpp::export(rng = false)]] std::vector ac_sr_get_annotations( const AcSerum &sr ){ return sr.get_annotations(); } // [[Rcpp::export(rng = false)]] std::string ac_sr_get_name( const AcSerum &sr ){ return sr.get_name(); } // [[Rcpp::export(rng = false)]] -std::string ac_sr_get_name_full( const AcSerum &sr ){ return sr.get_name_full(); } +std::string ac_sr_get_extra( const AcSerum &sr ){ return sr.get_extra(); } // [[Rcpp::export(rng = false)]] -std::string ac_sr_get_name_abbreviated( const AcSerum &sr ){ return sr.get_name_abbreviated(); } +std::string ac_sr_get_lineage( const AcSerum &sr ){ return sr.get_lineage(); } // [[Rcpp::export(rng = false)]] -std::string ac_sr_get_extra( const AcSerum &sr ){ return sr.get_extra(); } +std::string ac_sr_get_reassortant( const AcSerum &sr ){ return sr.get_reassortant(); } +// [[Rcpp::export(rng = false)]] +std::string ac_sr_get_strings( const AcSerum &sr ){ return sr.get_strings(); } +// [[Rcpp::export(rng = false)]] +std::string ac_sr_get_continent( const AcSerum &sr ){ return sr.get_continent(); } // [[Rcpp::export(rng = false)]] std::string ac_sr_get_match_id( const AcSerum &sr ){ return sr.get_match_id(); } @@ -58,17 +64,24 @@ AcSerum ac_sr_set_reference( AcSerum sr, bool value ){ sr.set_reference(value); // [[Rcpp::export(rng = false)]] AcSerum ac_sr_set_passage( AcSerum sr, std::string value ){ sr.set_passage(value); return sr; } // [[Rcpp::export(rng = false)]] +AcSerum ac_sr_set_species( AcSerum sr, std::string value ){ sr.set_species(value); return sr; } +// [[Rcpp::export(rng = false)]] AcSerum ac_sr_set_clade( AcSerum sr, std::vector value ){ sr.set_clade(value); return sr; } // [[Rcpp::export(rng = false)]] AcSerum ac_sr_set_annotations( AcSerum sr, std::vector value ){ sr.set_annotations(value); return sr; } // [[Rcpp::export(rng = false)]] AcSerum ac_sr_set_name( AcSerum sr, std::string value ){ sr.set_name(value); return sr; } // [[Rcpp::export(rng = false)]] -AcSerum ac_sr_set_name_full( AcSerum sr, std::string value ){ sr.set_name_full(value); return sr; } +AcSerum ac_sr_set_extra( AcSerum sr, std::string value ){ sr.set_extra(value); return sr; } // [[Rcpp::export(rng = false)]] -AcSerum ac_sr_set_name_abbreviated( AcSerum sr, std::string value ){ sr.set_name_abbreviated(value); return sr; } +AcSerum ac_sr_set_lineage( AcSerum sr, std::string value ){ sr.set_lineage(value); return sr; } // [[Rcpp::export(rng = false)]] -AcSerum ac_sr_set_extra( AcSerum sr, std::string value ){ sr.set_extra(value); return sr; } +AcSerum ac_sr_set_reassortant( AcSerum sr, std::string value ){ sr.set_reassortant(value); return sr; } +// [[Rcpp::export(rng = false)]] +AcSerum ac_sr_set_strings( AcSerum sr, std::string value ){ sr.set_strings(value); return sr; } +// [[Rcpp::export(rng = false)]] +AcSerum ac_sr_set_continent( AcSerum sr, std::string value ){ sr.set_continent(value); return sr; } + // [[Rcpp::export(rng = false)]] AcSerum ac_sr_set_homologous_ags( AcSerum sr, arma::uvec value ){ sr.set_homologous_ags(value); return sr; } diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 638bbcf4..67a8584b 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -286,33 +286,53 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// ac_ag_get_name_full -std::string ac_ag_get_name_full(const AcAntigen& ag); -RcppExport SEXP _Racmacs_ac_ag_get_name_full(SEXP agSEXP) { +// ac_ag_get_extra +std::string ac_ag_get_extra(const AcAntigen& ag); +RcppExport SEXP _Racmacs_ac_ag_get_extra(SEXP agSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const AcAntigen& >::type ag(agSEXP); - rcpp_result_gen = Rcpp::wrap(ac_ag_get_name_full(ag)); + rcpp_result_gen = Rcpp::wrap(ac_ag_get_extra(ag)); return rcpp_result_gen; END_RCPP } -// ac_ag_get_name_abbreviated -std::string ac_ag_get_name_abbreviated(const AcAntigen& ag); -RcppExport SEXP _Racmacs_ac_ag_get_name_abbreviated(SEXP agSEXP) { +// ac_ag_get_lineage +std::string ac_ag_get_lineage(const AcAntigen& ag); +RcppExport SEXP _Racmacs_ac_ag_get_lineage(SEXP agSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const AcAntigen& >::type ag(agSEXP); - rcpp_result_gen = Rcpp::wrap(ac_ag_get_name_abbreviated(ag)); + rcpp_result_gen = Rcpp::wrap(ac_ag_get_lineage(ag)); return rcpp_result_gen; END_RCPP } -// ac_ag_get_extra -std::string ac_ag_get_extra(const AcAntigen& ag); -RcppExport SEXP _Racmacs_ac_ag_get_extra(SEXP agSEXP) { +// ac_ag_get_reassortant +std::string ac_ag_get_reassortant(const AcAntigen& ag); +RcppExport SEXP _Racmacs_ac_ag_get_reassortant(SEXP agSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const AcAntigen& >::type ag(agSEXP); - rcpp_result_gen = Rcpp::wrap(ac_ag_get_extra(ag)); + rcpp_result_gen = Rcpp::wrap(ac_ag_get_reassortant(ag)); + return rcpp_result_gen; +END_RCPP +} +// ac_ag_get_strings +std::string ac_ag_get_strings(const AcAntigen& ag); +RcppExport SEXP _Racmacs_ac_ag_get_strings(SEXP agSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< const AcAntigen& >::type ag(agSEXP); + rcpp_result_gen = Rcpp::wrap(ac_ag_get_strings(ag)); + return rcpp_result_gen; +END_RCPP +} +// ac_ag_get_continent +std::string ac_ag_get_continent(const AcAntigen& ag); +RcppExport SEXP _Racmacs_ac_ag_get_continent(SEXP agSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< const AcAntigen& >::type ag(agSEXP); + rcpp_result_gen = Rcpp::wrap(ac_ag_get_continent(ag)); return rcpp_result_gen; END_RCPP } @@ -434,36 +454,58 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// ac_ag_set_name_full -AcAntigen ac_ag_set_name_full(AcAntigen ag, std::string value); -RcppExport SEXP _Racmacs_ac_ag_set_name_full(SEXP agSEXP, SEXP valueSEXP) { +// ac_ag_set_extra +AcAntigen ac_ag_set_extra(AcAntigen ag, std::string value); +RcppExport SEXP _Racmacs_ac_ag_set_extra(SEXP agSEXP, SEXP valueSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< AcAntigen >::type ag(agSEXP); Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); - rcpp_result_gen = Rcpp::wrap(ac_ag_set_name_full(ag, value)); + rcpp_result_gen = Rcpp::wrap(ac_ag_set_extra(ag, value)); return rcpp_result_gen; END_RCPP } -// ac_ag_set_name_abbreviated -AcAntigen ac_ag_set_name_abbreviated(AcAntigen ag, std::string value); -RcppExport SEXP _Racmacs_ac_ag_set_name_abbreviated(SEXP agSEXP, SEXP valueSEXP) { +// ac_ag_set_lineage +AcAntigen ac_ag_set_lineage(AcAntigen ag, std::string value); +RcppExport SEXP _Racmacs_ac_ag_set_lineage(SEXP agSEXP, SEXP valueSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< AcAntigen >::type ag(agSEXP); Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); - rcpp_result_gen = Rcpp::wrap(ac_ag_set_name_abbreviated(ag, value)); + rcpp_result_gen = Rcpp::wrap(ac_ag_set_lineage(ag, value)); return rcpp_result_gen; END_RCPP } -// ac_ag_set_extra -AcAntigen ac_ag_set_extra(AcAntigen ag, std::string value); -RcppExport SEXP _Racmacs_ac_ag_set_extra(SEXP agSEXP, SEXP valueSEXP) { +// ac_ag_set_reassortant +AcAntigen ac_ag_set_reassortant(AcAntigen ag, std::string value); +RcppExport SEXP _Racmacs_ac_ag_set_reassortant(SEXP agSEXP, SEXP valueSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< AcAntigen >::type ag(agSEXP); Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); - rcpp_result_gen = Rcpp::wrap(ac_ag_set_extra(ag, value)); + rcpp_result_gen = Rcpp::wrap(ac_ag_set_reassortant(ag, value)); + return rcpp_result_gen; +END_RCPP +} +// ac_ag_set_strings +AcAntigen ac_ag_set_strings(AcAntigen ag, std::string value); +RcppExport SEXP _Racmacs_ac_ag_set_strings(SEXP agSEXP, SEXP valueSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< AcAntigen >::type ag(agSEXP); + Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); + rcpp_result_gen = Rcpp::wrap(ac_ag_set_strings(ag, value)); + return rcpp_result_gen; +END_RCPP +} +// ac_ag_set_continent +AcAntigen ac_ag_set_continent(AcAntigen ag, std::string value); +RcppExport SEXP _Racmacs_ac_ag_set_continent(SEXP agSEXP, SEXP valueSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< AcAntigen >::type ag(agSEXP); + Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); + rcpp_result_gen = Rcpp::wrap(ac_ag_set_continent(ag, value)); return rcpp_result_gen; END_RCPP } @@ -951,6 +993,16 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// ac_sr_get_species +std::string ac_sr_get_species(const AcSerum& sr); +RcppExport SEXP _Racmacs_ac_sr_get_species(SEXP srSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< const AcSerum& >::type sr(srSEXP); + rcpp_result_gen = Rcpp::wrap(ac_sr_get_species(sr)); + return rcpp_result_gen; +END_RCPP +} // ac_sr_get_clade std::vector ac_sr_get_clade(const AcSerum& sr); RcppExport SEXP _Racmacs_ac_sr_get_clade(SEXP srSEXP) { @@ -981,33 +1033,53 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// ac_sr_get_name_full -std::string ac_sr_get_name_full(const AcSerum& sr); -RcppExport SEXP _Racmacs_ac_sr_get_name_full(SEXP srSEXP) { +// ac_sr_get_extra +std::string ac_sr_get_extra(const AcSerum& sr); +RcppExport SEXP _Racmacs_ac_sr_get_extra(SEXP srSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< const AcSerum& >::type sr(srSEXP); + rcpp_result_gen = Rcpp::wrap(ac_sr_get_extra(sr)); + return rcpp_result_gen; +END_RCPP +} +// ac_sr_get_lineage +std::string ac_sr_get_lineage(const AcSerum& sr); +RcppExport SEXP _Racmacs_ac_sr_get_lineage(SEXP srSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const AcSerum& >::type sr(srSEXP); - rcpp_result_gen = Rcpp::wrap(ac_sr_get_name_full(sr)); + rcpp_result_gen = Rcpp::wrap(ac_sr_get_lineage(sr)); return rcpp_result_gen; END_RCPP } -// ac_sr_get_name_abbreviated -std::string ac_sr_get_name_abbreviated(const AcSerum& sr); -RcppExport SEXP _Racmacs_ac_sr_get_name_abbreviated(SEXP srSEXP) { +// ac_sr_get_reassortant +std::string ac_sr_get_reassortant(const AcSerum& sr); +RcppExport SEXP _Racmacs_ac_sr_get_reassortant(SEXP srSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const AcSerum& >::type sr(srSEXP); - rcpp_result_gen = Rcpp::wrap(ac_sr_get_name_abbreviated(sr)); + rcpp_result_gen = Rcpp::wrap(ac_sr_get_reassortant(sr)); return rcpp_result_gen; END_RCPP } -// ac_sr_get_extra -std::string ac_sr_get_extra(const AcSerum& sr); -RcppExport SEXP _Racmacs_ac_sr_get_extra(SEXP srSEXP) { +// ac_sr_get_strings +std::string ac_sr_get_strings(const AcSerum& sr); +RcppExport SEXP _Racmacs_ac_sr_get_strings(SEXP srSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const AcSerum& >::type sr(srSEXP); - rcpp_result_gen = Rcpp::wrap(ac_sr_get_extra(sr)); + rcpp_result_gen = Rcpp::wrap(ac_sr_get_strings(sr)); + return rcpp_result_gen; +END_RCPP +} +// ac_sr_get_continent +std::string ac_sr_get_continent(const AcSerum& sr); +RcppExport SEXP _Racmacs_ac_sr_get_continent(SEXP srSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< const AcSerum& >::type sr(srSEXP); + rcpp_result_gen = Rcpp::wrap(ac_sr_get_continent(sr)); return rcpp_result_gen; END_RCPP } @@ -1095,6 +1167,17 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// ac_sr_set_species +AcSerum ac_sr_set_species(AcSerum sr, std::string value); +RcppExport SEXP _Racmacs_ac_sr_set_species(SEXP srSEXP, SEXP valueSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< AcSerum >::type sr(srSEXP); + Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); + rcpp_result_gen = Rcpp::wrap(ac_sr_set_species(sr, value)); + return rcpp_result_gen; +END_RCPP +} // ac_sr_set_clade AcSerum ac_sr_set_clade(AcSerum sr, std::vector value); RcppExport SEXP _Racmacs_ac_sr_set_clade(SEXP srSEXP, SEXP valueSEXP) { @@ -1128,36 +1211,58 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// ac_sr_set_name_full -AcSerum ac_sr_set_name_full(AcSerum sr, std::string value); -RcppExport SEXP _Racmacs_ac_sr_set_name_full(SEXP srSEXP, SEXP valueSEXP) { +// ac_sr_set_extra +AcSerum ac_sr_set_extra(AcSerum sr, std::string value); +RcppExport SEXP _Racmacs_ac_sr_set_extra(SEXP srSEXP, SEXP valueSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< AcSerum >::type sr(srSEXP); Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); - rcpp_result_gen = Rcpp::wrap(ac_sr_set_name_full(sr, value)); + rcpp_result_gen = Rcpp::wrap(ac_sr_set_extra(sr, value)); return rcpp_result_gen; END_RCPP } -// ac_sr_set_name_abbreviated -AcSerum ac_sr_set_name_abbreviated(AcSerum sr, std::string value); -RcppExport SEXP _Racmacs_ac_sr_set_name_abbreviated(SEXP srSEXP, SEXP valueSEXP) { +// ac_sr_set_lineage +AcSerum ac_sr_set_lineage(AcSerum sr, std::string value); +RcppExport SEXP _Racmacs_ac_sr_set_lineage(SEXP srSEXP, SEXP valueSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< AcSerum >::type sr(srSEXP); Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); - rcpp_result_gen = Rcpp::wrap(ac_sr_set_name_abbreviated(sr, value)); + rcpp_result_gen = Rcpp::wrap(ac_sr_set_lineage(sr, value)); return rcpp_result_gen; END_RCPP } -// ac_sr_set_extra -AcSerum ac_sr_set_extra(AcSerum sr, std::string value); -RcppExport SEXP _Racmacs_ac_sr_set_extra(SEXP srSEXP, SEXP valueSEXP) { +// ac_sr_set_reassortant +AcSerum ac_sr_set_reassortant(AcSerum sr, std::string value); +RcppExport SEXP _Racmacs_ac_sr_set_reassortant(SEXP srSEXP, SEXP valueSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< AcSerum >::type sr(srSEXP); Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); - rcpp_result_gen = Rcpp::wrap(ac_sr_set_extra(sr, value)); + rcpp_result_gen = Rcpp::wrap(ac_sr_set_reassortant(sr, value)); + return rcpp_result_gen; +END_RCPP +} +// ac_sr_set_strings +AcSerum ac_sr_set_strings(AcSerum sr, std::string value); +RcppExport SEXP _Racmacs_ac_sr_set_strings(SEXP srSEXP, SEXP valueSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< AcSerum >::type sr(srSEXP); + Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); + rcpp_result_gen = Rcpp::wrap(ac_sr_set_strings(sr, value)); + return rcpp_result_gen; +END_RCPP +} +// ac_sr_set_continent +AcSerum ac_sr_set_continent(AcSerum sr, std::string value); +RcppExport SEXP _Racmacs_ac_sr_set_continent(SEXP srSEXP, SEXP valueSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::traits::input_parameter< AcSerum >::type sr(srSEXP); + Rcpp::traits::input_parameter< std::string >::type value(valueSEXP); + rcpp_result_gen = Rcpp::wrap(ac_sr_set_continent(sr, value)); return rcpp_result_gen; END_RCPP } @@ -1312,17 +1417,18 @@ BEGIN_RCPP END_RCPP } // ac_merge_reoptimized -AcMap ac_merge_reoptimized(std::vector maps, int num_dims, int num_optimizations, AcOptimizerOptions optimizer_options, AcMergeOptions merge_options); -RcppExport SEXP _Racmacs_ac_merge_reoptimized(SEXP mapsSEXP, SEXP num_dimsSEXP, SEXP num_optimizationsSEXP, SEXP optimizer_optionsSEXP, SEXP merge_optionsSEXP) { +AcMap ac_merge_reoptimized(std::vector maps, int num_dims, int num_optimizations, std::string min_col_basis, AcOptimizerOptions optimizer_options, AcMergeOptions merge_options); +RcppExport SEXP _Racmacs_ac_merge_reoptimized(SEXP mapsSEXP, SEXP num_dimsSEXP, SEXP num_optimizationsSEXP, SEXP min_col_basisSEXP, SEXP optimizer_optionsSEXP, SEXP merge_optionsSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< std::vector >::type maps(mapsSEXP); Rcpp::traits::input_parameter< int >::type num_dims(num_dimsSEXP); Rcpp::traits::input_parameter< int >::type num_optimizations(num_optimizationsSEXP); + Rcpp::traits::input_parameter< std::string >::type min_col_basis(min_col_basisSEXP); Rcpp::traits::input_parameter< AcOptimizerOptions >::type optimizer_options(optimizer_optionsSEXP); Rcpp::traits::input_parameter< AcMergeOptions >::type merge_options(merge_optionsSEXP); - rcpp_result_gen = Rcpp::wrap(ac_merge_reoptimized(maps, num_dims, num_optimizations, optimizer_options, merge_options)); + rcpp_result_gen = Rcpp::wrap(ac_merge_reoptimized(maps, num_dims, num_optimizations, min_col_basis, optimizer_options, merge_options)); return rcpp_result_gen; END_RCPP } @@ -1737,9 +1843,11 @@ static const R_CallMethodDef CallEntries[] = { {"_Racmacs_ac_ag_get_annotations", (DL_FUNC) &_Racmacs_ac_ag_get_annotations, 1}, {"_Racmacs_ac_ag_get_labids", (DL_FUNC) &_Racmacs_ac_ag_get_labids, 1}, {"_Racmacs_ac_ag_get_name", (DL_FUNC) &_Racmacs_ac_ag_get_name, 1}, - {"_Racmacs_ac_ag_get_name_full", (DL_FUNC) &_Racmacs_ac_ag_get_name_full, 1}, - {"_Racmacs_ac_ag_get_name_abbreviated", (DL_FUNC) &_Racmacs_ac_ag_get_name_abbreviated, 1}, {"_Racmacs_ac_ag_get_extra", (DL_FUNC) &_Racmacs_ac_ag_get_extra, 1}, + {"_Racmacs_ac_ag_get_lineage", (DL_FUNC) &_Racmacs_ac_ag_get_lineage, 1}, + {"_Racmacs_ac_ag_get_reassortant", (DL_FUNC) &_Racmacs_ac_ag_get_reassortant, 1}, + {"_Racmacs_ac_ag_get_strings", (DL_FUNC) &_Racmacs_ac_ag_get_strings, 1}, + {"_Racmacs_ac_ag_get_continent", (DL_FUNC) &_Racmacs_ac_ag_get_continent, 1}, {"_Racmacs_ac_ag_get_match_id", (DL_FUNC) &_Racmacs_ac_ag_get_match_id, 1}, {"_Racmacs_ac_ag_get_group", (DL_FUNC) &_Racmacs_ac_ag_get_group, 1}, {"_Racmacs_ac_ag_get_group_levels", (DL_FUNC) &_Racmacs_ac_ag_get_group_levels, 1}, @@ -1751,9 +1859,11 @@ static const R_CallMethodDef CallEntries[] = { {"_Racmacs_ac_ag_set_annotations", (DL_FUNC) &_Racmacs_ac_ag_set_annotations, 2}, {"_Racmacs_ac_ag_set_labids", (DL_FUNC) &_Racmacs_ac_ag_set_labids, 2}, {"_Racmacs_ac_ag_set_name", (DL_FUNC) &_Racmacs_ac_ag_set_name, 2}, - {"_Racmacs_ac_ag_set_name_full", (DL_FUNC) &_Racmacs_ac_ag_set_name_full, 2}, - {"_Racmacs_ac_ag_set_name_abbreviated", (DL_FUNC) &_Racmacs_ac_ag_set_name_abbreviated, 2}, {"_Racmacs_ac_ag_set_extra", (DL_FUNC) &_Racmacs_ac_ag_set_extra, 2}, + {"_Racmacs_ac_ag_set_lineage", (DL_FUNC) &_Racmacs_ac_ag_set_lineage, 2}, + {"_Racmacs_ac_ag_set_reassortant", (DL_FUNC) &_Racmacs_ac_ag_set_reassortant, 2}, + {"_Racmacs_ac_ag_set_strings", (DL_FUNC) &_Racmacs_ac_ag_set_strings, 2}, + {"_Racmacs_ac_ag_set_continent", (DL_FUNC) &_Racmacs_ac_ag_set_continent, 2}, {"_Racmacs_ac_ag_set_group", (DL_FUNC) &_Racmacs_ac_ag_set_group, 2}, {"_Racmacs_ac_ag_set_group_levels", (DL_FUNC) &_Racmacs_ac_ag_set_group_levels, 2}, {"_Racmacs_ac_opt_get_ag_base_coords", (DL_FUNC) &_Racmacs_ac_opt_get_ag_base_coords, 1}, @@ -1800,12 +1910,15 @@ static const R_CallMethodDef CallEntries[] = { {"_Racmacs_ac_sr_get_date", (DL_FUNC) &_Racmacs_ac_sr_get_date, 1}, {"_Racmacs_ac_sr_get_reference", (DL_FUNC) &_Racmacs_ac_sr_get_reference, 1}, {"_Racmacs_ac_sr_get_passage", (DL_FUNC) &_Racmacs_ac_sr_get_passage, 1}, + {"_Racmacs_ac_sr_get_species", (DL_FUNC) &_Racmacs_ac_sr_get_species, 1}, {"_Racmacs_ac_sr_get_clade", (DL_FUNC) &_Racmacs_ac_sr_get_clade, 1}, {"_Racmacs_ac_sr_get_annotations", (DL_FUNC) &_Racmacs_ac_sr_get_annotations, 1}, {"_Racmacs_ac_sr_get_name", (DL_FUNC) &_Racmacs_ac_sr_get_name, 1}, - {"_Racmacs_ac_sr_get_name_full", (DL_FUNC) &_Racmacs_ac_sr_get_name_full, 1}, - {"_Racmacs_ac_sr_get_name_abbreviated", (DL_FUNC) &_Racmacs_ac_sr_get_name_abbreviated, 1}, {"_Racmacs_ac_sr_get_extra", (DL_FUNC) &_Racmacs_ac_sr_get_extra, 1}, + {"_Racmacs_ac_sr_get_lineage", (DL_FUNC) &_Racmacs_ac_sr_get_lineage, 1}, + {"_Racmacs_ac_sr_get_reassortant", (DL_FUNC) &_Racmacs_ac_sr_get_reassortant, 1}, + {"_Racmacs_ac_sr_get_strings", (DL_FUNC) &_Racmacs_ac_sr_get_strings, 1}, + {"_Racmacs_ac_sr_get_continent", (DL_FUNC) &_Racmacs_ac_sr_get_continent, 1}, {"_Racmacs_ac_sr_get_match_id", (DL_FUNC) &_Racmacs_ac_sr_get_match_id, 1}, {"_Racmacs_ac_sr_get_homologous_ags", (DL_FUNC) &_Racmacs_ac_sr_get_homologous_ags, 1}, {"_Racmacs_ac_sr_get_group", (DL_FUNC) &_Racmacs_ac_sr_get_group, 1}, @@ -1814,12 +1927,15 @@ static const R_CallMethodDef CallEntries[] = { {"_Racmacs_ac_sr_set_date", (DL_FUNC) &_Racmacs_ac_sr_set_date, 2}, {"_Racmacs_ac_sr_set_reference", (DL_FUNC) &_Racmacs_ac_sr_set_reference, 2}, {"_Racmacs_ac_sr_set_passage", (DL_FUNC) &_Racmacs_ac_sr_set_passage, 2}, + {"_Racmacs_ac_sr_set_species", (DL_FUNC) &_Racmacs_ac_sr_set_species, 2}, {"_Racmacs_ac_sr_set_clade", (DL_FUNC) &_Racmacs_ac_sr_set_clade, 2}, {"_Racmacs_ac_sr_set_annotations", (DL_FUNC) &_Racmacs_ac_sr_set_annotations, 2}, {"_Racmacs_ac_sr_set_name", (DL_FUNC) &_Racmacs_ac_sr_set_name, 2}, - {"_Racmacs_ac_sr_set_name_full", (DL_FUNC) &_Racmacs_ac_sr_set_name_full, 2}, - {"_Racmacs_ac_sr_set_name_abbreviated", (DL_FUNC) &_Racmacs_ac_sr_set_name_abbreviated, 2}, {"_Racmacs_ac_sr_set_extra", (DL_FUNC) &_Racmacs_ac_sr_set_extra, 2}, + {"_Racmacs_ac_sr_set_lineage", (DL_FUNC) &_Racmacs_ac_sr_set_lineage, 2}, + {"_Racmacs_ac_sr_set_reassortant", (DL_FUNC) &_Racmacs_ac_sr_set_reassortant, 2}, + {"_Racmacs_ac_sr_set_strings", (DL_FUNC) &_Racmacs_ac_sr_set_strings, 2}, + {"_Racmacs_ac_sr_set_continent", (DL_FUNC) &_Racmacs_ac_sr_set_continent, 2}, {"_Racmacs_ac_sr_set_homologous_ags", (DL_FUNC) &_Racmacs_ac_sr_set_homologous_ags, 2}, {"_Racmacs_ac_sr_set_group", (DL_FUNC) &_Racmacs_ac_sr_set_group, 2}, {"_Racmacs_ac_sr_set_group_levels", (DL_FUNC) &_Racmacs_ac_sr_set_group_levels, 2}, @@ -1831,7 +1947,7 @@ static const R_CallMethodDef CallEntries[] = { {"_Racmacs_ac_merge_titers", (DL_FUNC) &_Racmacs_ac_merge_titers, 2}, {"_Racmacs_ac_merge_titer_layers", (DL_FUNC) &_Racmacs_ac_merge_titer_layers, 2}, {"_Racmacs_ac_merge_tables", (DL_FUNC) &_Racmacs_ac_merge_tables, 2}, - {"_Racmacs_ac_merge_reoptimized", (DL_FUNC) &_Racmacs_ac_merge_reoptimized, 5}, + {"_Racmacs_ac_merge_reoptimized", (DL_FUNC) &_Racmacs_ac_merge_reoptimized, 6}, {"_Racmacs_ac_merge_frozen_overlay", (DL_FUNC) &_Racmacs_ac_merge_frozen_overlay, 2}, {"_Racmacs_ac_merge_relaxed_overlay", (DL_FUNC) &_Racmacs_ac_merge_relaxed_overlay, 3}, {"_Racmacs_ac_merge_frozen_merge", (DL_FUNC) &_Racmacs_ac_merge_frozen_merge, 3}, diff --git a/src/ac_merge.cpp b/src/ac_merge.cpp index 4d05de95..f74aadc8 100644 --- a/src/ac_merge.cpp +++ b/src/ac_merge.cpp @@ -277,9 +277,9 @@ arma::vec merge_ag_reactivity_adjustments( for(arma::uword j=0; j maps, int num_dims, int num_optimizations, + std::string min_col_basis, AcOptimizerOptions optimizer_options, AcMergeOptions merge_options ){ @@ -430,10 +431,6 @@ AcMap ac_merge_reoptimized( // Merge the map tables AcMap merged_map = ac_merge_tables(maps, merge_options); - // Merge column bases - std::string min_col_basis = merge_min_column_basis( maps ); - arma::vec fixed_col_bases = merge_fixed_column_bases( maps, merged_map.sera ); - // Merge antigen reactivity adjustments arma::vec ag_reactivity_adjustments = merge_ag_reactivity_adjustments( maps, merged_map.antigens ); @@ -442,7 +439,7 @@ AcMap ac_merge_reoptimized( num_dims, num_optimizations, min_col_basis, - fixed_col_bases, + arma::vec(merged_map.antigens.size(), arma::fill::value(arma::datum::nan)), ag_reactivity_adjustments, optimizer_options ); diff --git a/src/acmap_point.cpp b/src/acmap_point.cpp index 44334895..0b7f4ab5 100644 --- a/src/acmap_point.cpp +++ b/src/acmap_point.cpp @@ -11,14 +11,18 @@ std::string AcPoint::get_extra() const { return extra; } std::string AcPoint::get_date() const { return date; } bool AcPoint::get_reference() const { return reference; } std::string AcPoint::get_passage() const { return passage; } -std::string AcPoint::get_name_full() const { return name_full; } -std::string AcPoint::get_name_abbreviated() const { return name_abbreviated; } std::string AcPoint::get_id() const { return id; } +std::string AcPoint::get_species() const { return species; } int AcPoint::get_group() const { return group; } std::string AcPoint::get_sequence() const { return sequence; } std::vector AcPoint::get_clade() const { return clade; } std::vector AcPoint::get_annotations() const { return annotations; } std::vector AcPoint::get_labids() const { return labids; } +std::string AcPoint::get_lineage() const { return lineage; } +std::string AcPoint::get_reassortant() const { return reassortant; } +std::string AcPoint::get_strings() const { return strings; } +std::string AcPoint::get_continent() const { return continent; } +std::string AcPoint::get_nucleotidesequence() const { return nucleotidesequence; } void AcPoint::set_type( std::string value ){ type = value; } void AcPoint::set_name( std::string value ){ name = value; } @@ -26,14 +30,18 @@ void AcPoint::set_extra( std::string value ){ extra = value; } void AcPoint::set_date( std::string value ){ date = value; } void AcPoint::set_reference( bool value ){ reference = value; } void AcPoint::set_passage( std::string value ){ passage = value; } -void AcPoint::set_name_full( std::string value ){ name_full = value; } -void AcPoint::set_name_abbreviated( std::string value ){ name_abbreviated = value; } void AcPoint::set_id( std::string value ){ id = value; } +void AcPoint::set_species( std::string value ){ species = value; } void AcPoint::set_group( int value ){ group = value; } void AcPoint::set_sequence( std::string value ){ sequence = value; } void AcPoint::set_clade( std::vector value ){ clade = value; } void AcPoint::set_annotations( std::vector value ){ annotations = value; } void AcPoint::set_labids( std::vector value ){ labids = value; } +void AcPoint::set_lineage( std::string value ){ lineage = value; } +void AcPoint::set_reassortant( std::string value ){ reassortant = value; } +void AcPoint::set_strings( std::string value ){ strings = value; } +void AcPoint::set_continent( std::string value ){ continent = value; } +void AcPoint::set_nucleotidesequence( std::string value ){ nucleotidesequence = value; } // Get IDs for matching std::string AcPoint::get_match_id() const { @@ -63,8 +71,20 @@ bool AcPoint::isdefault(std::string attribute) { return(id == ""); } else if (attribute == "extra") { return(extra == ""); + } else if (attribute == "species") { + return(species == ""); } else if (attribute == "date") { return(date == ""); + } else if (attribute == "lineage") { + return(lineage == ""); + } else if (attribute == "reassortant") { + return(reassortant == ""); + } else if (attribute == "strings") { + return(strings == ""); + } else if (attribute == "continent") { + return(continent == ""); + } else if (attribute == "nucleotidesequence") { + return(nucleotidesequence == ""); } else { return(false); } diff --git a/src/acmap_point.h b/src/acmap_point.h index d8a80c18..03f59f49 100644 --- a/src/acmap_point.h +++ b/src/acmap_point.h @@ -17,15 +17,19 @@ class AcPoint { std::string extra; std::string date; bool reference = false; - std::string name_full; - std::string name_abbreviated; std::string id = ""; int group = 0; std::string sequence; std::string passage; + std::string species; std::vector clade; std::vector annotations; std::vector labids; + std::string lineage; + std::string reassortant; + std::string strings; + std::string continent; + std::string nucleotidesequence; public: @@ -42,14 +46,18 @@ class AcPoint { std::string get_date() const; bool get_reference() const; std::string get_passage() const; - std::string get_name_full() const; - std::string get_name_abbreviated() const; std::string get_id() const; + std::string get_species() const; int get_group() const; std::string get_sequence() const; std::vector get_clade() const; std::vector get_annotations() const; std::vector get_labids() const; + std::string get_lineage() const; + std::string get_reassortant() const; + std::string get_strings() const; + std::string get_continent() const; + std::string get_nucleotidesequence() const; void set_type( std::string value ); void set_name( std::string value ); @@ -57,14 +65,18 @@ class AcPoint { void set_date( std::string value ); void set_reference( bool value ); void set_passage( std::string value ); - void set_name_full( std::string value ); - void set_name_abbreviated( std::string value ); void set_id( std::string value ); + void set_species( std::string value ); void set_group( int value ); void set_sequence( std::string value ); void set_clade( std::vector value ); void set_annotations( std::vector value ); void set_labids( std::vector value ); + void set_lineage( std::string value ); + void set_reassortant( std::string value ); + void set_strings( std::string value ); + void set_continent( std::string value ); + void set_nucleotidesequence( std::string value ); // Get IDs for matching std::string get_match_id() const; diff --git a/src/json_read_to_acmap.cpp b/src/json_read_to_acmap.cpp index ded0d0c3..465fa594 100644 --- a/src/json_read_to_acmap.cpp +++ b/src/json_read_to_acmap.cpp @@ -93,6 +93,11 @@ AcMap json_to_acmap( if(ag.HasMember("l")) map.antigens[i].set_labids( parse>(ag["l"]) ); if(ag.HasMember("A")) map.antigens[i].set_sequence( ag["A"].GetString() ); if(ag.HasMember("D")) map.antigens[i].set_date( ag["D"].GetString() ); + if(ag.HasMember("L")) map.antigens[i].set_lineage( ag["L"].GetString() ); + if(ag.HasMember("R")) map.antigens[i].set_reassortant( ag["R"].GetString() ); + if(ag.HasMember("S")) map.antigens[i].set_strings( ag["S"].GetString() ); + if(ag.HasMember("C")) map.antigens[i].set_continent( ag["C"].GetString() ); + if(ag.HasMember("B")) map.antigens[i].set_nucleotidesequence( ag["B"].GetString() ); // set_reference // set_name_full // set_name_abbreviated @@ -112,7 +117,13 @@ AcMap json_to_acmap( if(sr.HasMember("A")) map.sera[i].set_sequence( sr["A"].GetString() ); if(sr.HasMember("D")) map.sera[i].set_date( sr["D"].GetString() ); if(sr.HasMember("I")) map.sera[i].set_id( sr["I"].GetString() ); + if(sr.HasMember("s")) map.sera[i].set_species( sr["s"].GetString() ); if(sr.HasMember("h")) map.sera[i].set_homologous_ags( parse(sr["h"]) ); + if(sr.HasMember("L")) map.sera[i].set_lineage( sr["L"].GetString() ); + if(sr.HasMember("R")) map.sera[i].set_reassortant( sr["R"].GetString() ); + if(sr.HasMember("S")) map.sera[i].set_strings( sr["S"].GetString() ); + if(sr.HasMember("C")) map.sera[i].set_continent( sr["C"].GetString() ); + if(sr.HasMember("B")) map.sera[i].set_nucleotidesequence( sr["B"].GetString() ); // set_reference // set_name_full // set_name_abbreviated diff --git a/src/json_write_from_acmap.cpp b/src/json_write_from_acmap.cpp index 84e7363e..b550d51a 100644 --- a/src/json_write_from_acmap.cpp +++ b/src/json_write_from_acmap.cpp @@ -52,12 +52,17 @@ std::string acmap_to_json( Value agval(kObjectType); agval.AddMember("N", jsonifya(ag.get_name(), allocator), allocator); - if (!ag.isdefault("passage")) agval.AddMember("P", jsonifya(ag.get_passage(), allocator), allocator); - if (!ag.isdefault("clade")) agval.AddMember("c", jsonifya(ag.get_clade(), allocator), allocator); - if (!ag.isdefault("annotations")) agval.AddMember("a", jsonifya(ag.get_annotations(), allocator), allocator); - if (!ag.isdefault("labids")) agval.AddMember("l", jsonifya(ag.get_labids(), allocator), allocator); - if (!ag.isdefault("sequence")) agval.AddMember("A", jsonifya(ag.get_sequence(), allocator), allocator); - if (!ag.isdefault("date")) agval.AddMember("D", jsonifya(ag.get_date(), allocator), allocator); + if (!ag.isdefault("passage")) agval.AddMember("P", jsonifya(ag.get_passage(), allocator), allocator); + if (!ag.isdefault("clade")) agval.AddMember("c", jsonifya(ag.get_clade(), allocator), allocator); + if (!ag.isdefault("annotations")) agval.AddMember("a", jsonifya(ag.get_annotations(), allocator), allocator); + if (!ag.isdefault("labids")) agval.AddMember("l", jsonifya(ag.get_labids(), allocator), allocator); + if (!ag.isdefault("sequence")) agval.AddMember("A", jsonifya(ag.get_sequence(), allocator), allocator); + if (!ag.isdefault("date")) agval.AddMember("D", jsonifya(ag.get_date(), allocator), allocator); + if (!ag.isdefault("lineage")) agval.AddMember("L", jsonifya(ag.get_lineage(), allocator), allocator); + if (!ag.isdefault("reassortant")) agval.AddMember("R", jsonifya(ag.get_reassortant(), allocator), allocator); + if (!ag.isdefault("strings")) agval.AddMember("S", jsonifya(ag.get_strings(), allocator), allocator); + if (!ag.isdefault("continent")) agval.AddMember("C", jsonifya(ag.get_continent(), allocator), allocator); + if (!ag.isdefault("nucleotidesequence")) agval.AddMember("B", jsonifya(ag.get_nucleotidesequence(), allocator), allocator); // set_group_values // set_reference // set_name_full @@ -75,13 +80,20 @@ std::string acmap_to_json( Value srval(kObjectType); srval.AddMember("N", jsonifya(sr.get_name(), allocator), allocator); - if (!sr.isdefault("passage")) srval.AddMember("P", jsonifya(sr.get_passage(), allocator), allocator); - if (!sr.isdefault("clade")) srval.AddMember("c", jsonifya(sr.get_clade(), allocator), allocator); - if (!sr.isdefault("annotations")) srval.AddMember("a", jsonifya(sr.get_annotations(), allocator), allocator); - if (!sr.isdefault("sequence")) srval.AddMember("A", jsonifya(sr.get_sequence(), allocator), allocator); - if (!sr.isdefault("date")) srval.AddMember("D", jsonifya(sr.get_date(), allocator), allocator); - if (!sr.isdefault("id")) srval.AddMember("I", jsonifya(sr.get_id(), allocator), allocator); - if (sr.get_homologous_ags().n_elem > 0) srval.AddMember("h", jsonifya(sr.get_homologous_ags(), allocator), allocator); + if (!sr.isdefault("passage")) srval.AddMember("P", jsonifya(sr.get_passage(), allocator), allocator); + if (!sr.isdefault("clade")) srval.AddMember("c", jsonifya(sr.get_clade(), allocator), allocator); + if (!sr.isdefault("annotations")) srval.AddMember("a", jsonifya(sr.get_annotations(), allocator), allocator); + if (!sr.isdefault("sequence")) srval.AddMember("A", jsonifya(sr.get_sequence(), allocator), allocator); + if (!sr.isdefault("date")) srval.AddMember("D", jsonifya(sr.get_date(), allocator), allocator); + if (!sr.isdefault("id")) srval.AddMember("I", jsonifya(sr.get_id(), allocator), allocator); + if (!sr.isdefault("species")) srval.AddMember("s", jsonifya(sr.get_species(), allocator), allocator); + if (sr.get_homologous_ags().n_elem > 0) srval.AddMember("h", jsonifya(sr.get_homologous_ags(), allocator), allocator); + if (!sr.isdefault("lineage")) srval.AddMember("L", jsonifya(sr.get_lineage(), allocator), allocator); + if (!sr.isdefault("reassortant")) srval.AddMember("R", jsonifya(sr.get_reassortant(), allocator), allocator); + if (!sr.isdefault("strings")) srval.AddMember("S", jsonifya(sr.get_strings(), allocator), allocator); + if (!sr.isdefault("continent")) srval.AddMember("C", jsonifya(sr.get_continent(), allocator), allocator); + if (!sr.isdefault("nucleotidesequence")) srval.AddMember("B", jsonifya(sr.get_nucleotidesequence(), allocator), allocator); + // set_group_values // set_reference // set_name_full diff --git a/tests/testthat/test-diagnostics_stress.R b/tests/testthat/test-diagnostics_stress.R index 6246ce67..e98384c6 100644 --- a/tests/testthat/test-diagnostics_stress.R +++ b/tests/testthat/test-diagnostics_stress.R @@ -28,8 +28,8 @@ test_that("point stress per titer", { ag_stress_per_titer <- agStressPerTiter(map) sr_stress_per_titer <- srStressPerTiter(map) - expect_equal(length(ag_stress_per_titer), numAntigens(map)) - expect_equal(length(sr_stress_per_titer), numSera(map)) + expect_equal(nrow(ag_stress_per_titer), numAntigens(map)) + expect_equal(nrow(sr_stress_per_titer), numSera(map)) }) @@ -81,7 +81,7 @@ test_that("Stress with NA coords", { map <- make.acmap(dat) expect_equal( - round(agStressPerTiter(map, exclude_nd = T)[4], 2), + round(agStressPerTiter(map)[4, "nd_excluded"], 2), 1.67 ) diff --git a/tests/testthat/test-map_merging.R b/tests/testthat/test-map_merging.R index 02ddbebb..8486bdff 100644 --- a/tests/testthat/test-map_merging.R +++ b/tests/testthat/test-map_merging.R @@ -58,6 +58,20 @@ map2 <- acmap( titerTable(map2) <- titers2 +test_that("Merging maps with few optimizations", { + + set.seed(850909) + many_dat <- replicate(3, acmap( + ag_names = paste0("A",1:10), + sr_names = paste0("S", 1:10), + titer_table = matrix(10*2^round(10*runif(100)), ncol=10) + ), simplify=F) + + mmap <- mergeMaps(many_dat, method="reoptimized-merge", number_of_dimensions = 2, number_of_optimizations = 10) + expect_equal(numOptimizations(mmap), 10) + +}) + test_that("Antigens and sera match properly", { diff --git a/tests/testthat/test-map_optimization.R b/tests/testthat/test-map_optimization.R index 5673b3ed..fa712fb1 100644 --- a/tests/testthat/test-map_optimization.R +++ b/tests/testthat/test-map_optimization.R @@ -576,10 +576,29 @@ test_that("Error when optimizing a map with disconnected points", { dat[6:10,1:5] <- "*" dat[1:5,6:9] <- "*" map <- acmap(titer_table = dat) - expect_warning( + expect_error( optimizeMap(map, 2, 10, "none"), - no_cohesion_warning() + "Map contains disconnected points.*" ) }) + +# Errors for disconnected maps +test_that("Optimizing a map with duplicate antigen or serum names", { + + dat <- matrix(rep(40, 90), ncol=9) + ag_names <- rep("AG", nrow(dat)) + sr_names <- rep("SR", ncol(dat)) + rownames(dat) <- ag_names + colnames(dat) <- sr_names + + map <- expect_warning(make.acmap(dat, number_of_optimizations = 2)) + expect_equal(agNames(map), ag_names) + expect_equal(srNames(map), sr_names) + expect_equal(sum(is.na(agCoords(map))), 0) + expect_equal(sum(is.na(srCoords(map))), 0) + +}) + + diff --git a/tests/testthat/test-map_sequences.R b/tests/testthat/test-map_sequences.R index 4ecb6495..ce4d88cf 100644 --- a/tests/testthat/test-map_sequences.R +++ b/tests/testthat/test-map_sequences.R @@ -26,9 +26,28 @@ test_that("Setting and getting sequences", { }) +test_that("Setting and getting nucleotide sequences", { + + nucsequence <- matrix("a", nrow = numAntigens(map), ncol = 10) + agNucleotideSequences(map) <- nucsequence + expect_equal(nucsequence, agNucleotideSequences(map)) + + nucsequence_sr <- matrix("a", nrow = numSera(map), ncol = 6) + srNucleotideSequences(map) <- nucsequence_sr + expect_equal(nucsequence_sr, srNucleotideSequences(map)) + + tmp <- tempfile(fileext = ".ace") + save.acmap(map, tmp) + map_loaded <- read.acmap(tmp) + expect_equal(nucsequence, agNucleotideSequences(map_loaded)) + expect_equal(nucsequence_sr, srNucleotideSequences(map_loaded)) + +}) + test_that("H3 map with sequences", { map <- read.acmap(test_path("../testdata/testmap_h3subset.ace")) + agSequences(map) <- read.csv( file = test_path("../testdata/testmap_h3subset_sequences.csv"), row.names = 1, @@ -48,6 +67,12 @@ test_that("H3 map with sequences", { check.names = FALSE ) + map$antigens[[2]]$sequence <- substr(map$antigens[[2]]$sequence, 1, 40) + map$antigens[[3]]$sequence <- NULL + + map$sera[[4]]$sequence <- substr(map$sera[[4]]$sequence, 1, 40) + map$sera[[6]]$sequence <- NULL + export.viewer.test( view(map), "map_with_agsrsequences.html" diff --git a/tests/testthat/test-map_strains.R b/tests/testthat/test-map_strains.R index f57571e9..2d4e21f8 100644 --- a/tests/testthat/test-map_strains.R +++ b/tests/testthat/test-map_strains.R @@ -198,16 +198,20 @@ test_that("Getting and setting other attributes", { # Test defaults expect_equal(agExtra(map), rep("", numAntigens(map))) expect_equal(srExtra(map), rep("", numSera(map))) + expect_equal(srSpecies(map), rep("", numSera(map))) # Test editing ag_extras <- paste("AG EXTRA", seq_len(numAntigens(map))) sr_extras <- paste("SR EXTRA", seq_len(numSera(map))) + sr_species <- paste("SR SPECIES", seq_len(numSera(map))) agExtra(map) <- ag_extras srExtra(map) <- sr_extras + srSpecies(map) <- sr_species # Check changed values expect_equal(agExtra(map), ag_extras) expect_equal(srExtra(map), sr_extras) + expect_equal(srSpecies(map), sr_species) # Check saving and reloading tmp <- tempfile(fileext = ".ace") @@ -216,6 +220,122 @@ test_that("Getting and setting other attributes", { loaded_map <- read.acmap(tmp) expect_equal(agExtra(loaded_map), ag_extras) expect_equal(srExtra(loaded_map), sr_extras) + expect_equal(srSpecies(loaded_map), sr_species) + +}) + +# Getting and setting B lineage +test_that("Getting and setting B lineage", { + + # Read in the test map + map <- read.acmap(filename = test_path("../testdata/testmap.ace")) + + # Test defaults + expect_equal(agLineage(map), rep("", numAntigens(map))) + expect_equal(srLineage(map), rep("", numSera(map))) + + # Test editing + ag_lineage <- rep("V", numAntigens(map)) + sr_lineage <- rep("Y", numSera(map)) + agLineage(map) <- ag_lineage + srLineage(map) <- sr_lineage + + # Check changed values + expect_equal(agLineage(map), ag_lineage) + expect_equal(srLineage(map), sr_lineage) + + # Check saving and reloading + tmp <- tempfile(fileext = ".ace") + save.acmap(map, tmp) + + loaded_map <- read.acmap(tmp) + expect_equal(agLineage(loaded_map), ag_lineage) + expect_equal(srLineage(loaded_map), sr_lineage) + +}) + +# Getting and setting reassortant status +test_that("Getting and setting reassortant status", { + + # Read in the test map + map <- read.acmap(filename = test_path("../testdata/testmap.ace")) + + # Test defaults + expect_equal(agReassortant(map), rep("", numAntigens(map))) + expect_equal(srReassortant(map), rep("", numSera(map))) + + # Test editing + ag_reassortant <- rep("R", numAntigens(map)) + sr_reassortant <- rep("R", numSera(map)) + agReassortant(map) <- ag_reassortant + srReassortant(map) <- sr_reassortant + + # Check changed values + expect_equal(agReassortant(map), ag_reassortant) + expect_equal(srReassortant(map), sr_reassortant) + + # Check saving and reloading + tmp <- tempfile(fileext = ".ace") + save.acmap(map, tmp) + + loaded_map <- read.acmap(tmp) + expect_equal(agReassortant(loaded_map), ag_reassortant) + expect_equal(srReassortant(loaded_map), sr_reassortant) + +}) + +# Getting and setting boolean strings +test_that("Getting and setting strings", { + + # Read in the test map + map <- read.acmap(filename = test_path("../testdata/testmap.ace")) + + # Test defaults + expect_equal(agStrings(map), rep("", numAntigens(map))) + expect_equal(srStrings(map), rep("", numSera(map))) + + # Test editing + ag_strings <- rep("E", numAntigens(map)) + sr_strings <- rep("C", numSera(map)) + agStrings(map) <- ag_strings + srStrings(map) <- sr_strings + + # Check changed values + expect_equal(agStrings(map), ag_strings) + expect_equal(srStrings(map), sr_strings) + + # Check saving and reloading + tmp <- tempfile(fileext = ".ace") + save.acmap(map, tmp) + + loaded_map <- read.acmap(tmp) + expect_equal(agStrings(loaded_map), ag_strings) + expect_equal(srStrings(loaded_map), sr_strings) + +}) + +# Getting and setting ag continent +test_that("Getting and setting continent", { + + # Read in the test map + map <- read.acmap(filename = test_path("../testdata/testmap.ace")) + + # Test defaults + expect_equal(agContinent(map), rep("", numAntigens(map))) + + # Test editing + ag_continent <- rep("NORTH-AMERICA", numAntigens(map)) + agContinent(map) <- ag_continent + + # Check changed values + expect_equal(agContinent(map), ag_continent) + + # Check saving and reloading + tmp <- tempfile(fileext = ".ace") + save.acmap(map, tmp) + + loaded_map <- read.acmap(tmp) + expect_equal(agContinent(loaded_map), ag_continent) }) diff --git a/tests/testthat/test-plot_map.R b/tests/testthat/test-plot_map.R index 043b3918..213a4359 100644 --- a/tests/testthat/test-plot_map.R +++ b/tests/testthat/test-plot_map.R @@ -21,6 +21,17 @@ test_that("Plotting a bare bones", { }) +# test_that("Plotting a 1D map", { +# +# map <- optimizeMap(map, 1, 2, "none", check_convergence = F) +# export.plot.test( +# plot(map), +# "1dmap.pdf", +# 8, 4 +# ) +# +# }) + test_that("Plotting a map with error lines", { map <- read.acmap(test_path("../testdata/testmap.ace")) diff --git a/tests/testthat/test-underconstrained_positions.R b/tests/testthat/test-underconstrained_positions.R index 772ccd38..55420874 100644 --- a/tests/testthat/test-underconstrained_positions.R +++ b/tests/testthat/test-underconstrained_positions.R @@ -20,7 +20,7 @@ test_that("Warn of undercontrained positions", { ), paste( "The following ANTIGENS have do not have enough titrations to position in 2 dimensions.", - "Coordinates were still optimized but positions will be unreliable\n\n'ANTIGEN 4'" + "Coordinates were still optimized but positions will be unreliable\n\n'A4'" ) ) @@ -44,7 +44,7 @@ test_that("Error for underconstrained points with infinite positions", { ), paste( "The following ANTIGENS are too underconstrained to position in 2 dimensions", - "and coordinates have been set to NaN:\n\n'ANTIGEN 4'" + "and coordinates have been set to NaN:\n\n'A4'" ) ) diff --git a/tests/testthat/test-view_map.R b/tests/testthat/test-view_map.R index 4dc9c45a..ec47d523 100644 --- a/tests/testthat/test-view_map.R +++ b/tests/testthat/test-view_map.R @@ -4,6 +4,14 @@ context("Viewing a map") map <- read.acmap(test_path("../testdata/testmap.ace")) +# Viewing a null map +test_that("Viewing a 1D map", { + + map <- optimizeMap(map, 1, 2, "none", check_convergence = F) + export.viewer.test(view(map), "map_1D.html") + +}) + # Viewing a null map test_that("Viewing a null map", { @@ -298,6 +306,37 @@ test_that("Viewing map transparency", { }) +# Point opacity +test_that("Viewing map with underconstrained points", { + + set.seed(850909) + dat <- matrix(10*2^round(10*runif(100)), ncol=10) + for (i in 1:10){ + dat[i,i:10] <- "*" + } + map <- expect_warning(make.acmap(dat, options = list(ignore_disconnected = TRUE))) + map2 <- expect_warning(make.acmap(dat[2:10,])) + + widget1 <- view(map) + widget2 <- view(map2) + + widget1 <- htmlwidgets::onRender( + x = widget1, + jsCode = "function(el, x, data) { el.viewer.colorPointsByStress(); }", + data = NULL + ) + + widget2 <- htmlwidgets::onRender( + x = widget2, + jsCode = "function(el, x, data) { el.viewer.colorPointsByStress(); el.viewer.showErrorLines(); }", + data = NULL + ) + + export.viewer.test(widget1, "map_ag_no_titers.html") + export.viewer.test(widget2, "map_ag_underconstrained.html") + +}) + # # Snapshot map # test_that("Map snapshot", {