Beispiel #1
0
    return splitFN[1]


fscid = fileNameParser(filename)

# Processing
fcsfilename = filename + '.fcs'
datafile = os.path.join(dataRootDir, dataFolderDir, fcsFolderDir, fcsfilename)
dataSample = FCMeasurement(ID=fscid, datafile=datafile)

# Gating
fsc_gate = ThresholdGate(1000.0, ['FSC-H'], region='above')
ssc_gate = ThresholdGate(1000.0, ['SSC-H'], region='above')
rfpA_gate = ThresholdGate(1.0, ['RFP2-A'], region='above')
fscssc_gate = CompositeGate(fsc_gate, 'and', ssc_gate)
dataSample = dataSample.gate(fscssc_gate)
dataSample = dataSample.gate(rfpA_gate)

#fig1 = plt.figure('figure 1')
#rfpdata = dataSample.data['RFP2-H']
#rfplist = rfpdata.values
#rfpLogMin, rfpLogMax = np.log10(rfplist.min()),np.log10(rfplist.max())
#rfpnewBins = np.logspace(rfpLogMin, rfpLogMax,100)
#sns.distplot(rfplist, bins=rfpnewBins, kde=False, color='r')
#plt.xscale('log')
#plt.xlim(1, 1e6)

data = dataSample.data[['FSC-H', 'RFP2-H']]
df = pd.DataFrame(data, columns=["x", "y"])
#sns.kdeplot(df.x, df.y)
#sns.jointplot(x="RFP2-H", y="FSC-H", data=data, kind="kde");
flow_data = FCMeasurement(ID='Flow data', datafile=input_file)

# Print channel information
print flow_data.channels

# Print the number of events in the data
print 'Events in file: ', flow_data.shape[0]

# Primary gates
non_debris_polygate = PolyGate([(45000, 50000), (150000, 55000),
                                (200000, 75000), (230000, 150000),
                                (180000, 225000), (60000, 200000),
                                (30000, 100000)], ['FSC-A', 'SSC-A'],
                               region='in',
                               name='live')
non_debris_gated_flow_data = flow_data.gate(non_debris_polygate)
singles_polygate = PolyGate([(45000, 25000), (190000, 99000), (170000, 135000),
                             (55000, 43000)], ['FSC-A', 'FSC-H'],
                            region='in',
                            name='singles')
singles_flow_data = non_debris_gated_flow_data.gate(singles_polygate)

# Transform data
tsingles_flow_data = singles_flow_data.transform(
    'hlog',
    channels=[
        'Alexa Fluor 405-A', 'Alexa Fluor 405-H', 'Alexa Fluor 405-W',
        'Alexa Fluor 488-A', 'Alexa Fluor 488-H', 'Alexa Fluor 488-W'
    ],
    b=500.0)
Beispiel #3
0
tsample = FCMeasurement(ID='Test Sample', datafile=datafile)
tsample = tsample.transform('hlog', channels=['Y2-A', 'B1-A', 'V2-A'], b=500.0)

# Create poly gate
from FlowCytometryTools import PolyGate

# HINT: If you have wx-python installed, then you can use the GUI to create the gate.
# You can launch the GUI by executing the command tsample.view_interactively()

gate1 = PolyGate([(-5.441e+02, 7.978e+03), (-8.605e+02, 6.739e+03),
                  (-5.811e+02, 4.633e+03), (1.502e+03, 5.118e+03),
                  (8.037e+02, 8.215e+03), (8.037e+02, 8.215e+03)],
                 ('B1-A', 'Y2-A'),
                 region='in',
                 name='poly gate')

# Gate

gated_sample = tsample.gate(gate1)
inverted_sample = tsample.gate(~gate1)  # Everything outside of gate1

# Plot
gated_sample.plot(('Y2-A', 'B1-A'),
                  gates=[gate1],
                  kind='scatter',
                  color='red',
                  alpha=0.9)
inverted_sample.plot(('Y2-A', 'B1-A'), kind='scatter', color='gray', alpha=0.9)

#show() # <-- Uncomment when running as a script.
# In[6]:


## draw gate around healthiest cells
gate1= PolyGate([(50000,0),(80000,0), (80000,45000), (50000,45000)],
               ('FSC-A', 'SSC-A'), region='in')
halo1.plot(['FSC-A', 'SSC-A'], gates=gate1)
plt.show()


# In[7]:


##see population that falls inside the gate
halo1_gated=halo1.gate(gate1)
halo1_gated.plot(['FSC-A','SSC-A'], gates=gate1)
plt.show()


# In[8]:


sgn1.plot(['FSC-A', 'SSC-A'])
plt.show()


# In[9]:


## gate Sgn1 healthiest cells 
Beispiel #5
0
# Locate sample data included with this package
datadir = os.path.join(FlowCytometryTools.__path__[0], 'tests', 'data', 'Plate01')
datafile = os.path.join(datadir, 'RFP_Well_A3.fcs')

# datafile = '[insert path to your own fcs file]' 

# Load data
tsample = FCMeasurement(ID='Test Sample', datafile=datafile)
tsample = tsample.transform('hlog', channels=['Y2-A', 'B1-A', 'V2-A'], b=500.0)

# Create a threshold gates
y2_gate = ThresholdGate(1000.0, 'Y2-A', region='above')

# Gate
gated_sample = tsample.gate(y2_gate)

# Plot
ax1 = subplot(121);
tsample.plot('Y2-A', gates=[y2_gate], bins=100, alpha=0.9);
y2_gate.plot(color='k', linewidth=4, linestyle='-')
title('Original Sample');

ax2 = subplot(122, sharey=ax1, sharex=ax1);
gated_sample.plot('Y2-A', gates=[y2_gate], bins=100, color='y', alpha=0.9);
title('Gated Sample');

tight_layout()

#show() # <-- Uncomment when running as a script.
Beispiel #6
0
    new_data = new_data.dropna()  # Removes all NaN entries
    new_sample.data = new_data
    return new_sample


# //////////////////////////////////////////////
# threshold gating to remove all negative FSC and SSC events
preP1th_value1 = 10.0**1.6699667767116002
preP1th_channel1 = 'FSC-A'
preP1th_value2 = 10.0**2.8012542209507507
preP1th_channel2 = 'SSC-A'
preP1gate1 = ThresholdGate(preP1th_value1, preP1th_channel1, region='above')
preP1gate2 = ThresholdGate(preP1th_value2, preP1th_channel2, region='above')
preP1gate = preP1gate1 & preP1gate2

preP1_sample = sample.gate(preP1gate)
print 'profile after preP1 gating'
print preP1_sample.data.describe()
print ''

preP1log = custom_log(preP1_sample, ['FSC-A', 'SSC-A'])
print 'profile after preP1 gating and log10 for FSC and SSC'
print preP1log.data.describe()
print ''

# //////////////////////////////////////////////
# P1 gating based on FSC and SSC (Log10 space)
P1_gatevalue = [(4.481395264353071, 4.727180089479611),
                (1.761395345415388, 3.4679208677492026),
                (1.6699667767116002, 2.8259455782395824),
                (3.7042524303708757, 2.8012542209507507),