packIndices {cydar}R Documentation

Pack or unpack indices

Description

Compress or decompress a vector of indices, usually specifying cell assignments to groups.

Usage

packIndices(assignments)
unpackIndices(assignments)

Arguments

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 packIndices, or already compressed for unpackIndices.

Details

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.

Value

A list of integer vectors containing compressed or uncompressed index vectors, for packIndices and unpackIndices respectively.

Author(s)

Aaron Lun

See Also

countCells

Examples

a <- c(1L, 3:6, 8:10, 12L)
packIndices(list(a))

b <- c(1L, 3L, -6L, 8L, -10L, 12L)
unpackIndices(list(b))


[Package cydar version 1.4.0 Index]