Skip to content

Commit 88bea46

Browse files
committed
feat: annotate single mother-bud pair tool, closes #985
1 parent 9ad3251 commit 88bea46

File tree

5 files changed

+380
-61
lines changed

5 files changed

+380
-61
lines changed

cellacdc/cca_functions.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,41 @@ def add_generation_num_of_relative_ID(
864864

865865
acdc_df_with_col = acdc_df_by_frame_i.reset_index()
866866
return acdc_df_with_col
867+
868+
def get_IDs_gen_num_will_divide(cca_df):
869+
"""Get a list of (ID, gen_num) of cells that require `will_divide`>0
870+
871+
Parameters
872+
----------
873+
cca_df : pd.DataFrame
874+
DataFrame with cc annotations for every frame and Cell_ID
867875
876+
Returns
877+
-------
878+
list of tuples
879+
List of (ID, gen_num) of cells that require `will_divide`>0
880+
"""
881+
882+
cca_df_buds = cca_df.query('relationship == "bud"')
883+
IDs_gen_num_will_divide = []
884+
for budID, bud_cca_df in cca_df_buds.groupby('Cell_ID'):
885+
all_gen_nums = cca_df.query(f'Cell_ID == {budID}')['generation_num']
886+
if not (all_gen_nums > 0).any():
887+
# bud division is annotated in the future
888+
continue
889+
890+
mothID = int(bud_cca_df['relative_ID'].iloc[0])
891+
first_frame_bud = bud_cca_df['frame_i'].iloc[0]
892+
gen_num_moth = cca_df.query(
893+
f'(frame_i == {first_frame_bud}) & (Cell_ID == {mothID})'
894+
)['generation_num'].iloc[0]
895+
896+
IDs_gen_num_will_divide.append((mothID, gen_num_moth))
897+
IDs_gen_num_will_divide.append((budID, 0))
898+
899+
return IDs_gen_num_will_divide
900+
901+
868902
def get_IDs_gen_num_will_divide_wrong(global_cca_df):
869903
"""Get a list of (ID, gen_num) of cells whose `will_divide`>0 but the
870904
next generation does not exist (i.e., `will_divide` is wrong)

0 commit comments

Comments
 (0)