aegis_sim.utilities.analysis.survival
1# BASIC 2 3# TODO add functions that convert mortality to survival to survivorship to counts, etc. 4 5 6def get_mortality(survival): 7 # TODO Ensure that you are slicing the phenotype array at right places 8 y = 1 - survival 9 return y 10 11 12def get_survivorship(survival): 13 # TODO Ensure that you are slicing the phenotype array at right places 14 y = survival.cumprod(axis=1) 15 return y 16 17 18def get_total_mortality(interval_life_table): 19 total_survivorship = get_total_survivorship(interval_life_table) 20 total_mortality = -total_survivorship.pct_change(axis=1) 21 return total_mortality 22 23 24def get_total_survivorship(interval_life_table): 25 # additive age structure records viability of each individual during its lifetime 26 # when applied to a discrete cohort, additive age structure have the same shape as the survivorship curve 27 # furthermore, if normalized, it is equivalent to the survivorship curve 28 # when not applied to a cohort, the same holds if the population is stationary which approximately holds at short time scales 29 total_survivorship = interval_life_table.div(interval_life_table.iloc[:, 0], axis=0) # normalize 30 return total_survivorship 31 32 33# COMPLEX 34 35 36def get_life_expectancy(phenotypes, AGE_LIMIT): 37 # TODO Ensure that you are slicing the phenotype array at right places 38 pdf = phenotypes.iloc[:, :AGE_LIMIT] 39 survivorship = pdf.cumprod(1) 40 y = survivorship.sum(1) 41 return y 42 43 44def get_longevity(survivorship, proportion_alive): 45 """ 46 Longevity (omega) .. age at which proportion_alive of the population is still alive. 47 Usually, this is set to 95% or 99%, sometimes called exceptional lifespan. 48 """ 49 return survivorship.ge(proportion_alive).sum(1)
def
get_mortality(survival):
def
get_survivorship(survival):
def
get_total_mortality(interval_life_table):
def
get_total_survivorship(interval_life_table):
25def get_total_survivorship(interval_life_table): 26 # additive age structure records viability of each individual during its lifetime 27 # when applied to a discrete cohort, additive age structure have the same shape as the survivorship curve 28 # furthermore, if normalized, it is equivalent to the survivorship curve 29 # when not applied to a cohort, the same holds if the population is stationary which approximately holds at short time scales 30 total_survivorship = interval_life_table.div(interval_life_table.iloc[:, 0], axis=0) # normalize 31 return total_survivorship
def
get_life_expectancy(phenotypes, AGE_LIMIT):
def
get_longevity(survivorship, proportion_alive):
45def get_longevity(survivorship, proportion_alive): 46 """ 47 Longevity (omega) .. age at which proportion_alive of the population is still alive. 48 Usually, this is set to 95% or 99%, sometimes called exceptional lifespan. 49 """ 50 return survivorship.ge(proportion_alive).sum(1)
Longevity (omega) .. age at which proportion_alive of the population is still alive. Usually, this is set to 95% or 99%, sometimes called exceptional lifespan.