packIndices {cydar} | R Documentation |
Compress or decompress a vector of indices, usually specifying cell assignments to groups.
packIndices(assignments) unpackIndices(assignments)
assignments |
A list of integer vectors containing indices that specify cell assignments to groups.
Each vector corresponds to a group and should be uncompressed for |
Indices are stored in a compressed format whereby a negative number indicates that all consecutive integers from the preceding index should be used.
For example, a sequence of c(1, 3, -6, 8, -10, 12)
would be unpacked as c(1, 3:6, 8:10, 12)
.
This saves a lot of memory for storing cell assignments in hyperspheres, where there are likely to be many consecutive indices.
The countCells
function will automatically fill in the cellAssignments
slot of the output object with compressed index vectors.
The unpackIndices
function can be used to construct the full vector from some or all of these vectors, for manual use elsewhere.
Conversely, users manually constructing CyData objects can use packIndices
to compress the vectors and save space.
A list of integer vectors containing compressed or uncompressed index vectors, for packIndices
and unpackIndices
respectively.
Aaron Lun
a <- c(1L, 3:6, 8:10, 12L) packIndices(list(a)) b <- c(1L, 3L, -6L, 8L, -10L, 12L) unpackIndices(list(b))