def calc_figureRightProtein(self): self.PLPlotProtein.clear() self.proteinView = self.dataFrame[self.dataFrame[PROTEINHEADER] == self.currentRow[PROTEINHEADER]] self.passProteinView = self.proteinView[self.proteinView['allClear'] == True] self.failProteinView = self.proteinView[self.proteinView['allClear'] == False] theRows = self.proteinView[self.proteinView['TID'] == self.currentRow['TID']] self.selectedPairedPointsProtein, = self.PLPlotProtein.plot(theRows['currentPosProtein'], theRows['currentCalc'], 'o', ms=30*self.size, alpha=0.25, color='red') self.selectedPointProtein, = self.PLPlotProtein.plot(self.currentRow['currentPosProtein'], self.currentRow['currentCalc'], 'o', ms=20, alpha=0.5, color='yellow', visible=True) self.PLPlotProtein.plot(self.passProteinView['currentPosProtein'], self.passProteinView['currentCalc'], 'ro', picker=5, label="Saved : " + str(len(self.passProteinView['currentCalc'].values))) meds = self.determineMedians(self.passProteinView, 'currentPosProtein') self.PLPlotProtein.plot(meds[0], meds[1], 'g-', lw=2, label="Median : " + str(round(numpy.median(meds[1]),1))) if not self.hideCheck.IsChecked(): self.PLPlotProtein.plot(self.failProteinView['currentPosProtein'], self.failProteinView['currentCalc'], 'x', mec='grey', picker=5, label="Filtered : " + str(len(self.failProteinView['currentCalc'].values))) self.PLPlotProtein.grid(self.cb_grid.IsChecked()) self.PLPlotProtein.set_xticks(range(1,int(self.dataFrame['currentPosProtein'].max())+1)) self.PLPlotProtein.set_xticklabels(self.positionLabelsProtein, rotation=30, size='small') self.PLPlotProtein.set_title(self.currentRow[PROTEINHEADER] + " : " + setCurrentFrac(self.calcNum, self.calcDen)) self.PLPlotProtein.set_xlim([0,self.dataFrame['currentPosProtein'].max()+1]) if not self.zoomCheck.IsChecked(): self.PLPlotProtein.set_ylim([0,max(self.passProteinView['currentCalc'].max(),1)]) else: self.PLPlotProtein.set_ylim([0,3]) self.PLPlotProtein.legend() vizLib.cleanAxis(self.PLPlotProtein, ticksOnly=True)
def calc_figureLeft(self): self.PLPlotDataset.clear() self.datasetView = self.dataFrame[self.dataFrame[FILENAMEHEADER] == self.currentRow[FILENAMEHEADER]] self.passDatasetView = self.datasetView[self.datasetView['allClear'] == True] self.failDatasetView = self.datasetView[self.datasetView['allClear'] == False] self.selectedPointDataset, = self.PLPlotDataset.plot(self.currentRow['currentPosDataset'], self.currentRow['currentCalc'], 'o', ms=20, alpha=0.5, color='yellow', visible=True) self.PLPlotDataset.grid(self.cb_grid.IsChecked()) self.PLPlotDataset.plot(self.passDatasetView['currentPosDataset'], self.passDatasetView['currentCalc'], 'ro', picker=5, label="Saved : " + str(len(self.passDatasetView['currentCalc'].values))) meds = self.determineMedians(self.passDatasetView, 'currentPosDataset') self.PLPlotDataset.plot(meds[0], meds[1], 'g-', lw=2, label="Median : " + str(round(numpy.median(meds[1]),1))) if not self.hideCheck.IsChecked(): self.PLPlotDataset.plot(self.failDatasetView['currentPosDataset'], self.failDatasetView['currentCalc'], 'x', mec='grey', picker=5, label="Filtered : " + str(len(self.failDatasetView['currentCalc'].values))) self.PLPlotDataset.set_xticks(range(1,int(self.dataFrame['currentPosDataset'].max())+1)) self.PLPlotDataset.set_xticklabels(self.positionLabelsDataset, rotation=90, size='small') self.PLPlotDataset.set_title(self.currentRow[FILENAMEHEADER] + " : " + setCurrentFrac(self.calcNum, self.calcDen)) if self.proteinZoomOn.IsChecked(): (x_low, x_high) = map(float, self.proteinZoomRangeBypass.GetValue().split(' ')) self.PLPlotDataset.set_xlim([x_low,x_high]) else: self.PLPlotDataset.set_xlim([0.5,self.datasetView['currentPosDataset'].max()+1.5]) if not self.zoomCheck.IsChecked(): self.PLPlotDataset.set_ylim([0,max(self.passDatasetView['currentCalc'].max(),1)]) else: self.PLPlotDataset.set_ylim([0,3]) self.PLPlotDataset.legend() vizLib.cleanAxis(self.PLPlotDataset, ticksOnly=True)
def calc_figureRightFit(self): plotsfile = self.datapath+self.currentRow[ISOFILEHEADER]+'.plots' txtfile = self.datapath+self.currentRow[ISOFILEHEADER]+'.txt' df = pandas.read_csv(plotsfile) df2 = pandas.read_csv(txtfile, header=None, sep=' ') del df['residAdj'] self.PNGPlot.clear() self.PNGPlot.plot(df2[0][0:len(df['dat'])].values, df['dat'].values, 'o', markersize=6, markerfacecolor='None', markeredgecolor='red') self.PNGPlot.plot(df2[0][0:len(df['dat'])].values, df['dat'].values, 'r-', linewidth=2, label='data') self.PNGPlot.plot(df2[0][0:len(df['fit'])].values, df['fit'].values, 'b-', linewidth=2, label='fit') self.PNGPlot.plot(df2[0][0:len(df['resid'])].values, df['resid'].values, 'g-', linewidth=2, label='residual') self.PNGPlot.set_xlim(df2[0][0:len(df['dat'])].values.min(), df2[0][0:len(df['dat'])].values.max()) self.PNGPlot.legend() stringColor = 'black' row = self.currentRow if row['handDelete']: stringColor = 'red' elif row['handSave']: stringColor = 'green' seqText = str(self.currentRow['seqmod']) + " : z=" + str(self.currentRow['charge']) dataString1 = "ppmDiff: " + str(round(row['ppmDiff'],1)) + " : " + str(row['ppmDiff_pass']) +\ "\nN14: " + str(round(row['ppm_n14'],1)) + " : " + str(row['ppm_n14_pass']) +\ "\nN15: " + str(round(row['ppm_n15'],1)) + " : " + str(row['ppm_n15_pass']) +\ "\nresid: " + str(round(row['resid'],1)) + " : " + str(row['resid_pass']) dataString2 = "ratio: " + str(round(row['currentCalc'],1)) + " : " + str(row['ratio_pass']) +\ "\nintensity: " + str(round(row['minIntensity'],1)) + " : " + str(row['minInt_pass']) +\ "\n"+self.lastHistField+" "+ str(round(row[self.lastHistField],1)) + " : " + str(row[self.lastHistField+'_pass']) +\ "\ncurrentCalc: " + str(round(row['currentCalc'],1)) self.PNGPlot.text(0.02, 0.98,seqText, horizontalalignment='left', verticalalignment='top', transform = self.PNGPlot.transAxes, color = stringColor, size='large') self.PNGPlot.text(0.98, 0.02,dataString1, horizontalalignment='right', verticalalignment='bottom', transform = self.PNGPlot.transAxes, color = stringColor) self.PNGPlot.text(0.02, 0.02,dataString2, horizontalalignment='left', verticalalignment='bottom', transform = self.PNGPlot.transAxes, color = stringColor) self.PNGPlot.set_title(self.currentRow[UIDHEADER]) self.PNGPlot.yaxis.set_major_formatter(matplotlib.ticker.FormatStrFormatter('%.0e')) vizLib.cleanAxis(self.PNGPlot, ticksOnly=True)
def calc_hists(self): hists = {'ppmDiff':self.hist1, 'ppm_n14':self.hist2, 'ppm_n15':self.hist3, 'resid':self.hist4, 'minIntensity':self.hist5, self.lastHistField:self.hist6} relSet = self.dataFrame[(self.dataFrame[FILENAMEHEADER] == self.currentRow[FILENAMEHEADER]) & (self.dataFrame['allClear'] == True)] for curHist in hists.keys(): hists[curHist].clear() data = relSet[curHist].values bin_num = min(20, len(list(set(data)))) if curHist == 'minIntensity' or curHist == 'resid': bin_num = numpy.logspace(numpy.log10(data.min()), numpy.log10(data.max()), num=20) hists[curHist].hist(data, bins = bin_num) hists[curHist].text(0.05,0.75,curHist, transform=hists[curHist].transAxes) numTicks = 2 spacing = (data.max()-data.min())/(numTicks+2) if curHist == 'minIntensity' or curHist == 'resid': hists[curHist].set_xscale('log') else: hists[curHist].set_xticks([data.min()+spacing*i for i in range(numTicks+3)]) hists[curHist].set_xticklabels([str(round(data.min()+spacing*i,1)) for i in range(numTicks+3)], size='small') hists[curHist].set_xlim(data.min(), data.max()) hists[curHist].set_yticks([]) vizLib.cleanAxis(hists[curHist])
def prettyPlot3TransMRM(dataFrame, toPlotIndex, figsize=(33, 8.5)): axisArray = [] pylab.figure(figsize=figsize) for i in range(len(toPlotIndex)): a = plt.subplot2grid((2, 9), (0, i * 3), colspan=1, rowspan=2) a = plotTotalChromPairsMRM(dataFrame, toPlotIndex[i], a, smooth=5, zoom=True) info = getInfoMRM(dataFrame, toPlotIndex[i]) a.set_title(info[1]) vizLib.tickNum(a, xAxis=4, yAxis=4) vizLib.cleanAxis(a, ticksOnly=True) axisArray.append(a) b = plt.subplot2grid((2, 9), (0, i * 3 + 1), colspan=2, rowspan=1) b = plotAllTransitionsMRM(dataFrame, toPlotIndex[i], b, smooth=5, zoom=True) info = getInfoMRM(dataFrame, toPlotIndex[i]) b.set_title("light") vizLib.tickNum(b, xAxis=4, yAxis=4) vizLib.cleanAxis(b, ticksOnly=True) axisArray.append(b) c = plt.subplot2grid((2, 9), (1, i * 3 + 1), colspan=2, rowspan=1) opp = getPairedIonMRM(dataFrame, toPlotIndex[i]) c = plotAllTransitionsMRM(dataFrame, opp, c, smooth=5, zoom=True) info = getInfoMRM(dataFrame, toPlotIndex[i]) c.set_title("heavy") vizLib.tickNum(c, xAxis=4, yAxis=4) vizLib.cleanAxis(c, ticksOnly=True) axisArray.append(c) pylab.tight_layout() return axisArray