def concat(fdarray): """Merge FlowData together """ pd_data = [fd.panda for fd in fdarray] new_panda = pd.concat(pd_data) md = fdarray[0]._metadata # Clean up the metadata md['$FIL'] = 'merged data' newfd = FlowData(panda=new_panda, metadata=md) return newfd
import numpy as np from flowdata import FlowData import matplotlib.pyplot as plt fd = FlowData('test.fcs') print fd.markers (xgrid,den) = fd.histogram(5) print xgrid print den fig, ax = plt.subplots() ax.semilogy(xgrid,den) plt.show()
#!/usr/bin/env python # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from timeit import Timer from flowdata import FlowData import pandas as pd import numpy as np fd = FlowData('test.fcs') print fd.tags print fd.markers print len(fd.CD45) print fd.get('TIM-3') data = fd._data x = fd.get('TIM-3') y = fd.get('CD45') i = y > 10 print len(i) print data[:,y>10] numpy_select = Timer("""x = fd.get('TIM-3'); y = fd.get('CD45'); x[y>10]""",setup="""from flowdata import FlowData; fd = FlowData('test.fcs'); """) it = 1000 print "Time per select (Numpy) {} ms".format(numpy_select.timeit(it)/it*1000) df = pd.DataFrame({'TIM-3':x, 'CD45':y}) #print df
#! /opt/local/bin/python from flowdata import FlowData fd = FlowData('test.fcs') fd.tsne('visne', sample = 100) fd.write('test_write.fcs') #fcs.write('test_write.fcs',data, metadata)