R/dynamics_relevant_functions.R
select_cell_index.RdRandomly selects a specific cell from the living cells of a given clone type based on the cell lineage information.
select_cell_index(cell_info, clone_type)An integer representing the selected cell's unique index
This function filters the cell_info data frame to find all living cells (those without a death_time) of the specified clone type. If there is only one such cell, it is returned directly. If there are multiple cells, one is chosen randomly with equal probability.
Living cells are identified as those where death_time is NA in the cell_info data frame.
cell_info <- data.frame( clone = c("Clone1", "Clone1", "Clone2"), death_time = c(NA, 5, NA), cell_index = c(1, 2, 3) ) clone_type <- "Clone1"
selected_cell_index <- select_cell_index(cell_info, clone_type) print(selected_cell_index) # Possible output: 1