import os,sys import fcm from PositivityLib import * import matplotlib.pyplot as plt if not os.path.isdir("eqapol-11c-1"): raise Exception("The data directory eqapol-11c-1 is not present") ## define the file list stimulationList = "CMVpp65" fileList = os.listdir("eqapol-11c-1") filePathList = [os.path.join(os.getcwd(),"eqapol-11c-1",fn) for fn in fileList] ## load the fcs files and append them to a list fcsList = [] for filePath in filePathList: fcsData = fcm.loadFCS(filePath,auto_comp=False,transform=None) fcsData.logicle(scale_max=1e05) fcsList.append(fcsData) ## define variables channelDict = {'FSC':0,'SSC':3,'CD57':8,'CD4':7,'dump':17,'CD3':16,'CD27':15,'TNFa':14,'CD8':13,'IL2':12, 'CD45RO':11, 'CD107':10, 'IFNg':9} ## find the positivity threshold posControlFile = 'G69019FF_SEB_CD4.fcs' negControlFile = 'G69019FF_Costim_CD4.fcs' beta = 0.8 cytokine = 'IL2' positiveEvents = get_events(posControlFile,fileList,fcsList) negativeEvents = get_events(negControlFile,fileList,fcsList) fResults = get_positivity_threshold(negativeEvents,positiveEvents,channelDict[cytokine],beta=beta) print fResults['threshold'] ## get the percentages, counts, and indices of positive events percentages,counts,idx = get_cytokine_positive_events(channelDict[cytokine],fResults['threshold'], fileList,fcsList) ## plot the results fig = plt.figure(figsize=(8,6)) ax = fig.add_subplot(111) create_plot(fig,ax,'G69019FF_CMVpp65_CD4.fcs',cytokine,channelDict,fileList,fcsList,fResults,percentages,counts,idx) plt.savefig("positivity_%s.png"%cytokine)