コード例 #1
0
def dataGrapherSingle(dataStructure, figureLabel):

    resolution = 1000

    for epocLabel in dataStructure:

        epoc = epocLabel.split('_')[0]
        localTime = numpy.array(dataStructure[epocLabel][0])
        shiftedTime = localTime - min(localTime)

        localCells = dataStructure[epocLabel][1]

        highResolutionTime = numpy.linspace(min(shiftedTime), max(shiftedTime),
                                            resolution)

        if len(localCells) > 2:  # dealing with sets of at least 2 data points
            print figureLabel + '_' + epocLabel, '\t',

            fittedTrajectory = library.dataFitter(shiftedTime, localCells)
            b = library.peval(highResolutionTime, fittedTrajectory[0])

            checkFit(highResolutionTime, b, shiftedTime, localCells,
                     figureLabel + '_' + epocLabel)

    return None
コード例 #2
0
def dataGrapherEpocs(dataStructure,figureLabel):

    resolution=1000
    figureFile='../results/figure_%s.pdf'%figureLabel
    legendWritten=False

    if figureLabel == '300':
        localColor='blue'
    elif figureLabel == '1000':
        localColor='red'
    else:
        print 'error a'
        sys.exit()

    for epocLabel in dataStructure:


        epoc=epocLabel.split('_')[0]
        
        localTime=numpy.array(dataStructure[epocLabel][0])
        shiftedTime=localTime-min(localTime)
        localCells=dataStructure[epocLabel][1]
        highResolutionTime=numpy.linspace(min(shiftedTime),max(shiftedTime),resolution)

        # plotting the data
        if legendWritten == False:
            matplotlib.pyplot.plot(localTime,localCells,'o',color=localColor,markeredgecolor='None',label='%s ppm'%figureLabel)
            legendWritten=True
        else:
            matplotlib.pyplot.plot(localTime,localCells,'o',color=localColor,markeredgecolor='None')

        # plotting the model if there is growth, otherwise plot a best model straight line
        if len(localCells) == 2:
            matplotlib.pyplot.plot([localTime[0],localTime[-1]],[localCells[0],localCells[-1]],'-',color=localColor)
        elif localCells[0] > localCells[-1]:
            slope, intercept, temp0, temp1, temp2 = scipy.stats.linregress(shiftedTime,localCells)
            matplotlib.pyplot.plot([localTime[0],localTime[-1]],[intercept,slope*shiftedTime[-1]+intercept],'-',color=localColor)
        else:
            fittedTrajectory=library.dataFitter(shiftedTime,localCells)
            b=library.peval(highResolutionTime,fittedTrajectory[0])
            matplotlib.pyplot.plot(highResolutionTime+min(localTime),b,'-',color=localColor)
    
    matplotlib.pyplot.xlim([-0.5,19])
    matplotlib.pyplot.ylim([-0.5e5,10e5])
    matplotlib.pyplot.xlabel('time (days)')
    matplotlib.pyplot.ylabel('number of cells (x 1e5)')
    matplotlib.pyplot.yticks((0,1e5,2e5,3e5,4e5,5e5,6e5,7e5,8e5,9e5,10e5),('0','1','2','3','4','5','6','7','8','9','10'))

    matplotlib.pyplot.legend(numpoints=1,loc=1,frameon=False)
    
    matplotlib.pyplot.savefig(figureFile)
    matplotlib.pyplot.clf()


    return None
コード例 #3
0
ファイル: epochGrapher.py プロジェクト: adelomana/viridis
def dataGrapherEpochs(dataStructure,figureLabel):

    resolution=1000
    figureFile='results/figure_%s.pdf'%figureLabel

    for epochLabel in dataStructure:


        epoch=epochLabel.split('_')[0]
        
        localTime=numpy.array(dataStructure[epochLabel][0])
        shiftedTime=localTime-min(localTime)
        localCells=dataStructure[epochLabel][1]
        highResolutionTime=numpy.linspace(min(shiftedTime),max(shiftedTime),resolution)

        epochColor=colorDefiner(epoch)

        # plotting the data
        if len(localCells) > 1:
            matplotlib.pyplot.plot(localTime,localCells,'o',color=epochColor,markeredgecolor='None',ms=4)

        # plotting the model if there is growth, otherwise plot a best model straight line
        if len(localCells) <= 2:
            matplotlib.pyplot.plot([localTime[0],localTime[-1]],[localCells[0],localCells[-1]],'-',color=epochColor)
        elif localCells[0] > localCells[-1]:
            slope, intercept, temp0, temp1, temp2 = scipy.stats.linregress(shiftedTime,localCells)
            matplotlib.pyplot.plot([localTime[0],localTime[-1]],[intercept,slope*shiftedTime[-1]+intercept],'-',color=epochColor)
        else:
            fittedTrajectory=library.dataFitter(shiftedTime,localCells)
            b=library.peval(highResolutionTime,fittedTrajectory[0])
            matplotlib.pyplot.plot(highResolutionTime+min(localTime),b,'-',color=epochColor)
    
    matplotlib.pyplot.xlim([-0.5,20])
    matplotlib.pyplot.ylim([-0.5e5,18e5])
    matplotlib.pyplot.xlabel('time (days)')
    matplotlib.pyplot.ylabel('number of cells (x 1e5)')
    matplotlib.pyplot.title('%s ppm'%figureLabel)
    matplotlib.pyplot.yticks((0,2e5,4e5,6e5,8e5,10e5,12e5,14e5,16e5,18e5),('0','2','4','6','8','10','12','14','16','18'))

    matplotlib.pyplot.savefig(figureFile)
    matplotlib.pyplot.clf()


    return None
コード例 #4
0
ファイル: timeSeriesFitter.py プロジェクト: adelomana/viridis
def dataGrapherSingle(dataStructure,figureLabel):

    resolution=1000

    for epocLabel in dataStructure:

        epoc=epocLabel.split('_')[0]
        localTime=numpy.array(dataStructure[epocLabel][0])
        shiftedTime=localTime-min(localTime)

        localCells=dataStructure[epocLabel][1]
        
        highResolutionTime=numpy.linspace(min(shiftedTime),max(shiftedTime),resolution)

        if len(localCells) > 2: # dealing with sets of at least 2 data points
            print figureLabel+'_'+epocLabel,'\t',

            fittedTrajectory=library.dataFitter(shiftedTime,localCells)
            b=library.peval(highResolutionTime,fittedTrajectory[0])

            checkFit(highResolutionTime,b,shiftedTime,localCells,figureLabel+'_'+epocLabel)

    return None
コード例 #5
0
def dataGrapherEpocs(dataStructure, figureLabel):

    resolution = 1000
    figureFile = '../results/figure_%s.pdf' % figureLabel
    legendWritten = False

    if figureLabel == '300':
        localColor = 'blue'
    elif figureLabel == '1000':
        localColor = 'red'
    else:
        print 'error a'
        sys.exit()

    for epocLabel in dataStructure:

        epoc = epocLabel.split('_')[0]

        localTime = numpy.array(dataStructure[epocLabel][0])
        shiftedTime = localTime - min(localTime)
        localCells = dataStructure[epocLabel][1]
        highResolutionTime = numpy.linspace(min(shiftedTime), max(shiftedTime),
                                            resolution)

        # plotting the data
        if legendWritten == False:
            matplotlib.pyplot.plot(localTime,
                                   localCells,
                                   'o',
                                   color=localColor,
                                   markeredgecolor='None',
                                   label='%s ppm' % figureLabel)
            legendWritten = True
        else:
            matplotlib.pyplot.plot(localTime,
                                   localCells,
                                   'o',
                                   color=localColor,
                                   markeredgecolor='None')

        # plotting the model if there is growth, otherwise plot a best model straight line
        if len(localCells) == 2:
            matplotlib.pyplot.plot([localTime[0], localTime[-1]],
                                   [localCells[0], localCells[-1]],
                                   '-',
                                   color=localColor)
        elif localCells[0] > localCells[-1]:
            slope, intercept, temp0, temp1, temp2 = scipy.stats.linregress(
                shiftedTime, localCells)
            matplotlib.pyplot.plot(
                [localTime[0], localTime[-1]],
                [intercept, slope * shiftedTime[-1] + intercept],
                '-',
                color=localColor)
        else:
            fittedTrajectory = library.dataFitter(shiftedTime, localCells)
            b = library.peval(highResolutionTime, fittedTrajectory[0])
            matplotlib.pyplot.plot(highResolutionTime + min(localTime),
                                   b,
                                   '-',
                                   color=localColor)

    matplotlib.pyplot.xlim([-0.5, 19])
    matplotlib.pyplot.ylim([-0.5e5, 10e5])
    matplotlib.pyplot.xlabel('time (days)')
    matplotlib.pyplot.ylabel('number of cells (x 1e5)')
    matplotlib.pyplot.yticks(
        (0, 1e5, 2e5, 3e5, 4e5, 5e5, 6e5, 7e5, 8e5, 9e5, 10e5),
        ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'))

    matplotlib.pyplot.legend(numpoints=1, loc=1, frameon=False)

    matplotlib.pyplot.savefig(figureFile)
    matplotlib.pyplot.clf()

    return None
コード例 #6
0
def dataGrapherEpochs(dataStructure, figureLabel):

    resolution = 1000
    figureFile = 'results/figure_%s.pdf' % figureLabel

    for epochLabel in dataStructure:

        epoch = epochLabel.split('_')[0]

        localTime = numpy.array(dataStructure[epochLabel][0])
        shiftedTime = localTime - min(localTime)
        localCells = dataStructure[epochLabel][1]
        highResolutionTime = numpy.linspace(min(shiftedTime), max(shiftedTime),
                                            resolution)

        epochColor = colorDefiner(epoch)

        # plotting the data
        if len(localCells) > 1:
            matplotlib.pyplot.plot(localTime,
                                   localCells,
                                   'o',
                                   color=epochColor,
                                   markeredgecolor='None',
                                   ms=4)

        # plotting the model if there is growth, otherwise plot a best model straight line
        if len(localCells) <= 2:
            matplotlib.pyplot.plot([localTime[0], localTime[-1]],
                                   [localCells[0], localCells[-1]],
                                   '-',
                                   color=epochColor)
        elif localCells[0] > localCells[-1]:
            slope, intercept, temp0, temp1, temp2 = scipy.stats.linregress(
                shiftedTime, localCells)
            matplotlib.pyplot.plot(
                [localTime[0], localTime[-1]],
                [intercept, slope * shiftedTime[-1] + intercept],
                '-',
                color=epochColor)
        else:
            fittedTrajectory = library.dataFitter(shiftedTime, localCells)
            b = library.peval(highResolutionTime, fittedTrajectory[0])
            matplotlib.pyplot.plot(highResolutionTime + min(localTime),
                                   b,
                                   '-',
                                   color=epochColor)

    matplotlib.pyplot.xlim([-0.5, 20])
    matplotlib.pyplot.ylim([-0.5e5, 18e5])
    matplotlib.pyplot.xlabel('time (days)')
    matplotlib.pyplot.ylabel('number of cells (x 1e5)')
    matplotlib.pyplot.title('%s ppm' % figureLabel)
    matplotlib.pyplot.yticks(
        (0, 2e5, 4e5, 6e5, 8e5, 10e5, 12e5, 14e5, 16e5, 18e5),
        ('0', '2', '4', '6', '8', '10', '12', '14', '16', '18'))

    matplotlib.pyplot.savefig(figureFile)
    matplotlib.pyplot.clf()

    return None