def dose_response_caller(gct_file,verbose=True): ''' Counts the number of dose-responsive genes based on template matching also examines the S-C correlation to determine if a perturbation is dose responsive ''' dp = doseClass.DosePlate() dp.add_from_gct(gct_file) dp.examine_doses_tested(verbose=verbose) dp.match_template(verbose=verbose) # dp.permutation_template() ssAll = dp.gct.get_column_meta('distil_ss') ccAll = dp.gct.get_column_meta('distil_cc_q75') #matric what is the dose corr nMatchDict = {} for pert in dp.perts_at_dose: IndsPert = dp.doseIndDict[pert] ssVals = [float(ssAll[i]) for i in IndsPert] ccVals = [float(ccAll[i]) for i in IndsPert] corr, p = stats.pearsonr(ccVals,ssVals) if p < .2: print pert + ' S-C corr ' + str(corr) #find number of probes that match a template pass FDR templates = dp.templateMatchInd[pert].keys() probeTempMatches = [] for temp in templates: probeTempMatches.extend(dp.templateMatchInd[pert][temp]) probeMatch = set(probeTempMatches) print pert + ' number of template matches ' + str(len(probeMatch)) ### DR caller if len(probeMatch) > 10 or p < .1: print pert + ' is dose responsive' nMatchDict[pert] = len(probeMatch) return nMatchDict
ominWithContext.append(geneID) ### in which cell lines do we have more than 500 CGS sigs cellFull = [q['cell_id'] for q in CGSall] cgsCellsLong = list(set(cellFull)) cgsCells = [] for cell in cgsCellsLong: if cellFull.count(cell) > 500: cgsCells.append(cell) ### get HOG brds file1 = '/xchip/obelix/pod/brew/pc/HOG001_A549_24H/by_pert_id_pert_dose/HOG001_A549_24H_COMPZ.MODZ_SCORE_LM_n288x978.gctx' file2 = '/xchip/obelix/pod/brew/pc/HOG002_A549_24H/by_pert_id_pert_dose/HOG002_A549_24H_COMPZ.MODZ_SCORE_LM_n288x978.gctx' hogPerts = [] #plate 1 dp = doseClass.DosePlate() dp.add_from_gct(file1) dp.examine_doses_tested() hogPerts.extend(dp.perts_at_dose) #plaste 2 dp = doseClass.DosePlate() dp.add_from_gct(file2) dp.examine_doses_tested() hogPerts.extend(dp.perts_at_dose) hogPertsShort = [x[:13] for x in hogPerts] ### pull sigs of hog perts from mongo # for pert in hogPertsShort: # for cell in cgsCells: # CM = mutil.CMapMongo() # cpSigs = CM.find({'pert_id':pert,'pert_type':'trt_cp'},{'sig_id':True,'cell_id':True,'pert_iname':True,'pert_id':True})
# refControl = 'pc' #use pc vs vc controled data # gctfile = glob.glob('%s/%s/%s_%s_%s/by_pert_id_pert_dose/%s_%s_%s_COMPZ.MODZ_SCORE_LM_*.gctx' % (data_dir,refControl,platePrefix,cell,timeP,platePrefix,cell,timeP)) # gctfile = gctfile[0] # work_dir = '/xchip/cogs/projects/HOG/scratch/%s_%s_%s' % (cell,timeP,refControl) # if not os.path.exists(work_dir): # os.mkdir(work_dir) # db = gct.GCT() #make a gct object # db.read(gctfile) ###merged gct gctfile = '/xchip/cogs/projects/HOG/data/brew_by_pert_id_pert_dose/pc/HOG_merged_MCF7_24H/merged_COMPZ.MODZ_SCORE_LM_n862x978.gctx' db = gct.GCT() #make a gct object db.read(gctfile) do = doseClass.DosePlate() do.add_from_gct() pertIDs = db.get_column_meta('pert_id') pertDescs = db.get_column_meta('pert_desc') ### parp group # XAV939 BRD-K12762134-001-02-1 # veliparib BRD-K87142802-001-02-7 # olaparib BRD-K02113016 # 3-amino-benzamide BRD-K08703257-001-06-3 # IWR-1-endo BRD-K61314889-001-01-0 # NU-1025 BRD-K48692744-001-01-2 # DR2313 BRD-K94920105-001-01-3 # phenanthridinone BRD-K11163873-001-02-8 # PJ34 BRD-K11853856-003-01-3