x = singleton(1) |>
addMarker(name = "m1", alleles = 1:2) |>
addMarker(name = "m2", alleles = letters[1:2], chrom = "X")
# By default, the markers to be modified are identified by name
locs = list(list(name = "m1", alleles = 1:10),
list(name = "m2", alleles = letters[1:10]))
y = setLocusAttributes(x, locusAttributes = locs)
getMarkers(y, 1:2)
# If `erase = TRUE` attributes not explicitly given are erased
y2 = setLocusAttributes(x, locusAttributes = locs, erase = TRUE)
chrom(y2, 2) # not "X" anymore
# The getter and setter are inverses
newx = setLocusAttributes(x, locusAttributes = getLocusAttributes(x))
stopifnot(identical(x, newx))
Run the code above in your browser using DataLab