python/cell_cycle_gating/dead_cell_filter_ldrint.py
def live_dead(ldrint, ldr_gates=None,
              dna=None, dna_gates=None,
              x_dna=None, ax=None, ldr_control_cutoff=2):
    """Assign classification to individual cells as live/dead based on
    ldrint and DNA content.
    If ax is not None, plots pie chart of fraction live/dead
    1. alive = selected+others, where selected is within
                 inner DNA gate and within LDR
    2. dead = anything outside of DNA outer gating and LDR gating
    3. total = alive + dead; selected + others + dead

    Parameters
    ----------
    ldrint : 1d array
       ldr int feature across all cells in a well
    ldr_gates : list of floats
    dna : 1d array
       DNA content of cells in a given well
    dna_gates : list of floats
    ldr_cutoff : float
       default cutoff if
    x_dna : 1d array
       Expected distribution of DNA content (used as x-axis grid)
    ax : subplot object

    Returns
    -------
    alive : int
       number of cells classied as alive
    dead : int
       numer of cells classified as dead
    outcome : 1d array
       classification of each cell as live(>=0) or dead (-1).
       should have same length as ldrtxt
    """
    if x_dna is None:
        x_dna = np.arange(2.5, 8, 0.02)

    outcome = [0] * len(ldrint)
    logint = np.log10(ldrint)
    logint[np.isnan(logint)] = -10 #dummy value
    
    if ldr_gates is  None:
        ldr_gates, _ = get_ldrgates(ldrint, ldr_control_cutoff)
    ldr_outer = (logint < ldr_gates[0]) | (logint > ldr_gates[1])
    outcome = [-1 if b else 0 for b in ldr_outer]
    #dead = np.sum([1 for ot in outcome if ot == -1])
    alive = np.sum([1 for ot in outcome if ot >= 0])
    selected = 'DNA information unavailable'
    others = 'DNA information unavailable'
    dead_ldrpos = np.sum(ldr_outer)
    cell_fate_dict = {'alive': alive, 'alive_subg1': 0, 'alive_beyondg2': 0,
                          'dead_ldrpos': dead_ldrpos, 'dead_subg1': 0}

    if dna_gates is not None:
        log_dna = compute_log_dna(dna, x_dna)
        dna_outermost = (log_dna < dna_gates[0]) | (log_dna > dna_gates[3])
        dead_ldrpos = np.sum(ldr_outer)
        dead_subg1 = np.sum((ldr_outer==False) & (log_dna < dna_gates[0]))
        alive_beyondg2 = np.sum((ldr_outer==False) & (log_dna > dna_gates[2]))
        alive_subg1 = np.sum((ldr_outer==False) & (log_dna > dna_gates[0]) & (log_dna < dna_gates[1]))
        dna_inner = ((log_dna > dna_gates[1]) &
                     (log_dna < dna_gates[2]) &
                     (ldr_outer==False))
        alive = np.sum(dna_inner)
        #outcome = [-1 if d else 1 if s else 0
        #           for d, s in zip((ldr_outer | dna_outermost), dna_inner)]
        outcome = ((1 * dna_inner) # normal live cells
                   + (1.5 * ((ldr_outer==False) & (log_dna > dna_gates[2]))) # live but higher than G2
                   + (-1 * ((ldr_outer==False) & (log_dna < dna_gates[0]))) # dead very low G1
                   + (1.25 * ((ldr_outer==False) & (log_dna > dna_gates[0]) & (log_dna < dna_gates[1]))) # alive lower than G1
                   + (-2 * ldr_outer)) 
        cell_fate_dict = {'alive': alive, 'alive_subg1': alive_subg1, 'alive_beyondg2': alive_beyondg2,
                          'dead_ldrpos': dead_ldrpos, 'dead_subg1': dead_subg1}
        #alive = np.sum([1 for ot in outcome if ot >= 0])
        #dead = np.sum([1 for s in outcome if s == -1])
        #selected = np.sum([1 for s in outcome if s == 1])
        #others = np.sum([1 for s in outcome if s == 0])
        if ax is not None:
            ax.pie([alive, alive_subg1, alive_beyondg2, dead_ldrpos, dead_subg1],
                   labels=['alive', 'alive_subg1', 'alive_beyondg2', 'dead_ldrpos', 'dead_subg1'],
                   explode=(0.1, 0.1, 0.1, 0.1, 0.1), autopct='%1.1f%%')
            ax.axis('equal')
    else:
        if ax is not None:
            ax.pie([alive, dead_ldrpos], labels=['alive', 'dead_ldrpos'],
                   explode=(0.1, 0.1), autopct='%1.1f%%')
            ax.axis('equal')
    return cell_fate_dict, outcome
Assign classification to individual cells as live/dead based on
    ldrint and DNA content.
    If ax is not None, plots pie chart of fraction live/dead
    1. alive = selected+others, where selected is within
                 inner DNA gate and within LDR
    2. dead = anything outside of DNA outer gating and LDR gating
    3. total = alive + dead; selected + others + dead

    Parameters
    ----------
    ldrint : 1d array
       ldr int feature across all cells in a well
    ldr_gates : list of floats
    dna : 1d array
       DNA content of cells in a given well
    dna_gates : list of floats
    ldr_cutoff : float
       default cutoff if
    x_dna : 1d array
       Expected distribution of DNA content (used as x-axis grid)
    ax : subplot object

    Returns
    -------
    alive : int
       number of cells classied as alive
    dead : int
       numer of cells classified as dead
    outcome : 1d array
       classification of each cell as live(>=0) or dead (-1).
       should have same length as ldrtxt
    
Assign classification to individual cells as live/dead based on
ldrint and DNA content.
If ax is not None, plots pie chart of fraction live/dead
1. alive = selected+others, where selected is within
inner DNA gate and within LDR
2. dead = anything outside of DNA outer gating and LDR gating
3. total = alive + dead; selected + others + dead

Parameters



Returns

alive : int
number of cells classied as alive
dead : int
numer of cells classified as dead
outcome : 1d array
classification of each cell as live(>=0) or dead (-1).
should have same length as ldrtxt
Assign classification to individual cells as live / dead based on ldrint and DNA content . If ax is not None plots pie chart of fraction live / dead 1 . alive = selected + others where selected is within inner DNA gate and within LDR 2 . dead = anything outside of DNA outer gating and LDR gating 3 . total = alive + dead ; selected + others + dead Parameters Returns alive : int number of cells classied as alive dead : int numer of cells classified as dead outcome : 1d array classification of each cell as live ( > = 0 ) or dead ( - 1 ) . should have same length as ldrtxt
def live_dead(ldrint, ldr_gates=None,
              dna=None, dna_gates=None,
              x_dna=None, ax=None, ldr_control_cutoff=2):
    if x_dna is None:
        x_dna = np.arange(2.5, 8, 0.02)
    outcome = [0] * len(ldrint)
    logint = np.log10(ldrint)
    logint[np.isnan(logint)] = -10 
    if ldr_gates is  None:
        ldr_gates, _ = get_ldrgates(ldrint, ldr_control_cutoff)
    ldr_outer = (logint < ldr_gates[0]) | (logint > ldr_gates[1])
    outcome = [-1 if b else 0 for b in ldr_outer]
    alive = np.sum([1 for ot in outcome if ot >= 0])
    selected = 'DNA information unavailable'
    others = 'DNA information unavailable'
    dead_ldrpos = np.sum(ldr_outer)
    cell_fate_dict = {'alive': alive, 'alive_subg1': 0, 'alive_beyondg2': 0,
                          'dead_ldrpos': dead_ldrpos, 'dead_subg1': 0}
    if dna_gates is not None:
        log_dna = compute_log_dna(dna, x_dna)
        dna_outermost = (log_dna < dna_gates[0]) | (log_dna > dna_gates[3])
        dead_ldrpos = np.sum(ldr_outer)
        dead_subg1 = np.sum((ldr_outer==False) & (log_dna < dna_gates[0]))
        alive_beyondg2 = np.sum((ldr_outer==False) & (log_dna > dna_gates[2]))
        alive_subg1 = np.sum((ldr_outer==False) & (log_dna > dna_gates[0]) & (log_dna < dna_gates[1]))
        dna_inner = ((log_dna > dna_gates[1]) &
                     (log_dna < dna_gates[2]) &
                     (ldr_outer==False))
        alive = np.sum(dna_inner)
        outcome = ((1 * dna_inner) 
                   + (1.5 * ((ldr_outer==False) & (log_dna > dna_gates[2]))) 
                   + (-1 * ((ldr_outer==False) & (log_dna < dna_gates[0]))) 
                   + (1.25 * ((ldr_outer==False) & (log_dna > dna_gates[0]) & (log_dna < dna_gates[1]))) 
                   + (-2 * ldr_outer)) 
        cell_fate_dict = {'alive': alive, 'alive_subg1': alive_subg1, 'alive_beyondg2': alive_beyondg2,
                          'dead_ldrpos': dead_ldrpos, 'dead_subg1': dead_subg1}
        if ax is not None:
            ax.pie([alive, alive_subg1, alive_beyondg2, dead_ldrpos, dead_subg1],
                   labels=['alive', 'alive_subg1', 'alive_beyondg2', 'dead_ldrpos', 'dead_subg1'],
                   explode=(0.1, 0.1, 0.1, 0.1, 0.1), autopct='%1.1f%%')
            ax.axis('equal')
    else:
        if ax is not None:
            ax.pie([alive, dead_ldrpos], labels=['alive', 'dead_ldrpos'],
                   explode=(0.1, 0.1), autopct='%1.1f%%')
            ax.axis('equal')
    return cell_fate_dict, outcome
def live_dead ( ldrint , ldr_gates = None , dna = None , dna_gates = None , x_dna = None , ax = None , ldr_control_cutoff = 2 ) : if x_dna is None : x_dna = np . arange ( 2.5 , 8 , 0.02 ) outcome = [ 0 ] * len ( ldrint ) logint = np . log10 ( ldrint ) logint [ np . isnan ( logint ) ] = - 10 if ldr_gates is None : ldr_gates , _ = get_ldrgates ( ldrint , ldr_control_cutoff ) ldr_outer = ( logint < ldr_gates [ 0 ] ) | ( logint > ldr_gates [ 1 ] ) outcome = [ - 1 if b else 0 for b in ldr_outer ] alive = np . sum ( [ 1 for ot in outcome if ot >= 0 ] ) selected = 'DNA information unavailable' others = 'DNA information unavailable' dead_ldrpos = np . sum ( ldr_outer ) cell_fate_dict = { 'alive' : alive , 'alive_subg1' : 0 , 'alive_beyondg2' : 0 , 'dead_ldrpos' : dead_ldrpos , 'dead_subg1' : 0 } if dna_gates is not None : log_dna = compute_log_dna ( dna , x_dna ) dna_outermost = ( log_dna < dna_gates [ 0 ] ) | ( log_dna > dna_gates [ 3 ] ) dead_ldrpos = np . sum ( ldr_outer ) dead_subg1 = np . sum ( ( ldr_outer == False ) & ( log_dna < dna_gates [ 0 ] ) ) alive_beyondg2 = np . sum ( ( ldr_outer == False ) & ( log_dna > dna_gates [ 2 ] ) ) alive_subg1 = np . sum ( ( ldr_outer == False ) & ( log_dna > dna_gates [ 0 ] ) & ( log_dna < dna_gates [ 1 ] ) ) dna_inner = ( ( log_dna > dna_gates [ 1 ] ) & ( log_dna < dna_gates [ 2 ] ) & ( ldr_outer == False ) ) alive = np . sum ( dna_inner ) outcome = ( ( 1 * dna_inner ) + ( 1.5 * ( ( ldr_outer == False ) & ( log_dna > dna_gates [ 2 ] ) ) ) + ( - 1 * ( ( ldr_outer == False ) & ( log_dna < dna_gates [ 0 ] ) ) ) + ( 1.25 * ( ( ldr_outer == False ) & ( log_dna > dna_gates [ 0 ] ) & ( log_dna < dna_gates [ 1 ] ) ) ) + ( - 2 * ldr_outer ) ) cell_fate_dict = { 'alive' : alive , 'alive_subg1' : alive_subg1 , 'alive_beyondg2' : alive_beyondg2 , 'dead_ldrpos' : dead_ldrpos , 'dead_subg1' : dead_subg1 } if ax is not None : ax . pie ( [ alive , alive_subg1 , alive_beyondg2 , dead_ldrpos , dead_subg1 ] , labels = [ 'alive' , 'alive_subg1' , 'alive_beyondg2' , 'dead_ldrpos' , 'dead_subg1' ] , explode = ( 0.1 , 0.1 , 0.1 , 0.1 , 0.1 ) , autopct = '%1.1f%%' ) ax . axis ( 'equal' ) else : if ax is not None : ax . pie ( [ alive , dead_ldrpos ] , labels = [ 'alive' , 'dead_ldrpos' ] , explode = ( 0.1 , 0.1 ) , autopct = '%1.1f%%' ) ax . axis ( 'equal' ) return cell_fate_dict , outcome
Assign classification to individual cells as live/dead based on
ldrint and DNA content.
Assign classification to individual cells as live / dead based on ldrint and DNA content .
"""Assign classification to individual cells as live/dead based on
    ldrint and DNA content.
    If ax is not None, plots pie chart of fraction live/dead
    1. alive = selected+others, where selected is within
                 inner DNA gate and within LDR
    2. dead = anything outside of DNA outer gating and LDR gating
    3. total = alive + dead; selected + others + dead

    Parameters
    ----------
    ldrint : 1d array
       ldr int feature across all cells in a well
    ldr_gates : list of floats
    dna : 1d array
       DNA content of cells in a given well
    dna_gates : list of floats
    ldr_cutoff : float
       default cutoff if
    x_dna : 1d array
       Expected distribution of DNA content (used as x-axis grid)
    ax : subplot object

    Returns
    -------
    alive : int
       number of cells classied as alive
    dead : int
       numer of cells classified as dead
    outcome : 1d array
       classification of each cell as live(>=0) or dead (-1).
       should have same length as ldrtxt
    """ #dummy value #dead = np.sum([1 for ot in outcome if ot == -1]) #outcome = [-1 if d else 1 if s else 0 #           for d, s in zip((ldr_outer | dna_outermost), dna_inner)] # normal live cells # live but higher than G2 # dead very low G1 # alive lower than G1 #alive = np.sum([1 for ot in outcome if ot >= 0]) #dead = np.sum([1 for s in outcome if s == -1]) #selected = np.sum([1 for s in outcome if s == 1]) #others = np.sum([1 for s in outcome if s == 0])
ldrint
ldr_gates
dna
dna_gates
x_dna
ax
ldr_control_cutoff