Exemplo n.º 1
0
def driveSelector(DRIVE, TYPE):
    # Split Drive #############################################################
    if DRIVE == 'SD':
        if TYPE == 'ECO':
            aggD = monet.generateAggregationDictionary(
                ["WA", "H", "R", "B", "C", "WB"], gsd.SD_ECO)
            yRange = 12500 * 2
            colors = COLEN
        elif TYPE == 'HLT':
            aggD = monet.generateAggregationDictionary(["H*", "O-", "Total"],
                                                       gsd.SD_HLT)
            yRange = 12500
            colors = COLHN
        elif TYPE == 'TRS':
            aggD = monet.generateAggregationDictionary(["C*", "O-", "Total"],
                                                       gsd.SD_TRS)
            yRange = 12500
            colors = COLTN
        elif TYPE == 'WLD':
            aggD = monet.generateAggregationDictionary(["O-", "W*", "Total"],
                                                       gsd.SD_WLD)
            yRange = 12500
            colors = COLWN
    # Return values ###########################################################
    return {'gDict': aggD, 'yRange': yRange, 'colors': colors}
def aggregateDataFromPath(path, aggregationDictionary):
    filenames = monet.readExperimentFilenames(path)
    landscapeSumData = monet.sumLandscapePopulationsFromFiles(
        filenames, male=True, female=True, dataType=float
    )
    aggData = monet.aggregateGenotypesInNode(landscapeSumData, aggregationDictionary)
    return aggData
Exemplo n.º 3
0
def exportPreTracesParallel(exIx,
                            STYLE,
                            PT_IMG,
                            border=True,
                            borderColor='#322E2D',
                            borderWidth=1,
                            autoAspect=False,
                            xpNum=0,
                            digs=3,
                            vLines=[0, 0],
                            hLines=[0],
                            popScaler=1,
                            sampRate=1):
    monet.printProgress(exIx[0], xpNum, digs)
    repFilePath = exIx[1][1]
    repDta = pkl.load(repFilePath)
    name = path.splitext(repFilePath.split('/')[-1])[0][:-4]
    monet.exportTracesPlot(repDta,
                           name,
                           STYLE,
                           PT_IMG,
                           wopPrint=False,
                           autoAspect=autoAspect,
                           border=border,
                           borderColor=borderColor,
                           borderWidth=borderWidth,
                           sampRate=sampRate)
    return None
Exemplo n.º 4
0
def calcQuantWOP(srpPrb, meanRef, thresholds, gIx, quantile=.95):
    """
    Calculates the mean window of protection for the quantile response of two
        populations.
    Args:
        srpPrb (dict): SRP population of the probe population.
        meanRef (np.array): Mean population of the reference population
        thresholds (list): List of ratios to use as thresholds.
        gIx (int): Index of the genotype of interest's location
        quantile (float): Quantile for the thresholds calculation
        cmprOp(function): Operation to compare against (less than, greater
            than, etcetera).
    Returns:
        list: Returns the time at which the condition is met at a given
            quantile level.
    """
    prb = srpPrb['landscapes']
    smpNum = len(prb)
    (wopArr, ttiArr,
     ttoArr) = [np.empty((smpNum, len(thresholds))) for i in range(3)]
    for s in range(smpNum):
        refPop = meanRef['population']
        ratioOI = monet.getPopRatio(prb[s], refPop, gIx)
        thsArray = monet.comparePopToThresh(ratioOI, thresholds, cmprOp=op.lt)
        thsDays = monet.thresholdMet(thsArray)
        wopArr[s] = [len(i) for i in thsDays]
        ttiArr[s] = [min(i) for i in thsDays]
        ttoArr[s] = [max(i) for i in thsDays]
    (quantWOP, quantTTI, quantTTO) = [
        np.nanquantile(i, quantile, axis=0) for i in [wopArr, ttiArr, ttoArr]
    ]
    return (quantWOP, quantTTI, quantTTO)
Exemplo n.º 5
0
def exportPstTracesParallel(
        exIx, expsNum,
        STABLE_T, THS, QNT, STYLE, PT_IMG, 
        border=True, borderColor='#322E2D', borderWidth=1, 
        labelPos=(.7, .9), xpsNum=0, digs=3, 
        autoAspect=False, popScaler=1,
        wopPrint=True, cptPrint=True, poePrint=True, mnfPrint=True, 
        ticksHide=True, transparent=True, sampRate=1, labelspacing=.1
    ):
    (ix, repFile, tti, tto, wop, mnf, _, poe, cpt) = exIx
    repDta = pkl.load(repFile)
    # Print to terminal -------------------------------------------------------
    padi = str(ix+1).zfill(digs)
    fmtStr = '{}+ File: {}/{}'
    print(fmtStr.format(monet.CBBL, padi, expsNum, monet.CEND), end='\r')
    # Traces ------------------------------------------------------------------
    pop = repDta['landscapes'][0][STABLE_T][-1]
    # STYLE['yRange'] = (0,  pop*popScaler)
    monet.exportTracesPlot(
        repDta, repFile.split('/')[-1][:-6]+str(QNT), STYLE, PT_IMG,
        vLines=[tti, tto, 0], hLines=[mnf*pop], labelPos=labelPos, 
        border=border, borderColor=borderColor, borderWidth=borderWidth,
        autoAspect=autoAspect, popScaler=popScaler,
        wop=wop, wopPrint=wopPrint, 
        cpt=cpt, cptPrint=cptPrint,
        poe=poe, poePrint=poePrint,
        mnf=mnf, mnfPrint=mnfPrint,
        ticksHide=ticksHide, transparent=True, 
        sampRate=sampRate, labelspacing=labelspacing
    )
    return None
Exemplo n.º 6
0
def readExperimentFilenames(experimentPath,
                            sexFilenameIdentifiers={
                                "male": "",
                                "female": ""
                            },
                            exclusionPattern=None):
    defaultIdentifiers = {"male": ["M_", "ADM"], "female": ["F_", "AF1"]}

    maleFiles = []
    if 'male' in sexFilenameIdentifiers:
        maleFiles = monet.getFileExperimentList(experimentPath,
                                                sexFilenameIdentifiers['male'])
        if not maleFiles:
            for i in defaultIdentifiers['male']:
                fileList = monet.getFileExperimentList(experimentPath, i)
                if fileList:
                    maleFiles = fileList
                    break

    femaleFiles = []
    if 'female' in sexFilenameIdentifiers:
        femaleFiles = monet.getFileExperimentList(
            experimentPath, sexFilenameIdentifiers['female'])
        if not femaleFiles:
            for i in defaultIdentifiers['female']:
                fileList = monet.getFileExperimentList(experimentPath, i)
                if fileList:
                    femaleFiles = fileList
                    break

    if exclusionPattern is not None:
        maleFiles = [i for i in maleFiles if exclusionPattern(i)]
        femaleFiles = [i for i in femaleFiles if exclusionPattern(i)]

    return {"male": maleFiles, "female": femaleFiles}
Exemplo n.º 7
0
def exportTracesPlot(
    tS, nS, STYLE, PATH_IMG, append='', 
    vLines=[0, 0], hLines=[0], labelPos=(.7, .9), autoAspect=False,
    border=True, borderColor='#8184a7AA', borderWidth=2, popScaler=1,
    wop=0, wopPrint=True, cpt=0, cptPrint=False, poe=0, poePrint=False,
    transparent=False
):
    if transparent:
        plt.rcParams.update({
            "figure.facecolor":  (1.0, 0.0, 0.0, 0.0),
            "axes.facecolor":    (0.0, 1.0, 0.0, 0.0),
            "savefig.facecolor": (0.0, 0.0, 1.0, 0.0),
        })
    figArr = monet.plotNodeTraces(tS, STYLE)
    axTemp = figArr[0].get_axes()[0]
    STYLE['yRange'] = (STYLE['yRange'][0], STYLE['yRange'][1] * popScaler)
    axTemp.set_xlim(STYLE['xRange'][0], STYLE['xRange'][1])
    axTemp.set_ylim(STYLE['yRange'][0], STYLE['yRange'][1])
    if autoAspect:
        axTemp.set_aspect(aspect=monet.scaleAspect(STYLE["aspect"], STYLE))
    else:
        axTemp.set_aspect(aspect=STYLE["aspect"])
    # axTemp.axes.xaxis.set_ticklabels()
    # axTemp.axes.yaxis.set_ticklabels()
    axTemp.axes.xaxis.set_visible(True)
    axTemp.axes.yaxis.set_visible(True)
    # axTemp.set_axis_off()
    axTemp.grid(which='major', axis='y', lw=.5, ls='-', alpha=0.0, color=(0, 0, 0))
    axTemp.grid(which='major', axis='x', lw=.5, ls='-', alpha=0.0, color=(0, 0, 0))

    if wop==True:
        axTemp.axvspan(vLines[0], vLines[1], alpha=0.15, facecolor='#3687ff', zorder=-5)

    
    for vline in vLines[2:]:
        axTemp.axvline(vline, alpha=.5, zorder=10, ls='-', lw=.1, color='#000000')
     
    #axTemp.tick_params(color=(0, 0, 0, 0.5))
    axTemp.tick_params(left=False, labelleft=False, bottom=False, labelbottom=False)
    # extent = axTemp.get_tightbbox(figArr[0]).transformed(figArr[0].dpi_scale_trans.inverted())
    if border:
        axTemp.set_axis_on()
        plt.setp(axTemp.spines.values(), color=borderColor)
        pad = 0.025
        for axis in ['top','bottom','left','right']:
            axTemp.spines[axis].set_linewidth(borderWidth)
    else:
        pad = 0
    figArr[0].savefig(
            "{}/{}.{}".format(PATH_IMG, nS, STYLE['format']),
            dpi=STYLE['dpi'], facecolor=None,
            orientation='portrait', format=STYLE['format'], 
            transparent=transparent, bbox_inches='tight', pad_inches=pad
        )
    plt.clf()
    plt.cla() 
    plt.close('all')
    plt.gcf()
    return None
Exemplo n.º 8
0
def setupFolder(USR, DRV, exp, HD_IND):
    (PT_ROT, PT_IMG, PT_DTA, PT_PRE, PT_OUT) = selectPath(USR, DRV, exp)
    PT_IMG = PT_IMG[:-1]+'Pst/'
    fldrName = '{}_{}/'.format(*HD_IND)
    PT_IMG_XP = PT_IMG+fldrName
    monet.makeFolder(PT_IMG)
    monet.makeFolder(PT_IMG_XP)
    return (PT_ROT, PT_IMG_XP, PT_DTA, PT_PRE, PT_OUT)
Exemplo n.º 9
0
def plotAndSaveLandscapeReps(landscapeReps, ssDay, path):
    figsArray = plots.plotLandscapeDataRepetitions(landscapeReps, style, ssDay,
                                                   yRangeFixed)
    for i in range(0, len(figsArray)):
        figsArray[i].get_axes()[0].set_xlim(0, xRange)
        figsArray[i].get_axes()[0].set_ylim(0, yRangeFixed)
        monet.quickSaveFigure(figsArray[i], path, dpi=750)
        plt.close()
Exemplo n.º 10
0
def getExpPaths(PATH_DATA):
    (expDirsMean, expDirsTrac) = (
            monet.listDirectoriesWithPathWithinAPath(PATH_DATA + 'ANALYZED/'),
            monet.listDirectoriesWithPathWithinAPath(PATH_DATA + 'TRACES/')
        )
    expDirsMean.sort()
    expDirsTrac.sort()
    return (expDirsMean, expDirsTrac)
Exemplo n.º 11
0
def loadSummedMeanResponse(aFiles, GDICT, MALE, FEMALE):
    print(aux.CBLU, end='\r')
    # print('\t Loading mean response...'+aux.PADC, end='\r')
    landData = monet.loadLandscapeData(aFiles, male=MALE, female=FEMALE)
    # print('\t Aggregating mean response...'+aux.PADC, end='\r')
    aggDataM = monet.aggregateGenotypesInLandscape(landData, GDICT)
    aggDataM['landscape'] = sum(aggDataM['landscape'])
    print(aux.CEND, end='\r')
    return aggDataM
Exemplo n.º 12
0
def getExpPaths(PATH_DATA):
    (expDirsMean,
     expDirsTrac) = (monet.listDirectoriesWithPathWithinAPath(PATH_DATA +
                                                              'analyzed/'),
                     monet.listDirectoriesWithPathWithinAPath(PATH_DATA +
                                                              'traces/'))
    expDirsMean.sort()
    expDirsTrac.sort()
    return (expDirsMean, [i + '/' for i in expDirsTrac])
Exemplo n.º 13
0
def plotAndSaveStack(aggData, ssDay, ffString, ffStringH, path):
    figB = plots.plotMeanGenotypeStack(aggData, styleS, ssDay, 2 * yRange)
    figB.get_axes()[0].set_xlim(0, xRange)
    figB.get_axes()[0].set_ylim(0, 2 * yRange)
    figB.get_axes()[0].set_title("[tSS: " + str(ssDay) + "] :: [" + ffString +
                                 "] :: [" + ffStringH + "]",
                                 fontsize=5)
    monet.quickSaveFigure(figB, path, dpi=1024, format="pdf")
    plt.close()
Exemplo n.º 14
0
def preProcessSubLandscape(pop,
                           landReps,
                           fName,
                           drive,
                           nodesAggLst,
                           nodeAggIx,
                           MF=(True, True),
                           cmpr='bz2',
                           SUM=True,
                           AGG=True,
                           SPA=True,
                           REP=True,
                           SRP=True):
    """
    Preprocesses a subset of the landscape
    Args:
        pop (list): Files list element aggregated by landscape subset
        landReps (dict): Landscape repetitions
                (spatial from monet.loadAndAggregateLandscapeDataRepetitions)
        fName (str): Filename (including path)
        drive (dict): Gene-drive dictionary
        nodesAggLst (lst): List of lists containing the indices of the nodes
                to be aggregated together
        nodeAggIx (int): Current list to process (from the nodeAggLst)
        MF (bool tuple): Male and Female boolean selectors
        cmpr (str): Compression algorithm to be used by compress-python
        SUM (bool): Population summed and gene-aggregated into one node
        AGG (bool): Population gene-aggregated in their own nodes
        SPA (bool): Genetic landscape (gene-aggregated)
        REP (bool): Garbage gene-aggregated data
        SRP (bool): Summed into one garbage gene-aggregated data
    Returns:
        None
    """
    if SUM:
        sumData = monet.sumLandscapePopulationsFromFiles(pop, MF[0], MF[1])
        sumAgg = monet.aggregateGenotypesInNode(sumData, drive)
        pkl.dump(sumAgg, fName + '_sum', compression=cmpr)
    if AGG:
        aggData = monet.loadAndAggregateLandscapeData(pop, drive, MF[0], MF[1])
        pkl.dump(aggData, fName + '_agg', compression=cmpr)
    if SPA:
        geneSpaTemp = monet.getGenotypeArraysFromLandscape(aggData)
        pkl.dump(geneSpaTemp, fName + '_spa', compression=cmpr)
    if REP or SRP:
        fLandReps = monet.filterAggregateGarbageByIndex(
            landReps, nodesAggLst[nodeAggIx])
        pkl.dump(fLandReps, fName + '_rep', compression=cmpr)
    if SRP:
        fRepsSum = [sum(i) for i in fLandReps['landscapes']]
        fRepsDict = {
            'genotypes': fLandReps['genotypes'],
            'landscapes': fRepsSum
        }
        pkl.dump(fRepsDict, fName + '_srp', compression=cmpr)
    return None
Exemplo n.º 15
0
def calcDaysCrosses(aggregatedNodesData, thresholds, ssPops, gIx):
    chngDays = []
    for j in range(len(aggregatedNodesData['landscape'])):
        nodePop = aggregatedNodesData['landscape'][j]
        thrsBool = monet.comparePopToThresholds(nodePop,
                                                gIx, [0, 1],
                                                thresholds,
                                                refPop=ssPops[j])
        chngDays.append(monet.getConditionChangeDays(thrsBool))
    return chngDays
Exemplo n.º 16
0
def selectVersionPath(MGV, PT_DTA):
    if MGV == 'v2':
        (expDirsMean, expDirsTrac) = monet.getExpPaths(PT_DTA,
                                                       mean='analyzed/',
                                                       reps='traces/')
    else:
        (expDirsMean, expDirsTrac) = monet.getExpPaths(PT_DTA,
                                                       mean='ANALYZED/',
                                                       reps='GARBAGE/')
    return (expDirsMean, expDirsTrac)
Exemplo n.º 17
0
def getAggDataSSDay(pathsRoot, i):
    pathSample = pathsRoot[i] + "/"
    experimentString = pathSample.split("/")[-2]
    filenames = monet.readExperimentFilenames(pathSample)
    landscapeSumData = monet.sumLandscapePopulationsFromFiles(filenames,
                                                              male=True,
                                                              female=True,
                                                              dataType=float)
    aggData = monet.aggregateGenotypesInNode(landscapeSumData,
                                             aggregationDictionary)
    ssDay = aux.reachedSteadtStateAtDay(aggData, .01)
    return aggData, ssDay, experimentString
Exemplo n.º 18
0
def getLandscapeReps(i):
    pathsRoot = monet.listDirectoriesWithPathWithinAPath(pathRoot + pathExt +
                                                         "ANALYZED/")
    aggData, ssDay, _ = getAggDataSSDay(pathsRoot, i)
    #######################################################################
    pathsRoot = monet.listDirectoriesWithPathWithinAPath(pathRoot + pathExt +
                                                         "GARBAGE/")
    pathSample = pathsRoot[i]
    experimentString = pathSample.split("/")[-1]
    paths = monet.listDirectoriesWithPathWithinAPath(pathSample + "/")
    landscapeReps = monet.loadAndAggregateLandscapeDataRepetitions(
        paths, aggregationDictionary, male=False, female=True, dataType=float)
    return landscapeReps, ssDay, experimentString
Exemplo n.º 19
0
def driveSelector(DRIVE, HEALTH, pathRoot):
    if DRIVE == 1:
        (pathExt, pathO) = ("SplitDrive/2019_10_12_GARBAGE/", 'SD')
        if HEALTH is True:
            aggregationDictionary = monet.generateAggregationDictionary(
                ["H", "Other", "Total"],
                [[4, 5, 6, 11, 14, 15, 16, 21, 24, 25, 26],
                 [
                     0, 1, 2, 3, 7, 8, 9, 10, 12, 13, 17, 18, 19, 20, 22, 23,
                     27, 28, 29
                 ],
                 [
                     4, 5, 6, 11, 14, 15, 16, 21, 24, 25, 26, 0, 1, 2, 3, 7, 8,
                     9, 10, 12, 13, 17, 18, 19, 20, 22, 23, 27, 28, 29
                 ]])
        else:
            aggregationDictionary = monet.generateAggregationDictionary(
                ["H", "B", "R", "W", "C", "Total"],
                [[1, 4, 4, 5, 6, 11, 14, 14, 15, 16, 21, 24, 24, 25, 26],
                 [3, 6, 8, 9, 9, 13, 16, 18, 19, 19, 23, 26, 28, 29, 29],
                 [2, 5, 7, 7, 8, 12, 15, 17, 17, 18, 22, 25, 27, 27, 28],
                 [
                     0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6,
                     7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14,
                     15, 16, 17, 18, 19, 20, 20, 21, 22, 23
                 ],
                 [
                     10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21,
                     22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28,
                     29, 29
                 ],
                 [
                     1, 4, 4, 5, 6, 11, 14, 14, 15, 16, 21, 24, 24, 25, 26, 3,
                     6, 8, 9, 9, 13, 16, 18, 19, 19, 23, 26, 28, 29, 29, 2, 5,
                     7, 7, 8, 12, 15, 17, 17, 18, 22, 25, 27, 27, 28, 0, 0, 0,
                     0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
                     8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 16,
                     17, 18, 19, 20, 20, 21, 22, 23, 10, 11, 12, 13, 14, 15,
                     16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24,
                     25, 25, 26, 26, 27, 27, 28, 28, 29, 29
                 ]])
    if HEALTH is True:
        prepend = "H"
    else:
        prepend = "E"
    if pathRoot != '':
        pathsRoot = monet.listDirectoriesWithPathWithinAPath(pathRoot +
                                                             pathExt)
    else:
        pathsRoot = ''
    return [pathsRoot, aggregationDictionary, prepend, pathO]
Exemplo n.º 20
0
def calculateGeneTemporal(filenames):
    landscapeSumData = monet.sumLandscapePopulationsFromFiles(
        filenames, male=True, female=False, dataType=float
    )
    genotypes = landscapeSumData["genotypes"]
    aggregationDictionary = monet.autoGenerateGenotypesDictionary(
        ["W", "H", "R", "B"],
        genotypes
    )
    aggData = monet.aggregateGenotypesInNode(
        landscapeSumData,
        aggregationDictionary
    )
    return aggData
Exemplo n.º 21
0
def driveParameters(TYPE, popSize):
    if TYPE == 'ECO':
        aggD = monet.generateAggregationDictionary(*CRS_ECO)
        yRange = popSize
    elif TYPE == 'HLT':
        aggD = monet.generateAggregationDictionary(*CRS_HLT)
        yRange = popSize / 4
    elif TYPE == 'TRS':
        aggD = monet.generateAggregationDictionary(*CRS_TRS)
        yRange = popSize
    elif TYPE == 'WLD':
        aggD = monet.generateAggregationDictionary(*CRS_WLD)
        yRange = popSize
    return (aggD, yRange, 'SplitDrive-YG')
Exemplo n.º 22
0
def driveParameters(TYPE, popSize):
    if TYPE == 'ECO':
        aggD = monet.generateAggregationDictionary(*ASD_ECO)
        yRange = popSize
    elif TYPE == 'HLT':
        aggD = monet.generateAggregationDictionary(*ASD_HLT)
        yRange = popSize / 2
    elif TYPE == 'TRS':
        aggD = monet.generateAggregationDictionary(*ASD_TRS)
        yRange = popSize / 2
    elif TYPE == 'WLD':
        aggD = monet.generateAggregationDictionary(*ASD_WLD)
        yRange = popSize
    return (aggD, yRange, 'autosomal')
Exemplo n.º 23
0
def driveParameters(TYPE, popSize):
    if TYPE == 'ECO':
        aggD = monet.generateAggregationDictionary(*YXS_ECO)
        yRange = popSize
    elif TYPE == 'HLT':
        aggD = monet.generateAggregationDictionary(*YXS_HLT)
        yRange = popSize / 2
    elif TYPE == 'TRS':
        aggD = monet.generateAggregationDictionary(*YXS_TRS)
        yRange = popSize / 2
    elif TYPE == 'WLD':
        aggD = monet.generateAggregationDictionary(*YXS_WLD)
        yRange = popSize
    return (aggD, yRange, 'yLinked')
Exemplo n.º 24
0
def driveParameters(TYPE, popSize):
    if TYPE == 'ECO':
        aggD = monet.generateAggregationDictionary(*FMS_ECO)
        yRange = popSize * 4
    elif TYPE == 'HLT':
        aggD = monet.generateAggregationDictionary(*FMS_HLT)
        yRange = popSize
    elif TYPE == 'TRS':
        aggD = monet.generateAggregationDictionary(*FMS_TRS)
        yRange = popSize / 2
    elif TYPE == 'WLD':
        aggD = monet.generateAggregationDictionary(*FMS_WLD)
        yRange = popSize / 2
    return (aggD, yRange, 'ifegenia_5')
Exemplo n.º 25
0
def driveParameters(TYPE, popSize):
    if TYPE == 'ECO':
        aggD = monet.generateAggregationDictionary(*LDR_ECO)
        yRange = popSize*2
    elif TYPE == 'HLT':
        aggD = monet.generateAggregationDictionary(*LDR_HLT)
        yRange = popSize/2
    elif TYPE == 'TRS':
        aggD = monet.generateAggregationDictionary(*LDR_TRS)
        yRange = popSize/2
    elif TYPE == 'WLD':
        aggD = monet.generateAggregationDictionary(*LDR_WLD)
        yRange = popSize/2
    return (aggD, yRange, 'LDR')
Exemplo n.º 26
0
def HelperFunction(i, xpNum, digs, fLists, STYLE, PT_IMG):
    print(msg.format(str(i+1).zfill(digs), str(xpNum).zfill(digs)), end='\r')
    (sumDta, repDta) = [pkl.load(file) for file in (fLists[i])]
    name = fLists[i][0].split('/')[-1].split('.')[0][:-4][11:]
    # Export plots --------------------------------------------------------
    fun.exportTracesPlot(repDta, name, STYLE, PT_IMG, append='TRA')
    cl = [i[:-2]+'cc' for i in CLR]
    if i == xpNum - 1:
        monet.exportGeneLegend(
            sumDta['genotypes'], cl, PT_IMG+'/plt_{}.png'.format(AOI), 500
            )
        tE = datetime.now()
        print('* Analyzed ({}/{})                    '.format(xpNum, xpNum), end='\n')
        print(monet.PAD)
Exemplo n.º 27
0
def preProcessParallel(exIx,
                       expNum,
                       drive,
                       analysisOI='HLT',
                       prePath='./',
                       nodesAggLst=[[0]],
                       fNameFmt='{}/{}-{}_',
                       MF=(True, True),
                       cmpr='bz2',
                       nodeDigits=4,
                       SUM=True,
                       AGG=False,
                       SPA=False,
                       REP=False,
                       SRP=True,
                       sexFilenameIdentifiers={
                           "male": "M_",
                           "female": "F_"
                       }):
    (ix, expDirsMean, expDirsTrac) = exIx
    monet.printProgress(ix + 1, expNum, nodeDigits)
    (pathMean, pathTraces) = (expDirsMean, expDirsTrac + '/')
    expName = pathMean.split('/')[-1]
    fNameFmt = '{}/{}-{}_'.format(prePath, expName, analysisOI)
    # Iterate through experiment files and skip errors (unsafe but logs)
    try:
        monet.preProcessLandscape(
            pathMean,
            pathTraces,
            expName,
            drive,
            prePath,
            analysisOI=analysisOI,
            nodesAggLst=nodesAggLst,
            fNameFmt=fNameFmt,
            MF=MF,
            cmpr=cmpr,
            nodeDigits=nodeDigits,
            SUM=SUM,
            AGG=AGG,
            SPA=SPA,
            REP=REP,
            SRP=SRP,
            sexFilenameIdentifiers=sexFilenameIdentifiers)
    except:
        file = open("preProcess.log", "a")
        file.write(expName + '\n')
        file.close()
    return None
Exemplo n.º 28
0
def calculateGeneSpatiotemporals(filenames):
    landscapeData = monet.loadLandscapeData(filenames, dataType=float)
    genotypes = landscapeData["genotypes"]
    aggregationDictionary = monet.autoGenerateGenotypesDictionary(
        ["W", "H", "R", "B"],
        genotypes
    )
    aggregatedNodesData = monet.aggregateGenotypesInLandscape(
        landscapeData,
        aggregationDictionary
    )
    geneSpatiotemporals = monet.getGenotypeArraysFromLandscape(
        aggregatedNodesData
    )
    return geneSpatiotemporals
Exemplo n.º 29
0
def exportTracesPlot(tS, nS, STYLE, PATH_IMG, append='', vLines=[0]):
    figArr = monet.plotLandscapeDataRepetitions(tS, STYLE)
    axTemp = figArr[0].get_axes()[0]
    axTemp.set_aspect(aspect=STYLE["aspect"])
    axTemp.set_xlim(STYLE['xRange'][0], STYLE['xRange'][1])
    axTemp.set_ylim(STYLE['yRange'][0], STYLE['yRange'][1])
    axTemp.vlines(vLines,
                  0,
                  1,
                  transform=axTemp.get_xaxis_transform(),
                  colors='#FF007FA5',
                  linestyles='dashed',
                  linewidth=.25)
    axTemp.tick_params(color=(0, 0, 0, 0.5))
    figArr[0].savefig("{}/{}-{}.png".format(PATH_IMG, nS, append),
                      dpi=STYLE['dpi'],
                      facecolor=None,
                      edgecolor='w',
                      orientation='portrait',
                      papertype=None,
                      format='png',
                      transparent=True,
                      bbox_inches='tight',
                      pad_inches=.01)
    plt.close('all')
    return True
Exemplo n.º 30
0
def selectPath(USR, DRV, EXP):
    if USR == 'srv':
        PATH_ROOT = '/RAID5/marshallShare/SplitDrive_Suppression/{}/{}/'.format(
            DRV, EXP)
    elif USR == 'srv2':
        PATH_ROOT = '/RAID5/marshallShare/SplitDrive_Suppression/theoretical/{}/{}/'.format(
            DRV, EXP)
    elif USR == 'srvA':
        PATH_ROOT = '/RAID5/marshallShare/SplitDrive_Suppression/realized1/{}/{}/'.format(
            DRV, EXP)
    elif USR == 'srvB':
        PATH_ROOT = '/RAID5/marshallShare/SplitDrive_Suppression/realized3/{}/{}/'.format(
            DRV, EXP)
    elif USR == 'srvC':
        PATH_ROOT = '/RAID5/marshallShare/SplitDrive_Suppression/realized7/{}/{}/'.format(
            DRV, EXP)
    elif USR == 'dsk':
        PATH_ROOT = '/home/chipdelmal/Documents/WorkSims/SDP/{}/{}/'.format(
            DRV, EXP)
    elif USR == 'lab':
        PATH_ROOT = '/Volumes/marshallShare/SplitDrive_Suppression/theoretical/{}/{}/'.format(
            DRV, EXP)
    (PATH_IMG, PATH_DATA) = ('{}img/'.format(PATH_ROOT),
                             '{}'.format(PATH_ROOT))
    PATH_PRE = PATH_DATA + 'PREPROCESS/'
    PATH_OUT = PATH_DATA + 'POSTPROCESS/'
    PATH_MTR = PATH_DATA + 'SUMMARY/'
    fldrList = [PATH_ROOT, PATH_IMG, PATH_DATA, PATH_PRE, PATH_OUT, PATH_MTR]
    [monet.makeFolder(i) for i in fldrList]
    return (PATH_ROOT, PATH_IMG, PATH_DATA, PATH_PRE, PATH_OUT, PATH_MTR)