python/cell_cycle_gating/dead_cell_filter.py
def plot_ldr_dna_scatter(dna, ldrtxt, x_dna=None, x_ldr=None, ax=None):
    """Plot of LDR and DNA scatter with associated gates
    
    Parameters
    ----------
    dna : 1d array
        DNA content of cells in a given well
    ldrtxt : 1d array
        ldr txt feature across all cells in a well
    x_dna : 1d array
        Expected distribution of DNA content (used as x-axis grid)
    x_ldr : 1d array
        uniformly distributed 1d grid based on expected
        range of ldr txt
    ax : subplot object
        provides positional reference for master plot
    
    Returns
    -------
    """
    if x_dna is None:
        x_dna = np.arange(2.5, 8, 0.02)
    if x_ldr is None:
        mx = np.max(ldrtxt.tolist())+0.01
        x_ldr = np.arange(-0.01, mx, 0.0002)
    log_dna = compute_log_dna(dna, x_dna)
    xy = np.vstack([log_dna, ldrtxt])
    z = gaussian_kde(xy)(xy)

    ldr_gates = get_ldrgates(ldrtxt, x_ldr)

    g1_g2_pos = get_g1_g2_position(log_dna, x_dna, ldrtxt, ldr_gates)
    g1_loc = g1_g2_pos[0]
    g2_loc = g1_g2_pos[1]
    dna_gates = [a + b for a, b in zip(
        [g1_g2_pos[i] for i in [0, 0, 1, 1]],
        [(g2_loc-g1_loc) * s for s in [-1.5, -.9, 1.3, 2.2]])]
    ldr_gates = [0 if lg < 0 else lg for lg in ldr_gates]

    # Plotting
    # --------
    if ax is None:
        ax = plt.figure()
    ax.scatter(log_dna, ldrtxt, c=z, s=10)
    ax.plot([dna_gates[i] for i in [0, 0, 3, 3, 0]],
            [ldr_gates[i] for i in [0, 1, 1, 0, 0]], '-r')
    ax.plot([dna_gates[i] for i in [1, 1, 2, 2, 1]],
            [ldr_gates[i] for i in [0, 1, 1, 0, 0]],
            '-r', linewidth=2)

    ax.plot(g1_g2_pos, [0, 0], 'xk', )
    ax.plot(g1_g2_pos, [0, 0], 'ok', markersize=14, markerfacecolor='None')
    ax.set_xlabel('log10 (DNA content)')
    ax.set_ylabel('LDRtxt intensity')
    dna_lims = get_dnalims(log_dna, x_dna)
    dna_lims = [np.min((dna_lims[0], dna_gates[0]-0.1)),
                np.max((dna_lims[1], dna_gates[3]+0.1))]
    ldr_lims = get_ldrlims(ldrtxt, x_ldr)
    ax.set_xlim(dna_lims)
    ax.set_ylim(ldr_lims)
Plot of LDR and DNA scatter with associated gates
    
    Parameters
    ----------
    dna : 1d array
        DNA content of cells in a given well
    ldrtxt : 1d array
        ldr txt feature across all cells in a well
    x_dna : 1d array
        Expected distribution of DNA content (used as x-axis grid)
    x_ldr : 1d array
        uniformly distributed 1d grid based on expected
        range of ldr txt
    ax : subplot object
        provides positional reference for master plot
    
    Returns
    -------
    
Plot of LDR and DNA scatter with associated gates
Parameters



Returns
Plot of LDR and DNA scatter with associated gates Parameters Returns
def plot_ldr_dna_scatter(dna, ldrtxt, x_dna=None, x_ldr=None, ax=None):
    if x_dna is None:
        x_dna = np.arange(2.5, 8, 0.02)
    if x_ldr is None:
        mx = np.max(ldrtxt.tolist())+0.01
        x_ldr = np.arange(-0.01, mx, 0.0002)
    log_dna = compute_log_dna(dna, x_dna)
    xy = np.vstack([log_dna, ldrtxt])
    z = gaussian_kde(xy)(xy)
    ldr_gates = get_ldrgates(ldrtxt, x_ldr)
    g1_g2_pos = get_g1_g2_position(log_dna, x_dna, ldrtxt, ldr_gates)
    g1_loc = g1_g2_pos[0]
    g2_loc = g1_g2_pos[1]
    dna_gates = [a + b for a, b in zip(
        [g1_g2_pos[i] for i in [0, 0, 1, 1]],
        [(g2_loc-g1_loc) * s for s in [-1.5, -.9, 1.3, 2.2]])]
    ldr_gates = [0 if lg < 0 else lg for lg in ldr_gates]
    if ax is None:
        ax = plt.figure()
    ax.scatter(log_dna, ldrtxt, c=z, s=10)
    ax.plot([dna_gates[i] for i in [0, 0, 3, 3, 0]],
            [ldr_gates[i] for i in [0, 1, 1, 0, 0]], '-r')
    ax.plot([dna_gates[i] for i in [1, 1, 2, 2, 1]],
            [ldr_gates[i] for i in [0, 1, 1, 0, 0]],
            '-r', linewidth=2)
    ax.plot(g1_g2_pos, [0, 0], 'xk', )
    ax.plot(g1_g2_pos, [0, 0], 'ok', markersize=14, markerfacecolor='None')
    ax.set_xlabel('log10 (DNA content)')
    ax.set_ylabel('LDRtxt intensity')
    dna_lims = get_dnalims(log_dna, x_dna)
    dna_lims = [np.min((dna_lims[0], dna_gates[0]-0.1)),
                np.max((dna_lims[1], dna_gates[3]+0.1))]
    ldr_lims = get_ldrlims(ldrtxt, x_ldr)
    ax.set_xlim(dna_lims)
    ax.set_ylim(ldr_lims)
def plot_ldr_dna_scatter ( dna , ldrtxt , x_dna = None , x_ldr = None , ax = None ) : if x_dna is None : x_dna = np . arange ( 2.5 , 8 , 0.02 ) if x_ldr is None : mx = np . max ( ldrtxt . tolist ( ) ) + 0.01 x_ldr = np . arange ( - 0.01 , mx , 0.0002 ) log_dna = compute_log_dna ( dna , x_dna ) xy = np . vstack ( [ log_dna , ldrtxt ] ) z = gaussian_kde ( xy ) ( xy ) ldr_gates = get_ldrgates ( ldrtxt , x_ldr ) g1_g2_pos = get_g1_g2_position ( log_dna , x_dna , ldrtxt , ldr_gates ) g1_loc = g1_g2_pos [ 0 ] g2_loc = g1_g2_pos [ 1 ] dna_gates = [ a + b for a , b in zip ( [ g1_g2_pos [ i ] for i in [ 0 , 0 , 1 , 1 ] ] , [ ( g2_loc - g1_loc ) * s for s in [ - 1.5 , - .9 , 1.3 , 2.2 ] ] ) ] ldr_gates = [ 0 if lg < 0 else lg for lg in ldr_gates ] if ax is None : ax = plt . figure ( ) ax . scatter ( log_dna , ldrtxt , c = z , s = 10 ) ax . plot ( [ dna_gates [ i ] for i in [ 0 , 0 , 3 , 3 , 0 ] ] , [ ldr_gates [ i ] for i in [ 0 , 1 , 1 , 0 , 0 ] ] , '-r' ) ax . plot ( [ dna_gates [ i ] for i in [ 1 , 1 , 2 , 2 , 1 ] ] , [ ldr_gates [ i ] for i in [ 0 , 1 , 1 , 0 , 0 ] ] , '-r' , linewidth = 2 ) ax . plot ( g1_g2_pos , [ 0 , 0 ] , 'xk' , ) ax . plot ( g1_g2_pos , [ 0 , 0 ] , 'ok' , markersize = 14 , markerfacecolor = 'None' ) ax . set_xlabel ( 'log10 (DNA content)' ) ax . set_ylabel ( 'LDRtxt intensity' ) dna_lims = get_dnalims ( log_dna , x_dna ) dna_lims = [ np . min ( ( dna_lims [ 0 ] , dna_gates [ 0 ] - 0.1 ) ) , np . max ( ( dna_lims [ 1 ] , dna_gates [ 3 ] + 0.1 ) ) ] ldr_lims = get_ldrlims ( ldrtxt , x_ldr ) ax . set_xlim ( dna_lims ) ax . set_ylim ( ldr_lims )
Plot of LDR and DNA scatter with associated gates
Parameters
Plot of LDR and DNA scatter with associated gates Parameters
"""Plot of LDR and DNA scatter with associated gates
    
    Parameters
    ----------
    dna : 1d array
        DNA content of cells in a given well
    ldrtxt : 1d array
        ldr txt feature across all cells in a well
    x_dna : 1d array
        Expected distribution of DNA content (used as x-axis grid)
    x_ldr : 1d array
        uniformly distributed 1d grid based on expected
        range of ldr txt
    ax : subplot object
        provides positional reference for master plot
    
    Returns
    -------
    """ # Plotting # --------
dna
ldrtxt
x_dna
x_ldr
ax