Randomly samples a specified number of living cells from the cell lineage information produced by a dynamics simulation.
sample_cells(cell_info, num_samples)A data frame containing the cell_info rows for the randomly sampled cells
This function first filters the cell_info data frame to identify living cells (those with NA in death_time), then randomly samples the specified number of cells from this subset.
If the number of requested samples exceeds the number of living cells, the function issues a warning and returns all living cells instead.
# Example usage:
cell_info <- data.frame(
clone = c("Clone1", "Clone1", "Clone2"),
death_time = c(NA, 5, NA),
cell_index = c(1, 2, 3)
)
num_samples <- 2
sampled_cells <- sample_cells(cell_info, num_samples)
#> Warning: restarting interrupted promise evaluation
#> Warning: internal error -3 in R_decompress1
#> Error: lazy-load database '/Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/cancerSimCraft/R/cancerSimCraft.rdb' is corrupt
print(sampled_cells) # Sampled live cells
#> Error: object 'sampled_cells' not found