From ca9f9ba450364d669606f6c9bfa4425a40396566 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Sat, 31 Dec 2022 14:06:22 -0800 Subject: [PATCH 01/12] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8c64cabaf..fd6e3160d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ pylint.log spell.txt .vscode/settings.json .vscode +lineage/data/taxol From 56b3506d8a6c4ce3c4be7c9619a8a789ae977d5e Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Mon, 9 Jan 2023 16:31:57 -0800 Subject: [PATCH 02/12] more helper functions for importing taxol --- lineage/import_lineage.py | 154 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index 44b3c489b..b32b99d12 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -227,3 +227,157 @@ def MCF10A(condition: str): else: raise ValueError("condition does not exist. choose between [PBS, EGF, HGF, OSM]") + + +def assign_observs_Taxol(cell, cell_lineage, label: int): + """Given a cell, the lineage, and the unique id of the cell, it assigns the observations of that cell, and returns it. + :param cell: a CellVar object to be assigned observations. + :param cell_lineage: the dataframe of cells in a file. + :param label: the id given to the cell from the experiment. + """ + # initialize + cell.obs = [1, 1, 0, 0, 1, 1] # [G1_fate, S_G2_fate, G1_length, SG2_length, G1_censored?, SG2_censored?] + t_end = 5760 + + all_parent_ids = cell_lineage["parent"].unique() + cell_df = cell_lineage.loc[cell_lineage["label"] == label] + parent_id = cell_df["parent"].unique()[0] + if parent_id == 0: + cell.gen = 1 + + threshold = 0.7 # greater than this ==> SG2 + G1_df = cell_df.loc[cell_df['Cell_CC_mean_intensity_ratio'] <= threshold] + SG2_df = cell_df.loc[cell_df['Cell_CC_mean_intensity_ratio'] > threshold] + + ## G1 calculations: + if G1_df.empty: + # means the cell has no G1 component + cell.obs[0] = 1.0 # if no G1, then there is SG2, so it has definitely transitioned from G1 to SG2 + cell.obs[2] = np.nan + cell.obs[4] = np.nan + else: + # G1 length + cell.obs[2] = (np.nanmax(G1_df["elapsed_minutes"]) - np.nanmin(G1_df["elapsed_minutes"])) / 60 # G1 duration + if np.nanmin(G1_df["elapsed_minutes"]) == 0: # means left censored + cell.obs[4] = 0 + if not(SG2_df.empty): # has transitioned from G1 -> SG2 + cell.obs[0] = 1 + + if np.nanmax(G1_df["elapsed_minutes"]) == t_end: # cell existed and the experiment ended + cell.obs[4] = 0 + assert not(label in all_parent_ids) # definitely is not a parent because we reached end of exp + cell.obs[0] = np.nan + + if np.nanmax(G1_df["elapsed_minutes"]) < t_end and SG2_df.empty: # cell died in G1 + cell.obs[0] = 0 + + ## SG2 calculations: + if SG2_df.empty: + # means the cell has no SG2 component + cell.obs[1] = np.nan + cell.obs[3] = np.nan + cell.obs[5] = np.nan + else: + # SG2 length + cell.obs[3] = (np.nanmax(SG2_df["elapsed_minutes"]) - np.nanmin(SG2_df["elapsed_minutes"])) / 60 # SG2 + if np.nanmin(SG2_df["elapsed_minutes"]) == 0: # cell existed when the experiment started + cell.obs[5] = 0 + if label in all_parent_ids: + cell.obs[1] = 1 + + if np.nanmax(SG2_df["elapsed_minutes"]) == t_end: # cell existed and the experiment ended + cell.obs[5] = 0 + assert not(label in all_parent_ids) # definitely is not a parent because we reached end of exp + cell.obs[1] = np.nan + + if np.nanmax(SG2_df["elapsed_minutes"]) < t_end and not(label in all_parent_ids): # cell died in SG2 + cell.obs[1] = 0 + + return cell + +def import_taxol(filename="HC00801_A1_field_1_level_1.csv"): + """To import the new Taxol data""" + + data = pd.read_csv("lineage/data/taxol/"+filename) + labels = list(data["label"].unique()) + all_parent_ids = list(data["parent"].unique()) + + lineage_codes = sep_lineages(data) + lineages = [] + for i, lin in enumerate(lineage_codes): + num_gens = len(lin) # number of generations + parent_cell = CellVar(parent=None) + parent_cell = assign_observs_Taxol(parent_cell, data, lin[0][0]) + if num_gens == 1: + lineages.append([[parent_cell]]) + else: + temp = [[parent_cell]] + for gen in lin[1:]: + parent_cell.left = assign_observs_Taxol(parent_cell, data, gen[0]) + parent_cell.right = assign_observs_Taxol(parent_cell, data, gen[1]) + temp.append([parent_cell.left, parent_cell.right]) + + cell = data.loc[data["label"] == lab] + cell_lineage = cell[["label", "parent", "elapsed_minutes", "Drug1", "Drug1Concentration", "Cell_CC_mean_intensity_ratio"]] + + temp = [] + if np.all(cell_lineage["parent"] == 0): + parent_cell = CellVar(parent=None) + parent_cell = assign_observs_Taxol(parent_cell, cell_lineage, label) + if not(label in all_parent_ids): # singlton lineages + lineages.append([parent_cell]) + else: + while label in all_parent_ids: # while the cell is dividing... + childs = data.loc[data["parent"] == label] + child_ids = childs["label"].unique() + assert len(child_id) == 2 + parent_cell.left = assign_observs_Taxol(parent_cell, cell_lineage, chil_ids[0]) + parent_cell.right = assign_observs_Taxol(parent_cell, cell_lineage, chil_ids[1]) + + +### The following two functions are used to make a list from labels that belong to the same lineage +def sep_lineages(data): + labels = list(data["label"].unique()) + all_parent_ids = list(data["parent"].unique()) + a = [] + for i, val in enumerate(labels): + df = data.loc[data["label"]==val] # cell itself + if np.all(df["is_parent"] == True): + df_parent = data.loc[data["parent"] == val] # cell's parent + assert val in all_parent_ids + a.append([[val]] + [list(df_parent["label"].unique())]) + else: + a.append([[val]]) + + out1 = separate_lineages(data, all_parent_ids, a, 2) + out2 = separate_lineages(data, all_parent_ids, out1, 3) + out3 = separate_lineages(data, all_parent_ids, out2, 4) + out4 = separate_lineages(data, all_parent_ids, out3, 5) + out5 = separate_lineages(data, all_parent_ids, out4, 6) + + return out5 + +def separate_lineages(data, all_parent_ids, ls, k): + lss = ls.copy() + for j, val in enumerate(ls): + if len(val) == k: + temp = [] + k_th = val[k-1] + for i in k_th: + if np.isnan(i): + temp += [np.nan, np.nan] + else: + if i in all_parent_ids: + temp += list(data.loc[data["parent"]==i]["label"].unique()) + else: + temp += [np.nan, np.nan] + else: + continue + if np.all(np.isnan(temp)): + pass + else: + lss[j].append(temp) + return lss + + + From 8c1c74f63c095537955c5f9d90c768a1503d9808 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Tue, 10 Jan 2023 13:04:46 -0800 Subject: [PATCH 03/12] imported taxol --- lineage/import_lineage.py | 132 +++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 43 deletions(-) diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index b32b99d12..d4639c9b2 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -1,6 +1,6 @@ """ This file includes functions to import the new lineage data. """ import pandas as pd -import itertools +import itertools as it import numpy as np from .CellVar import CellVar @@ -32,7 +32,7 @@ def import_AU565(path: str) -> list: for j in unique_parent_trackIDs: if j != 0: pid.append(np.count_nonzero(lineage["parentTrackId"] == j) * [j]) - parent_ids = list(itertools.chain(*pid)) + parent_ids = list(it.chain(*pid)) # create the root parent cell and assign obsrvations parent_cell = CellVar(parent=None) @@ -295,45 +295,6 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): return cell -def import_taxol(filename="HC00801_A1_field_1_level_1.csv"): - """To import the new Taxol data""" - - data = pd.read_csv("lineage/data/taxol/"+filename) - labels = list(data["label"].unique()) - all_parent_ids = list(data["parent"].unique()) - - lineage_codes = sep_lineages(data) - lineages = [] - for i, lin in enumerate(lineage_codes): - num_gens = len(lin) # number of generations - parent_cell = CellVar(parent=None) - parent_cell = assign_observs_Taxol(parent_cell, data, lin[0][0]) - if num_gens == 1: - lineages.append([[parent_cell]]) - else: - temp = [[parent_cell]] - for gen in lin[1:]: - parent_cell.left = assign_observs_Taxol(parent_cell, data, gen[0]) - parent_cell.right = assign_observs_Taxol(parent_cell, data, gen[1]) - temp.append([parent_cell.left, parent_cell.right]) - - cell = data.loc[data["label"] == lab] - cell_lineage = cell[["label", "parent", "elapsed_minutes", "Drug1", "Drug1Concentration", "Cell_CC_mean_intensity_ratio"]] - - temp = [] - if np.all(cell_lineage["parent"] == 0): - parent_cell = CellVar(parent=None) - parent_cell = assign_observs_Taxol(parent_cell, cell_lineage, label) - if not(label in all_parent_ids): # singlton lineages - lineages.append([parent_cell]) - else: - while label in all_parent_ids: # while the cell is dividing... - childs = data.loc[data["parent"] == label] - child_ids = childs["label"].unique() - assert len(child_id) == 2 - parent_cell.left = assign_observs_Taxol(parent_cell, cell_lineage, chil_ids[0]) - parent_cell.right = assign_observs_Taxol(parent_cell, cell_lineage, chil_ids[1]) - ### The following two functions are used to make a list from labels that belong to the same lineage def sep_lineages(data): @@ -345,7 +306,8 @@ def sep_lineages(data): if np.all(df["is_parent"] == True): df_parent = data.loc[data["parent"] == val] # cell's parent assert val in all_parent_ids - a.append([[val]] + [list(df_parent["label"].unique())]) + if len(df_parent["label"].unique()) == 2: + a.append([[val]] + [list(df_parent["label"].unique())]) else: a.append([[val]]) @@ -368,7 +330,10 @@ def separate_lineages(data, all_parent_ids, ls, k): temp += [np.nan, np.nan] else: if i in all_parent_ids: - temp += list(data.loc[data["parent"]==i]["label"].unique()) + if len(data.loc[data["parent"]==i]["label"].unique()) == 2: + temp += list(data.loc[data["parent"]==i]["label"].unique()) + else: + temp += [np.nan, np.nan] else: temp += [np.nan, np.nan] else: @@ -380,4 +345,85 @@ def separate_lineages(data, all_parent_ids, ls, k): return lss +def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): + """To import the new Taxol data""" + data = pd.read_csv("lineage/data/taxol/"+filename) + + lineage_codes = sep_lineages(data) + lineages = [] + for i, lin in enumerate(lineage_codes): + num_gens = len(lin) # number of generations + parent_cell = CellVar(parent=None) + parent_cell = assign_observs_Taxol(parent_cell, data, lin[0][0]) + lin_temp = [[parent_cell]] + + if num_gens >= 2: + for kk in range(1, num_gens): + tmp = [] + for ix, l in enumerate(lin[kk]): + if ix % 2 == 1: # only iterate through one of two daughter cells + pass + else: + if not np.isnan(l): + cell = lin_temp[kk-1][int(ix/2)] + cell.left = assign_observs_Taxol(cell, data, l) + cell.right = assign_observs_Taxol(cell, data, lin[kk][ix+1]) + tmp.append([cell.left, cell.right]) + else: + tmp.append([np.nan, np.nan]) + lin_temp.append(list(it.chain(*tmp))) + lineages.append(lin_temp) + return lineages + +def import_taxol(): + """Import taxol data by condition""" + print("untreated") + untreated = [import_taxol_file("HC00801_A1_field_1_level_1.csv") + + import_taxol_file("HC00801_A1_field_2_level_1.csv") + + import_taxol_file("HC00801_A1_field_3_level_1.csv") + + import_taxol_file("HC00801_A1_field_4_level_1.csv")] + + print("taxol 0.5") + taxol_05 = [import_taxol_file("HC00801_A2_field_1_level_1.csv") + + import_taxol_file("HC00801_A2_field_2_level_1.csv") + + import_taxol_file("HC00801_A2_field_3_level_1.csv") + + import_taxol_file("HC00801_A2_field_4_level_1.csv")] + + print("taxol 1") + taxol_1 = [import_taxol_file("HC00801_B1_field_1_level_1.csv") + + import_taxol_file("HC00801_B1_field_2_level_1.csv") + + import_taxol_file("HC00801_B1_field_3_level_1.csv") + + import_taxol_file("HC00801_B1_field_4_level_1.csv")] + + print("taxol 1.5") + taxol_15 = [import_taxol_file("HC00801_B2_field_1_level_1.csv") + + import_taxol_file("HC00801_B2_field_2_level_1.csv") + + import_taxol_file("HC00801_B2_field_3_level_1.csv") + + import_taxol_file("HC00801_B2_field_4_level_1.csv")] + + print("taxol 2") + taxol_2 = [import_taxol_file("HC00801_C1_field_1_level_1.csv") + + import_taxol_file("HC00801_C1_field_2_level_1.csv") + + import_taxol_file("HC00801_C1_field_3_level_1.csv") + + import_taxol_file("HC00801_C1_field_4_level_1.csv")] + + print("taxol 2.5") + taxol_25 = [import_taxol_file("HC00801_C2_field_1_level_1.csv") + + import_taxol_file("HC00801_C2_field_2_level_1.csv") + + import_taxol_file("HC00801_C2_field_3_level_1.csv") + + import_taxol_file("HC00801_C2_field_4_level_1.csv")] + + print("taxol 3") + taxol_3 = [import_taxol_file("HC00801_D1_field_1_level_1.csv") + + import_taxol_file("HC00801_D1_field_2_level_1.csv") + + import_taxol_file("HC00801_D1_field_3_level_1.csv") + + import_taxol_file("HC00801_D1_field_4_level_1.csv")] + + print("taxol 4") + taxol_4 = [import_taxol_file("HC00801_D2_field_1_level_1.csv") + + import_taxol_file("HC00801_D2_field_2_level_1.csv") + + import_taxol_file("HC00801_D2_field_3_level_1.csv") + + import_taxol_file("HC00801_D2_field_4_level_1.csv")] + + return untreated, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 From e0577c739d1767ab2519b5e756dd9e7b19431aa8 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Tue, 10 Jan 2023 17:58:10 -0800 Subject: [PATCH 04/12] some more edits --- lineage/Lineage_collections.py | 14 +++++++++++++- lineage/figures/figureS18.py | 31 +++++++++++++++++++++++++++++++ lineage/import_lineage.py | 17 ++++++++++++----- lineage/plotTree.py | 4 +++- 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 lineage/figures/figureS18.py diff --git a/lineage/Lineage_collections.py b/lineage/Lineage_collections.py index d435ef70b..f36e7e678 100644 --- a/lineage/Lineage_collections.py +++ b/lineage/Lineage_collections.py @@ -1,7 +1,7 @@ """ This file is to collect those lineages that have the same condition, and have 3 or greater number of cells in their lineages. """ from .LineageInputOutput import import_exp_data -from .import_lineage import MCF10A +from .import_lineage import MCF10A, import_taxol from .states.StateDistributionGaPhs import StateDistribution from .states.StateDistributionGamma import StateDistribution as StDist from .LineageTree import LineageTree @@ -217,3 +217,15 @@ def popout_single_lineages(lineages): AllLapatinib = [Lapatinib_Control + Gemcitabine_Control, Lapt25uM, Lapt50uM, Lap250uM] AllGemcitabine = [Lapatinib_Control + Gemcitabine_Control, Gem5uM, Gem10uM, Gem30uM] GFs = [pbs, egf, hgf, osm] + +########################################################## +# NEW PACLITAXEL DATA +untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() + +untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] # 11427 cells +Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 8895 cells +Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 7782 cells +Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 8024 cells +Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 8024 cells + +taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_3, Taxol_4] \ No newline at end of file diff --git a/lineage/figures/figureS18.py b/lineage/figures/figureS18.py new file mode 100644 index 000000000..de8260513 --- /dev/null +++ b/lineage/figures/figureS18.py @@ -0,0 +1,31 @@ +""" In this file we plot the raw data before fitting from paclitaxel treated HCC1143 cells """ +from ..Lineage_collections import taxols as Taxol_lin_list +from ..plotTree import plotLineage +from .common import getSetup +from string import ascii_lowercase + +def makeFigure(): + """ + Makes figure S18. + """ + titles = ["Untreated", "Taxol 1 nM", "Taxol 2 nM", "Taxol 3 nM", "Taxol 4 nM"] + ax, f = getSetup((20, 45), (170, 5)) + + for i in range(170): + ax[5 * i].axis('off') + ax[5 * i + 1].axis('off') + ax[5 * i + 2].axis('off') + ax[5 * i + 3].axis('off') + ax[5 * i + 4].axis('off') + plotLineage(Taxol_lin_list[0][i], ax[5 * i], color=False) + plotLineage(Taxol_lin_list[1][i], ax[5 * i + 1], color=False) + plotLineage(Taxol_lin_list[2][i], ax[5 * i + 2], color=False) + plotLineage(Taxol_lin_list[3][i], ax[5 * i + 3], color=False) + plotLineage(Taxol_lin_list[4][i], ax[5 * i + 4], color=False) + + for i in range(5): + ax[i].axis('off') + ax[i].text(-0.2, 1.55, ascii_lowercase[i], transform=ax[i].transAxes, fontsize=20, fontweight="bold", va="top") + ax[i].text(0.0, 1.55, titles[i], transform=ax[i].transAxes, fontsize=20, va="top") + + return f \ No newline at end of file diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index d4639c9b2..b7fc67282 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -367,14 +367,21 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): else: if not np.isnan(l): cell = lin_temp[kk-1][int(ix/2)] - cell.left = assign_observs_Taxol(cell, data, l) - cell.right = assign_observs_Taxol(cell, data, lin[kk][ix+1]) + a = assign_observs_Taxol(CellVar(parent=cell), data, l) + b = assign_observs_Taxol(CellVar(parent=cell), data, lin[kk][ix+1]) + cell.left = a + cell.right = b tmp.append([cell.left, cell.right]) else: tmp.append([np.nan, np.nan]) + lin_temp.append(list(it.chain(*tmp))) - lineages.append(lin_temp) - return lineages + lineages.append(list(it.chain(*lin_temp))) + new_lins = [] + for lin in lineages: + n = [x for x in lin if str(x) != 'nan'] + new_lins.append(n) + return new_lins def import_taxol(): """Import taxol data by condition""" @@ -426,4 +433,4 @@ def import_taxol(): import_taxol_file("HC00801_D2_field_3_level_1.csv") + import_taxol_file("HC00801_D2_field_4_level_1.csv")] - return untreated, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 + return untreated[0], taxol_05[0], taxol_1[0], taxol_15[0], taxol_2[0], taxol_25[0], taxol_3[0], taxol_4[0] diff --git a/lineage/plotTree.py b/lineage/plotTree.py index dd1147720..53eef07c2 100644 --- a/lineage/plotTree.py +++ b/lineage/plotTree.py @@ -89,9 +89,11 @@ def plotLineage(lineage, axes, censor=True, color=True): else: length = root.obs[2] assert np.isfinite(length) - else: # the lineage starts from S/G2 phase + elif np.isfinite(root.obs[5]): # the lineage starts from S/G2 phase length = root.obs[3] assert np.isfinite(length) + else: + length=0.01 a = [Clade(length)] # input the root cell From 31f6157ca2091ce54cd43bb51152d33a18328e11 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Wed, 11 Jan 2023 09:54:00 -0800 Subject: [PATCH 05/12] one problem --- lineage/Lineage_collections.py | 16 ++++++++-------- lineage/figures/figureS18.py | 20 ++++++++++---------- lineage/import_lineage.py | 5 +++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lineage/Lineage_collections.py b/lineage/Lineage_collections.py index f36e7e678..2c2eb0a8d 100644 --- a/lineage/Lineage_collections.py +++ b/lineage/Lineage_collections.py @@ -1,7 +1,7 @@ """ This file is to collect those lineages that have the same condition, and have 3 or greater number of cells in their lineages. """ from .LineageInputOutput import import_exp_data -from .import_lineage import MCF10A, import_taxol +from .import_lineage import MCF10A, import_taxol_file from .states.StateDistributionGaPhs import StateDistribution from .states.StateDistributionGamma import StateDistribution as StDist from .LineageTree import LineageTree @@ -220,12 +220,12 @@ def popout_single_lineages(lineages): ########################################################## # NEW PACLITAXEL DATA -untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() - +# untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() +untreated_t = import_taxol_file() untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] # 11427 cells -Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 8895 cells -Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 7782 cells -Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 8024 cells -Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 8024 cells +# Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 8895 cells +# Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 7782 cells +# Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 8024 cells +# Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 8024 cells -taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_3, Taxol_4] \ No newline at end of file +# taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_3, Taxol_4] \ No newline at end of file diff --git a/lineage/figures/figureS18.py b/lineage/figures/figureS18.py index de8260513..4466a23cf 100644 --- a/lineage/figures/figureS18.py +++ b/lineage/figures/figureS18.py @@ -1,5 +1,5 @@ """ In this file we plot the raw data before fitting from paclitaxel treated HCC1143 cells """ -from ..Lineage_collections import taxols as Taxol_lin_list +from ..Lineage_collections import untreated_taxol as Taxol_lin_list from ..plotTree import plotLineage from .common import getSetup from string import ascii_lowercase @@ -13,15 +13,15 @@ def makeFigure(): for i in range(170): ax[5 * i].axis('off') - ax[5 * i + 1].axis('off') - ax[5 * i + 2].axis('off') - ax[5 * i + 3].axis('off') - ax[5 * i + 4].axis('off') - plotLineage(Taxol_lin_list[0][i], ax[5 * i], color=False) - plotLineage(Taxol_lin_list[1][i], ax[5 * i + 1], color=False) - plotLineage(Taxol_lin_list[2][i], ax[5 * i + 2], color=False) - plotLineage(Taxol_lin_list[3][i], ax[5 * i + 3], color=False) - plotLineage(Taxol_lin_list[4][i], ax[5 * i + 4], color=False) + # ax[5 * i + 1].axis('off') + # ax[5 * i + 2].axis('off') + # ax[5 * i + 3].axis('off') + # ax[5 * i + 4].axis('off') + plotLineage(Taxol_lin_list[i], ax[5 * i], color=False) + # plotLineage(Taxol_lin_list[1][i], ax[5 * i + 1], color=False) + # plotLineage(Taxol_lin_list[2][i], ax[5 * i + 2], color=False) + # plotLineage(Taxol_lin_list[3][i], ax[5 * i + 3], color=False) + # plotLineage(Taxol_lin_list[4][i], ax[5 * i + 4], color=False) for i in range(5): ax[i].axis('off') diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index b7fc67282..e4517668c 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -252,7 +252,7 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): ## G1 calculations: if G1_df.empty: # means the cell has no G1 component - cell.obs[0] = 1.0 # if no G1, then there is SG2, so it has definitely transitioned from G1 to SG2 + cell.obs[0] = np.nan # if no G1, then there is SG2, so it has definitely transitioned from G1 to SG2 cell.obs[2] = np.nan cell.obs[4] = np.nan else: @@ -380,7 +380,8 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): new_lins = [] for lin in lineages: n = [x for x in lin if str(x) != 'nan'] - new_lins.append(n) + m = [x for x in n if (not(np.isnan(x.obs[2])) or not(np.isnan(x.obs[3])))] + new_lins.append(m) return new_lins def import_taxol(): From e420796751cafe68a3296f8846c3b2365fff3b0b Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Thu, 12 Jan 2023 10:55:55 -0800 Subject: [PATCH 06/12] importing done --- lineage/figures/figureS18.py | 41 +- lineage/import_lineage.py | 150 +- lineage/plotTree.py | 2 + output/figureS18.svg | 18987 +++++++++++++++++++++++++++++++++ 4 files changed, 19118 insertions(+), 62 deletions(-) create mode 100644 output/figureS18.svg diff --git a/lineage/figures/figureS18.py b/lineage/figures/figureS18.py index 4466a23cf..351900919 100644 --- a/lineage/figures/figureS18.py +++ b/lineage/figures/figureS18.py @@ -1,27 +1,44 @@ """ In this file we plot the raw data before fitting from paclitaxel treated HCC1143 cells """ -from ..Lineage_collections import untreated_taxol as Taxol_lin_list +# from ..Lineage_collections import untreated_taxol as Taxol_lin_list +import numpy as np +from ..import_lineage import import_taxol from ..plotTree import plotLineage from .common import getSetup from string import ascii_lowercase +from ..states.StateDistributionGaPhs import StateDistribution +from ..LineageTree import LineageTree + +desired_num_states = 2 +E = [StateDistribution() for _ in range(desired_num_states)] + +untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() +untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] +Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] +Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] +Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] +Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] +print(len(untreated_taxol), len(Taxol_1), len(Taxol_2), len(Taxol_3), len(Taxol_4)) +counts = np.min([len(untreated_taxol), len(Taxol_1), len(Taxol_2), len(Taxol_3), len(Taxol_4)]) + def makeFigure(): """ Makes figure S18. """ titles = ["Untreated", "Taxol 1 nM", "Taxol 2 nM", "Taxol 3 nM", "Taxol 4 nM"] - ax, f = getSetup((20, 45), (170, 5)) + ax, f = getSetup((20, 35), (counts, 5)) - for i in range(170): + for i in range(counts): ax[5 * i].axis('off') - # ax[5 * i + 1].axis('off') - # ax[5 * i + 2].axis('off') - # ax[5 * i + 3].axis('off') - # ax[5 * i + 4].axis('off') - plotLineage(Taxol_lin_list[i], ax[5 * i], color=False) - # plotLineage(Taxol_lin_list[1][i], ax[5 * i + 1], color=False) - # plotLineage(Taxol_lin_list[2][i], ax[5 * i + 2], color=False) - # plotLineage(Taxol_lin_list[3][i], ax[5 * i + 3], color=False) - # plotLineage(Taxol_lin_list[4][i], ax[5 * i + 4], color=False) + ax[5 * i + 1].axis('off') + ax[5 * i + 2].axis('off') + ax[5 * i + 3].axis('off') + ax[5 * i + 4].axis('off') + plotLineage(untreated_taxol[i], ax[5 * i], color=False) + plotLineage(Taxol_1[i], ax[5 * i + 1], color=False) + plotLineage(Taxol_2[i], ax[5 * i + 2], color=False) + plotLineage(Taxol_3[i], ax[5 * i + 3], color=False) + plotLineage(Taxol_4[i], ax[5 * i + 4], color=False) for i in range(5): ax[i].axis('off') diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index e4517668c..e25dbe126 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -1,8 +1,9 @@ """ This file includes functions to import the new lineage data. """ import pandas as pd +from copy import copy import itertools as it import numpy as np -from .CellVar import CellVar +from .CellVar import CellVar, find_two_subtrees ############################ # importing AU565 data (new) @@ -255,6 +256,11 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): cell.obs[0] = np.nan # if no G1, then there is SG2, so it has definitely transitioned from G1 to SG2 cell.obs[2] = np.nan cell.obs[4] = np.nan + # if cell.gen > 1: + # cell.obs[1] = np.nan + # cell.obs[3] = np.nan + # cell.obs[5] = np.nan + # return cell else: # G1 length cell.obs[2] = (np.nanmax(G1_df["elapsed_minutes"]) - np.nanmin(G1_df["elapsed_minutes"])) / 60 # G1 duration @@ -295,21 +301,25 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): return cell - ### The following two functions are used to make a list from labels that belong to the same lineage def sep_lineages(data): labels = list(data["label"].unique()) all_parent_ids = list(data["parent"].unique()) + a = [] for i, val in enumerate(labels): df = data.loc[data["label"]==val] # cell itself - if np.all(df["is_parent"] == True): - df_parent = data.loc[data["parent"] == val] # cell's parent - assert val in all_parent_ids - if len(df_parent["label"].unique()) == 2: - a.append([[val]] + [list(df_parent["label"].unique())]) + if len(df) == 1: + continue else: - a.append([[val]]) + if np.all(df["is_parent"] == True): + df_parent = data.loc[data["parent"] == val] # cell's parent + assert val in all_parent_ids + if len(df_parent["label"].unique()) == 2: + a.append([[val]] + [list(df_parent["label"].unique())]) + else: + # a.append([[val]]) + continue out1 = separate_lineages(data, all_parent_ids, a, 2) out2 = separate_lineages(data, all_parent_ids, out1, 3) @@ -353,25 +363,31 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): lineage_codes = sep_lineages(data) lineages = [] for i, lin in enumerate(lineage_codes): - num_gens = len(lin) # number of generations + parent_cell = CellVar(parent=None) parent_cell = assign_observs_Taxol(parent_cell, data, lin[0][0]) lin_temp = [[parent_cell]] - if num_gens >= 2: - for kk in range(1, num_gens): - tmp = [] + if len(lin) >= 2: + for kk in range(1, len(lin)): + tmp = [] # for each lineage for ix, l in enumerate(lin[kk]): if ix % 2 == 1: # only iterate through one of two daughter cells pass else: if not np.isnan(l): cell = lin_temp[kk-1][int(ix/2)] - a = assign_observs_Taxol(CellVar(parent=cell), data, l) - b = assign_observs_Taxol(CellVar(parent=cell), data, lin[kk][ix+1]) - cell.left = a - cell.right = b - tmp.append([cell.left, cell.right]) + if type(cell) == CellVar: + a = assign_observs_Taxol(CellVar(parent=cell), data, l) + b = assign_observs_Taxol(CellVar(parent=cell), data, lin[kk][ix+1]) + cell.left = a + cell.right = b + if np.all(np.isnan(a.obs[2:4])) or np.all(np.isnan(b.obs[2:4])): + tmp.append([np.nan, np.nan]) + else: + tmp.append([cell.left, cell.right]) + else: + tmp.append([np.nan, np.nan]) else: tmp.append([np.nan, np.nan]) @@ -380,58 +396,92 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): new_lins = [] for lin in lineages: n = [x for x in lin if str(x) != 'nan'] - m = [x for x in n if (not(np.isnan(x.obs[2])) or not(np.isnan(x.obs[3])))] + + for kk, cells in enumerate(n): + if np.all(np.isnan(cells.obs[2:4])): + m = n[:kk] + else: + m = n + new_lins.append(m) + return new_lins +def trim_taxol(lineages): + """removed messed up lineages. e.g., those that divided but either didn't have G1 or SG2 although were in middle generations.. """ + + trimed_lineages = copy(lineages) + for lin in lineages: + rm = 0 + for cell in lin: + + # if it divided + if cell.left or cell.right: + # but also died in either phase + if cell.obs[0] == 0 or cell.obs[1] == 0: + # discrepancy... get rid of the lineage + rm += 1 + + # if it didn't start the lineage, and doesn't have a G1, remove lineage + if cell.gen > 1: + if (np.isnan(cell.obs[2]) or cell.obs[2] == 0.0) and cell.obs[3] > 0.0: + rm += 1 + + if (cell.obs[2] == 0.0 and cell.obs[4] == 1) or (cell.obs[3] == 0.0 and cell.obs[5] == 1): + rm += 1 + + if rm > 0: + trimed_lineages.remove(lin) + return [x for x in trimed_lineages if x] + + def import_taxol(): """Import taxol data by condition""" print("untreated") - untreated = [import_taxol_file("HC00801_A1_field_1_level_1.csv") + - import_taxol_file("HC00801_A1_field_2_level_1.csv") + - import_taxol_file("HC00801_A1_field_3_level_1.csv") + - import_taxol_file("HC00801_A1_field_4_level_1.csv")] + untreated = [trim_taxol(import_taxol_file("HC00801_A1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_A1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_A1_field_4_level_1.csv"))] print("taxol 0.5") - taxol_05 = [import_taxol_file("HC00801_A2_field_1_level_1.csv") + - import_taxol_file("HC00801_A2_field_2_level_1.csv") + - import_taxol_file("HC00801_A2_field_3_level_1.csv") + - import_taxol_file("HC00801_A2_field_4_level_1.csv")] + taxol_05 = [trim_taxol(import_taxol_file("HC00801_A2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_A2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_A2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_A2_field_4_level_1.csv"))] print("taxol 1") - taxol_1 = [import_taxol_file("HC00801_B1_field_1_level_1.csv") + - import_taxol_file("HC00801_B1_field_2_level_1.csv") + - import_taxol_file("HC00801_B1_field_3_level_1.csv") + - import_taxol_file("HC00801_B1_field_4_level_1.csv")] + taxol_1 = [trim_taxol(import_taxol_file("HC00801_B1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_B1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_B1_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_B1_field_4_level_1.csv"))] print("taxol 1.5") - taxol_15 = [import_taxol_file("HC00801_B2_field_1_level_1.csv") + - import_taxol_file("HC00801_B2_field_2_level_1.csv") + - import_taxol_file("HC00801_B2_field_3_level_1.csv") + - import_taxol_file("HC00801_B2_field_4_level_1.csv")] + taxol_15 = [trim_taxol(import_taxol_file("HC00801_B2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_B2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_B2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_B2_field_4_level_1.csv"))] print("taxol 2") - taxol_2 = [import_taxol_file("HC00801_C1_field_1_level_1.csv") + - import_taxol_file("HC00801_C1_field_2_level_1.csv") + - import_taxol_file("HC00801_C1_field_3_level_1.csv") + - import_taxol_file("HC00801_C1_field_4_level_1.csv")] + taxol_2 = [trim_taxol(import_taxol_file("HC00801_C1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_C1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_C1_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_C1_field_4_level_1.csv"))] print("taxol 2.5") - taxol_25 = [import_taxol_file("HC00801_C2_field_1_level_1.csv") + - import_taxol_file("HC00801_C2_field_2_level_1.csv") + - import_taxol_file("HC00801_C2_field_3_level_1.csv") + - import_taxol_file("HC00801_C2_field_4_level_1.csv")] + taxol_25 = [trim_taxol(import_taxol_file("HC00801_C2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_C2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_C2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_C2_field_4_level_1.csv"))] print("taxol 3") - taxol_3 = [import_taxol_file("HC00801_D1_field_1_level_1.csv") + - import_taxol_file("HC00801_D1_field_2_level_1.csv") + - import_taxol_file("HC00801_D1_field_3_level_1.csv") + - import_taxol_file("HC00801_D1_field_4_level_1.csv")] + taxol_3 = [trim_taxol(import_taxol_file("HC00801_D1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_D1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_D1_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_D1_field_4_level_1.csv"))] print("taxol 4") - taxol_4 = [import_taxol_file("HC00801_D2_field_1_level_1.csv") + - import_taxol_file("HC00801_D2_field_2_level_1.csv") + - import_taxol_file("HC00801_D2_field_3_level_1.csv") + - import_taxol_file("HC00801_D2_field_4_level_1.csv")] + taxol_4 = [trim_taxol(import_taxol_file("HC00801_D2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_D2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_D2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file("HC00801_D2_field_4_level_1.csv"))] return untreated[0], taxol_05[0], taxol_1[0], taxol_15[0], taxol_2[0], taxol_25[0], taxol_3[0], taxol_4[0] diff --git a/lineage/plotTree.py b/lineage/plotTree.py index 53eef07c2..2ef6edee5 100644 --- a/lineage/plotTree.py +++ b/lineage/plotTree.py @@ -484,6 +484,8 @@ def draw_clade(clade, x_start, color, lw): axes.set_ylabel("taxa") # Add margins around the tree to prevent overlapping the axes xmax = max(x_posns.values()) + if not(np.isfinite(xmax)): + xmax = 1.0 axes.set_xlim(-0.05 * xmax, 1.25 * xmax) # Also invert the y-axis (origin at the top) # Add a small vertical margin, but avoid including 0 and N+1 on the y axis diff --git a/output/figureS18.svg b/output/figureS18.svg new file mode 100644 index 000000000..f02105279 --- /dev/null +++ b/output/figureS18.svg @@ -0,0 +1,18987 @@ + + + + + + + + 2023-01-12T10:53:03.790247 + image/svg+xml + + + Matplotlib v3.6.1, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a + + + Untreated + + + + + + + + + + + + + + + + + + + + + + + + + + b + + + Taxol 1 nM + + + + + + + + + + + + + + + + + + + + + + + + + + c + + + Taxol 2 nM + + + + + + + + + + + + + + + + + + + + + + + + + + d + + + Taxol 3 nM + + + + + + + + + + + + + + + + + + + + + + + + + + e + + + Taxol 4 nM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5dc1c8d339fa562ae4e2300349478496b43e3503 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Thu, 12 Jan 2023 11:11:33 -0800 Subject: [PATCH 07/12] clean up --- lineage/Lineage_collections.py | 20 ++++++++++---------- lineage/figures/figureS18.py | 25 ++++++++++--------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/lineage/Lineage_collections.py b/lineage/Lineage_collections.py index 2c2eb0a8d..fd905df60 100644 --- a/lineage/Lineage_collections.py +++ b/lineage/Lineage_collections.py @@ -1,7 +1,7 @@ """ This file is to collect those lineages that have the same condition, and have 3 or greater number of cells in their lineages. """ from .LineageInputOutput import import_exp_data -from .import_lineage import MCF10A, import_taxol_file +from .import_lineage import MCF10A, import_taxol from .states.StateDistributionGaPhs import StateDistribution from .states.StateDistributionGamma import StateDistribution as StDist from .LineageTree import LineageTree @@ -220,12 +220,12 @@ def popout_single_lineages(lineages): ########################################################## # NEW PACLITAXEL DATA -# untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() -untreated_t = import_taxol_file() -untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] # 11427 cells -# Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 8895 cells -# Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 7782 cells -# Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 8024 cells -# Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 8024 cells - -# taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_3, Taxol_4] \ No newline at end of file +untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() +# 555, 1119, 486, 382, 272, 365, 246, 266 +untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] # 555 cells +Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 486 cells +Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 272 cells +Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 246 cells +Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 266 cells + +taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_3, Taxol_4] \ No newline at end of file diff --git a/lineage/figures/figureS18.py b/lineage/figures/figureS18.py index 351900919..470cc7884 100644 --- a/lineage/figures/figureS18.py +++ b/lineage/figures/figureS18.py @@ -1,5 +1,5 @@ """ In this file we plot the raw data before fitting from paclitaxel treated HCC1143 cells """ -# from ..Lineage_collections import untreated_taxol as Taxol_lin_list +from ..Lineage_collections import taxols as Taxol_lin_list import numpy as np from ..import_lineage import import_taxol from ..plotTree import plotLineage @@ -12,33 +12,28 @@ E = [StateDistribution() for _ in range(desired_num_states)] untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() -untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] -Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] -Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] -Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] -Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] -print(len(untreated_taxol), len(Taxol_1), len(Taxol_2), len(Taxol_3), len(Taxol_4)) -counts = np.min([len(untreated_taxol), len(Taxol_1), len(Taxol_2), len(Taxol_3), len(Taxol_4)]) +counts = [len(i) for i in Taxol_lin_list] +print(counts) def makeFigure(): """ Makes figure S18. """ titles = ["Untreated", "Taxol 1 nM", "Taxol 2 nM", "Taxol 3 nM", "Taxol 4 nM"] - ax, f = getSetup((20, 35), (counts, 5)) + ax, f = getSetup((20, 35), (np.min(counts), 5)) - for i in range(counts): + for i in range(np.min(counts)): ax[5 * i].axis('off') ax[5 * i + 1].axis('off') ax[5 * i + 2].axis('off') ax[5 * i + 3].axis('off') ax[5 * i + 4].axis('off') - plotLineage(untreated_taxol[i], ax[5 * i], color=False) - plotLineage(Taxol_1[i], ax[5 * i + 1], color=False) - plotLineage(Taxol_2[i], ax[5 * i + 2], color=False) - plotLineage(Taxol_3[i], ax[5 * i + 3], color=False) - plotLineage(Taxol_4[i], ax[5 * i + 4], color=False) + plotLineage(Taxol_lin_list[0][i], ax[5 * i], color=False) + plotLineage(Taxol_lin_list[1][i], ax[5 * i + 1], color=False) + plotLineage(Taxol_lin_list[2][i], ax[5 * i + 2], color=False) + plotLineage(Taxol_lin_list[3][i], ax[5 * i + 3], color=False) + plotLineage(Taxol_lin_list[4][i], ax[5 * i + 4], color=False) for i in range(5): ax[i].axis('off') From 33b9bc16117a0b2223f14a19ceef2906ea9576c2 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Thu, 12 Jan 2023 11:14:55 -0800 Subject: [PATCH 08/12] clean up --- lineage/import_lineage.py | 82 ++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index e25dbe126..42ea2777d 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -435,53 +435,45 @@ def trim_taxol(lineages): return [x for x in trimed_lineages if x] -def import_taxol(): +def import_taxol(HC="HC00801"): """Import taxol data by condition""" - print("untreated") - untreated = [trim_taxol(import_taxol_file("HC00801_A1_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_A1_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_A1_field_4_level_1.csv"))] - - print("taxol 0.5") - taxol_05 = [trim_taxol(import_taxol_file("HC00801_A2_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_A2_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_A2_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_A2_field_4_level_1.csv"))] - - print("taxol 1") - taxol_1 = [trim_taxol(import_taxol_file("HC00801_B1_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_B1_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_B1_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_B1_field_4_level_1.csv"))] - - print("taxol 1.5") - taxol_15 = [trim_taxol(import_taxol_file("HC00801_B2_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_B2_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_B2_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_B2_field_4_level_1.csv"))] - - print("taxol 2") - taxol_2 = [trim_taxol(import_taxol_file("HC00801_C1_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_C1_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_C1_field_3_level_1.csv")) + + untreated = [trim_taxol(import_taxol_file(HC + "_A1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_A1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_A1_field_4_level_1.csv"))] + + taxol_05 = [trim_taxol(import_taxol_file(HC + "_A2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_A2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_A2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_A2_field_4_level_1.csv"))] + + taxol_1 = [trim_taxol(import_taxol_file(HC + "_B1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_B1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_B1_field_3_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_B1_field_4_level_1.csv"))] + + taxol_15 = [trim_taxol(import_taxol_file(HC + "_B2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_B2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_B2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_B2_field_4_level_1.csv"))] + + taxol_2 = [trim_taxol(import_taxol_file(HC + "_C1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_C1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_C1_field_3_level_1.csv")) + trim_taxol(import_taxol_file("HC00801_C1_field_4_level_1.csv"))] - print("taxol 2.5") - taxol_25 = [trim_taxol(import_taxol_file("HC00801_C2_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_C2_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_C2_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_C2_field_4_level_1.csv"))] - - print("taxol 3") - taxol_3 = [trim_taxol(import_taxol_file("HC00801_D1_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_D1_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_D1_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_D1_field_4_level_1.csv"))] - - print("taxol 4") - taxol_4 = [trim_taxol(import_taxol_file("HC00801_D2_field_1_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_D2_field_2_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_D2_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_D2_field_4_level_1.csv"))] + taxol_25 = [trim_taxol(import_taxol_file(HC + "_C2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_C2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_C2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_C2_field_4_level_1.csv"))] + + taxol_3 = [trim_taxol(import_taxol_file(HC + "_D1_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_D1_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_D1_field_3_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_D1_field_4_level_1.csv"))] + + taxol_4 = [trim_taxol(import_taxol_file(HC + "_D2_field_1_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_D2_field_2_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_D2_field_3_level_1.csv")) + + trim_taxol(import_taxol_file(HC + "_D2_field_4_level_1.csv"))] return untreated[0], taxol_05[0], taxol_1[0], taxol_15[0], taxol_2[0], taxol_25[0], taxol_3[0], taxol_4[0] From 390dc3210ce49cc5d3359b3304587d3c9e618ca2 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Sat, 4 Feb 2023 13:49:29 -0800 Subject: [PATCH 09/12] some edits --- lineage/Lineage_collections.py | 6 +- lineage/figures/common.py | 3 +- lineage/figures/figureS11.py | 9 ++- lineage/figures/figureS18.py | 42 ++++++------- lineage/figures/figureS19.py | 45 ++++++++++++++ lineage/import_lineage.py | 104 +++++++++++++++++++++------------ lineage/plotTree.py | 4 +- 7 files changed, 150 insertions(+), 63 deletions(-) create mode 100644 lineage/figures/figureS19.py diff --git a/lineage/Lineage_collections.py b/lineage/Lineage_collections.py index fd905df60..40ceebb62 100644 --- a/lineage/Lineage_collections.py +++ b/lineage/Lineage_collections.py @@ -220,12 +220,12 @@ def popout_single_lineages(lineages): ########################################################## # NEW PACLITAXEL DATA -untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() +untreated_t, taxol_1, taxol_2, taxol_4 = import_taxol() # 555, 1119, 486, 382, 272, 365, 246, 266 untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] # 555 cells Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 486 cells Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 272 cells -Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 246 cells +# Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 246 cells Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 266 cells -taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_3, Taxol_4] \ No newline at end of file +taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_4] \ No newline at end of file diff --git a/lineage/figures/common.py b/lineage/figures/common.py index 52c5dd30c..2a96d2d68 100644 --- a/lineage/figures/common.py +++ b/lineage/figures/common.py @@ -615,7 +615,8 @@ def sort_lins(tHMMobj): for i in range(num_st): st_i = [index for index, val in enumerate(st) if val == i] temp = [tHMMobj.X[k] for k in st_i] + to_append = temp if len(temp) <= 40 else temp[:40] - states += temp + states += to_append return states diff --git a/lineage/figures/figureS11.py b/lineage/figures/figureS11.py index c0f7a2397..eb7e5be10 100644 --- a/lineage/figures/figureS11.py +++ b/lineage/figures/figureS11.py @@ -27,6 +27,7 @@ for i in range(4): lapt_tHMMobj_list[i].X = sort_lins(lapt_tHMMobj_list[i]) + print(len(lapt_tHMMobj_list[i].X)) def makeFigure(): @@ -34,16 +35,20 @@ def makeFigure(): Makes figure 100. """ titles = ["Control", "Lapatinib 25 nM", "Lapatinib 50 nM", "Lapatinib 250 nM"] - ax, f = getSetup((15, 45), (170, 4)) + ax, f = getSetup((15, 65), (160, 4)) - for i in range(170): + for i in range(160): ax[4 * i].axis('off') ax[4 * i + 1].axis('off') ax[4 * i + 2].axis('off') ax[4 * i + 3].axis('off') + for i in range(len(lapt_tHMMobj_list[0].X)): plotLineage(lapt_tHMMobj_list[0].X[i], ax[4 * i]) + for i in range(len(lapt_tHMMobj_list[1].X)): plotLineage(lapt_tHMMobj_list[1].X[i], ax[4 * i + 1]) + for i in range(len(lapt_tHMMobj_list[2].X)): plotLineage(lapt_tHMMobj_list[2].X[i], ax[4 * i + 2]) + for i in range(len(lapt_tHMMobj_list[3].X)): plotLineage(lapt_tHMMobj_list[3].X[i], ax[4 * i + 3]) for i in range(4): diff --git a/lineage/figures/figureS18.py b/lineage/figures/figureS18.py index 470cc7884..3d43942ea 100644 --- a/lineage/figures/figureS18.py +++ b/lineage/figures/figureS18.py @@ -1,7 +1,7 @@ """ In this file we plot the raw data before fitting from paclitaxel treated HCC1143 cells """ -from ..Lineage_collections import taxols as Taxol_lin_list +# from ..Lineage_collections import taxols as Taxol_lin_list import numpy as np -from ..import_lineage import import_taxol +from ..import_lineage import import_taxol_file, trim_taxol from ..plotTree import plotLineage from .common import getSetup from string import ascii_lowercase @@ -10,32 +10,34 @@ desired_num_states = 2 E = [StateDistribution() for _ in range(desired_num_states)] - -untreated_t, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() - -counts = [len(i) for i in Taxol_lin_list] -print(counts) +untreated_t = import_taxol_file() +untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] +c = 0 +for lins in untreated_t: + for cell in lins: + c += 1 +# counts = len(untreated_taxol) +counts = 100 +print("number of lineages", len(untreated_taxol), " and the number of total cells: ", c) def makeFigure(): """ Makes figure S18. """ titles = ["Untreated", "Taxol 1 nM", "Taxol 2 nM", "Taxol 3 nM", "Taxol 4 nM"] - ax, f = getSetup((20, 35), (np.min(counts), 5)) + ax, f = getSetup((17, 35), (counts, 4)) - for i in range(np.min(counts)): - ax[5 * i].axis('off') - ax[5 * i + 1].axis('off') - ax[5 * i + 2].axis('off') - ax[5 * i + 3].axis('off') - ax[5 * i + 4].axis('off') - plotLineage(Taxol_lin_list[0][i], ax[5 * i], color=False) - plotLineage(Taxol_lin_list[1][i], ax[5 * i + 1], color=False) - plotLineage(Taxol_lin_list[2][i], ax[5 * i + 2], color=False) - plotLineage(Taxol_lin_list[3][i], ax[5 * i + 3], color=False) - plotLineage(Taxol_lin_list[4][i], ax[5 * i + 4], color=False) + for i in range(counts): + ax[4 * i].axis('off') + # ax[4 * i + 1].axis('off') + # ax[4 * i + 2].axis('off') + # ax[4 * i + 3].axis('off') + plotLineage(untreated_taxol[i], ax[4 * i], color=False) + # plotLineage(Taxol_lin_list[1][i], ax[4 * i + 1], color=False) + # plotLineage(Taxol_lin_list[2][i], ax[4 * i + 2], color=False) + # plotLineage(Taxol_lin_list[3][i], ax[4 * i + 3], color=False) - for i in range(5): + for i in range(4): ax[i].axis('off') ax[i].text(-0.2, 1.55, ascii_lowercase[i], transform=ax[i].transAxes, fontsize=20, fontweight="bold", va="top") ax[i].text(0.0, 1.55, titles[i], transform=ax[i].transAxes, fontsize=20, va="top") diff --git a/lineage/figures/figureS19.py b/lineage/figures/figureS19.py new file mode 100644 index 000000000..a310bfcfa --- /dev/null +++ b/lineage/figures/figureS19.py @@ -0,0 +1,45 @@ +""" BIC for Taxol data.""" +from ..Lineage_collections import taxols as Taxol_lin_list +from ..Analyze import run_Analyze_over, Analyze_list +from .common import getSetup + +import pickle +import numpy as np +from matplotlib.ticker import MaxNLocator + +desired_num_states = np.arange(1, 8) + +def find_BIC(data, desired_num_states, num_cells, mc=False): + # Copy out data to full set + dataFull = [] + for _ in desired_num_states: + dataFull.append(data) + # Run fitting + output = run_Analyze_over(dataFull, desired_num_states, atonce=True) + BICs = np.array([oo[0][0].get_BIC(oo[1], num_cells, atonce=True, mcf10a=mc)[0] for oo in output]) + thobj = [oo[0] for oo in output] + return BICs - np.min(BICs, axis=0), thobj + +def makeFigure(): + """ + Makes figure 9. + """ + ax, f = getSetup((14, 4), (1, 3)) + + BIC, Obj = find_BIC(Taxol_lin_list, desired_num_states, num_cells=1041) + + # create a pickle file + pik1 = open("taxols.pkl", "wb") + for lapt_tHMMobj_list in Obj: + for laps in lapt_tHMMobj_list: + pickle.dump(laps, pik1) + pik1.close() + + i = 0 + ax[i].set_xlabel("Number of States Predicted") + ax[i].set_ylabel("Normalized BIC") + ax[i].xaxis.set_major_locator(MaxNLocator(integer=True)) + + ax[0].set_title("Taxol Treated Populations") + + return f \ No newline at end of file diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index 42ea2777d..b99807ea1 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -242,6 +242,7 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): all_parent_ids = cell_lineage["parent"].unique() cell_df = cell_lineage.loc[cell_lineage["label"] == label] + parent_id = cell_df["parent"].unique()[0] if parent_id == 0: cell.gen = 1 @@ -256,11 +257,7 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): cell.obs[0] = np.nan # if no G1, then there is SG2, so it has definitely transitioned from G1 to SG2 cell.obs[2] = np.nan cell.obs[4] = np.nan - # if cell.gen > 1: - # cell.obs[1] = np.nan - # cell.obs[3] = np.nan - # cell.obs[5] = np.nan - # return cell + else: # G1 length cell.obs[2] = (np.nanmax(G1_df["elapsed_minutes"]) - np.nanmin(G1_df["elapsed_minutes"])) / 60 # G1 duration @@ -305,23 +302,42 @@ def assign_observs_Taxol(cell, cell_lineage, label: int): def sep_lineages(data): labels = list(data["label"].unique()) all_parent_ids = list(data["parent"].unique()) - - a = [] - for i, val in enumerate(labels): + root_parent_labels = data.loc[data["parent"] == 0]["label"].unique() + lin = [[[item]] for item in root_parent_labels] + + # remove singleton lineages that only existed in 1 frame + xxx = 0 + remains = [] + for value in root_parent_labels: + dff = data.loc[data["label"]==value] + if len(dff) == 1: + # print(dff[["label", "well", "field", "time_slice", "row", "column", "plateID"]]) + xxx += 1 + lin.remove([[value]]) + elif len(dff) > 1: + remains.append(value) + + for i, val in enumerate(remains): df = data.loc[data["label"]==val] # cell itself - if len(df) == 1: - continue - else: - if np.all(df["is_parent"] == True): - df_parent = data.loc[data["parent"] == val] # cell's parent - assert val in all_parent_ids - if len(df_parent["label"].unique()) == 2: - a.append([[val]] + [list(df_parent["label"].unique())]) + # if it only appeard in one frame, discard + assert len(df) > 1 + + # if it has divided + if np.all(df["is_parent"] == True): + assert val in all_parent_ids + df_children = data.loc[data["parent"] == val] # cell's children + # if the cell has two children + child_labels = list(df_children["label"].unique()) + if len(child_labels) == 2: + lin[i] += [child_labels] else: - # a.append([[val]]) - continue + print("not two children. cell label: ", val, "child label: ", child_labels) + else: + # singleton lineage + continue + print("number of cells that only appear in 1 frame: ", xxx) - out1 = separate_lineages(data, all_parent_ids, a, 2) + out1 = separate_lineages(data, all_parent_ids, lin, 2) out2 = separate_lineages(data, all_parent_ids, out1, 3) out3 = separate_lineages(data, all_parent_ids, out2, 4) out4 = separate_lineages(data, all_parent_ids, out3, 5) @@ -330,6 +346,7 @@ def sep_lineages(data): return out5 def separate_lineages(data, all_parent_ids, ls, k): + """Given the lineages that only includes up to k generations of cells, add the k+1 generation to those lineages that have it.""" lss = ls.copy() for j, val in enumerate(ls): if len(val) == k: @@ -382,10 +399,7 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): b = assign_observs_Taxol(CellVar(parent=cell), data, lin[kk][ix+1]) cell.left = a cell.right = b - if np.all(np.isnan(a.obs[2:4])) or np.all(np.isnan(b.obs[2:4])): - tmp.append([np.nan, np.nan]) - else: - tmp.append([cell.left, cell.right]) + tmp.append([cell.left, cell.right]) else: tmp.append([np.nan, np.nan]) else: @@ -394,44 +408,62 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): lin_temp.append(list(it.chain(*tmp))) lineages.append(list(it.chain(*lin_temp))) new_lins = [] - for lin in lineages: + counts_ = 0 + # remove nans + for jj, lin in enumerate(lineages): n = [x for x in lin if str(x) != 'nan'] for kk, cells in enumerate(n): + # remove those lineages with cells that have NaN intensity ratio if np.all(np.isnan(cells.obs[2:4])): - m = n[:kk] + counts_ += 1 + n = [] + break else: - m = n + pass - new_lins.append(m) + new_lins.append(n) + print("this is counts of NaN ratio lineages", counts_) - return new_lins + # remove empty lineages and return + return [s for s in new_lins if s] def trim_taxol(lineages): """removed messed up lineages. e.g., those that divided but either didn't have G1 or SG2 although were in middle generations.. """ trimed_lineages = copy(lineages) - for lin in lineages: + counts, countsG1, countsG2 = 0, 0, 0 + for ix, lin in enumerate(lineages): rm = 0 for cell in lin: + # cells with only one daughter + if not(cell.left and cell.right) and not(cell.isLeaf()): + rm += 1 + counts += 1 # if it divided - if cell.left or cell.right: + if cell.left: + assert cell.right # but also died in either phase - if cell.obs[0] == 0 or cell.obs[1] == 0: + if cell.obs[0] == 0: # discrepancy... get rid of the lineage rm += 1 + countsG1 += 1 + elif cell.obs[1] == 0: + countsG2 += 1 - # if it didn't start the lineage, and doesn't have a G1, remove lineage + # # if it didn't start the lineage, and doesn't have a G1, remove lineage if cell.gen > 1: if (np.isnan(cell.obs[2]) or cell.obs[2] == 0.0) and cell.obs[3] > 0.0: rm += 1 - - if (cell.obs[2] == 0.0 and cell.obs[4] == 1) or (cell.obs[3] == 0.0 and cell.obs[5] == 1): - rm += 1 + counts += 1 + print("lineage index: ", ix) + break if rm > 0: trimed_lineages.remove(lin) + # print("number of cells that divided but also died G1: ", countsG1, "For G2: ", countsG2) + # print("number of cells that started their cycle with SG2: ", counts) return [x for x in trimed_lineages if x] @@ -476,4 +508,4 @@ def import_taxol(HC="HC00801"): trim_taxol(import_taxol_file(HC + "_D2_field_3_level_1.csv")) + trim_taxol(import_taxol_file(HC + "_D2_field_4_level_1.csv"))] - return untreated[0], taxol_05[0], taxol_1[0], taxol_15[0], taxol_2[0], taxol_25[0], taxol_3[0], taxol_4[0] + return untreated[0], taxol_1[0], taxol_2[0], taxol_4[0] diff --git a/lineage/plotTree.py b/lineage/plotTree.py index 2ef6edee5..cbe7fedf7 100644 --- a/lineage/plotTree.py +++ b/lineage/plotTree.py @@ -484,8 +484,10 @@ def draw_clade(clade, x_start, color, lw): axes.set_ylabel("taxa") # Add margins around the tree to prevent overlapping the axes xmax = max(x_posns.values()) - if not(np.isfinite(xmax)): + if xmax <= 1.0: xmax = 1.0 + else: + pass axes.set_xlim(-0.05 * xmax, 1.25 * xmax) # Also invert the y-axis (origin at the top) # Add a small vertical margin, but avoid including 0 and N+1 on the y axis From 88e9522f916b23b8ab76ceab497fb53a2001d57e Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Sun, 5 Feb 2023 15:12:47 -0800 Subject: [PATCH 10/12] ready to merge? --- lineage/Lineage_collections.py | 6 +++--- lineage/figures/common.py | 3 +-- lineage/figures/figureS11.py | 8 ++------ lineage/import_lineage.py | 10 +++++----- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lineage/Lineage_collections.py b/lineage/Lineage_collections.py index 40ceebb62..2f767eb08 100644 --- a/lineage/Lineage_collections.py +++ b/lineage/Lineage_collections.py @@ -220,12 +220,12 @@ def popout_single_lineages(lineages): ########################################################## # NEW PACLITAXEL DATA -untreated_t, taxol_1, taxol_2, taxol_4 = import_taxol() +untreated, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 = import_taxol() # 555, 1119, 486, 382, 272, 365, 246, 266 -untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated_t] # 555 cells +untreated_taxol = [LineageTree(list_cells, E) for list_cells in untreated] # 555 cells Taxol_1 = [LineageTree(list_cells, E) for list_cells in taxol_1] # 486 cells Taxol_2 = [LineageTree(list_cells, E) for list_cells in taxol_2] # 272 cells -# Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 246 cells +Taxol_3 = [LineageTree(list_cells, E) for list_cells in taxol_3] # 246 cells Taxol_4 = [LineageTree(list_cells, E) for list_cells in taxol_4] # 266 cells taxols = [untreated_taxol, Taxol_1, Taxol_2, Taxol_4] \ No newline at end of file diff --git a/lineage/figures/common.py b/lineage/figures/common.py index 2a96d2d68..52c5dd30c 100644 --- a/lineage/figures/common.py +++ b/lineage/figures/common.py @@ -615,8 +615,7 @@ def sort_lins(tHMMobj): for i in range(num_st): st_i = [index for index, val in enumerate(st) if val == i] temp = [tHMMobj.X[k] for k in st_i] - to_append = temp if len(temp) <= 40 else temp[:40] - states += to_append + states += temp return states diff --git a/lineage/figures/figureS11.py b/lineage/figures/figureS11.py index eb7e5be10..73e1bba0e 100644 --- a/lineage/figures/figureS11.py +++ b/lineage/figures/figureS11.py @@ -35,20 +35,16 @@ def makeFigure(): Makes figure 100. """ titles = ["Control", "Lapatinib 25 nM", "Lapatinib 50 nM", "Lapatinib 250 nM"] - ax, f = getSetup((15, 65), (160, 4)) + ax, f = getSetup((15, 45), (170, 4)) - for i in range(160): + for i in range(170): ax[4 * i].axis('off') ax[4 * i + 1].axis('off') ax[4 * i + 2].axis('off') ax[4 * i + 3].axis('off') - for i in range(len(lapt_tHMMobj_list[0].X)): plotLineage(lapt_tHMMobj_list[0].X[i], ax[4 * i]) - for i in range(len(lapt_tHMMobj_list[1].X)): plotLineage(lapt_tHMMobj_list[1].X[i], ax[4 * i + 1]) - for i in range(len(lapt_tHMMobj_list[2].X)): plotLineage(lapt_tHMMobj_list[2].X[i], ax[4 * i + 2]) - for i in range(len(lapt_tHMMobj_list[3].X)): plotLineage(lapt_tHMMobj_list[3].X[i], ax[4 * i + 3]) for i in range(4): diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index b99807ea1..810415ab8 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -1,9 +1,9 @@ """ This file includes functions to import the new lineage data. """ import pandas as pd +import itertools from copy import copy -import itertools as it import numpy as np -from .CellVar import CellVar, find_two_subtrees +from .CellVar import CellVar ############################ # importing AU565 data (new) @@ -33,7 +33,7 @@ def import_AU565(path: str) -> list: for j in unique_parent_trackIDs: if j != 0: pid.append(np.count_nonzero(lineage["parentTrackId"] == j) * [j]) - parent_ids = list(it.chain(*pid)) + parent_ids = list(itertools.chain(*pid)) # create the root parent cell and assign obsrvations parent_cell = CellVar(parent=None) @@ -491,7 +491,7 @@ def import_taxol(HC="HC00801"): taxol_2 = [trim_taxol(import_taxol_file(HC + "_C1_field_1_level_1.csv")) + trim_taxol(import_taxol_file(HC + "_C1_field_2_level_1.csv")) + trim_taxol(import_taxol_file(HC + "_C1_field_3_level_1.csv")) + - trim_taxol(import_taxol_file("HC00801_C1_field_4_level_1.csv"))] + trim_taxol(import_taxol_file(HC + "_C1_field_4_level_1.csv"))] taxol_25 = [trim_taxol(import_taxol_file(HC + "_C2_field_1_level_1.csv")) + trim_taxol(import_taxol_file(HC + "_C2_field_2_level_1.csv")) + @@ -508,4 +508,4 @@ def import_taxol(HC="HC00801"): trim_taxol(import_taxol_file(HC + "_D2_field_3_level_1.csv")) + trim_taxol(import_taxol_file(HC + "_D2_field_4_level_1.csv"))] - return untreated[0], taxol_1[0], taxol_2[0], taxol_4[0] + return untreated, taxol_05, taxol_1, taxol_15, taxol_2, taxol_25, taxol_3, taxol_4 From 4c4cb8bfdd0197cc348bcd8f0d993eb69ec14af7 Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Sun, 5 Feb 2023 15:13:29 -0800 Subject: [PATCH 11/12] remove print --- lineage/figures/figureS11.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lineage/figures/figureS11.py b/lineage/figures/figureS11.py index 73e1bba0e..c0f7a2397 100644 --- a/lineage/figures/figureS11.py +++ b/lineage/figures/figureS11.py @@ -27,7 +27,6 @@ for i in range(4): lapt_tHMMobj_list[i].X = sort_lins(lapt_tHMMobj_list[i]) - print(len(lapt_tHMMobj_list[i].X)) def makeFigure(): From 7e91efb4b6a27df86f4e21a0a80a6f669e24846c Mon Sep 17 00:00:00 2001 From: Farnaz Mohammadi Date: Sun, 5 Feb 2023 15:57:58 -0800 Subject: [PATCH 12/12] needs more work --- lineage/figures/figureS19.py | 16 +++------------- lineage/import_lineage.py | 5 ++--- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lineage/figures/figureS19.py b/lineage/figures/figureS19.py index a310bfcfa..a7aaccb72 100644 --- a/lineage/figures/figureS19.py +++ b/lineage/figures/figureS19.py @@ -2,6 +2,7 @@ from ..Lineage_collections import taxols as Taxol_lin_list from ..Analyze import run_Analyze_over, Analyze_list from .common import getSetup +from .figure9 import find_BIC import pickle import numpy as np @@ -9,17 +10,6 @@ desired_num_states = np.arange(1, 8) -def find_BIC(data, desired_num_states, num_cells, mc=False): - # Copy out data to full set - dataFull = [] - for _ in desired_num_states: - dataFull.append(data) - # Run fitting - output = run_Analyze_over(dataFull, desired_num_states, atonce=True) - BICs = np.array([oo[0][0].get_BIC(oo[1], num_cells, atonce=True, mcf10a=mc)[0] for oo in output]) - thobj = [oo[0] for oo in output] - return BICs - np.min(BICs, axis=0), thobj - def makeFigure(): """ Makes figure 9. @@ -30,8 +20,8 @@ def makeFigure(): # create a pickle file pik1 = open("taxols.pkl", "wb") - for lapt_tHMMobj_list in Obj: - for laps in lapt_tHMMobj_list: + for taxol_tHMMobj_list in Obj: + for laps in taxol_tHMMobj_list: pickle.dump(laps, pik1) pik1.close() diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index ef1685e12..15fc9ad02 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -405,8 +405,8 @@ def import_taxol_file(filename="HC00801_A1_field_1_level_1.csv"): else: tmp.append([np.nan, np.nan]) - lin_temp.append(list(it.chain(*tmp))) - lineages.append(list(it.chain(*lin_temp))) + lin_temp.append(list(itertools.chain(*tmp))) + lineages.append(list(itertools.chain(*lin_temp))) new_lins = [] counts_ = 0 # remove nans @@ -457,7 +457,6 @@ def trim_taxol(lineages): if (np.isnan(cell.obs[2]) or cell.obs[2] == 0.0) and cell.obs[3] > 0.0: rm += 1 counts += 1 - print("lineage index: ", ix) break if rm > 0: