Beispiel #1
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
Beispiel #2
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
Beispiel #3
0
 # Heatmap population plots (maintains the spatial information, so that the
 #   spread of the gene drive can be analyzed geographically)
 ###########################################################################
 if HEAT:
     # Parses the paths of all CSV files starting with 'F_' and/or 'M_'
     filenames = monet.readExperimentFilenames(pathRoot + experimentString +
                                               '/')
     # Loads all the files provided without summing them
     landscapeData = monet.loadLandscapeData(filenames,
                                             male=maleToggle,
                                             female=femaleToggle,
                                             dataType=float)
     # Groups the genotypes into "bins" provided by the
     #   "aggregationDictionary" by summing the counts in each one of the
     #   columns.
     aggregatedNodesData = monet.aggregateGenotypesInLandscape(
         landscapeData, aggregationDictionary)
     # Reshapes the data to take the form:
     #    [nodeNUM, [originalGenotypes, time, [counts]]
     geneSpatiotemporals = monet.getGenotypeArraysFromLandscape(
         aggregatedNodesData)
     # Plotting-related instructions
     overlay = monet.plotGenotypeOverlayFromLandscape(
         geneSpatiotemporals,
         style={
             "aspect": 30 * style['aspect'],
             "cmap": cmaps
         },
         vmax=
         27.5  #monet.maxAlleleInLandscape(geneSpatiotemporals["geneLandscape"])
     )
     monet.quickSaveFigure(overlay,
Beispiel #4
0
 gradient = np.linspace(0, 1, len(expDirsMean))
 for (i, pathMean) in enumerate(expDirsMean):
     # for (i, pathMean) in enumerate(expDirsMean):
     print('* Analyzing {}: ({}/{})'.format(rid,
                                            str(i + 1).zfill(2),
                                            str(expNum)),
           end='\r')
     expName = pathMean.split('/')[-1]
     dirsMean = pathMean
     expOutImgPath = expOutRootPath
     # Mean response -------------------------------------------------------
     filenames = monet.readExperimentFilenames(pathMean)
     landscapeData = monet.loadLandscapeData(filenames,
                                             male=True,
                                             female=True)
     aggregatedNodesData = monet.aggregateGenotypesInLandscape(
         landscapeData, DRIVE)
     trace = aggregatedNodesData['landscape'][NOI].T[GOI] / SSPOP
     # Plot
     ax.plot([i / 7 for i in range(len(trace))],
             trace,
             color=cm(gradient[i]),
             alpha=.95,
             lw=.6)
 ax.set_xlim(0, xRange)
 ax.set_ylim(0, yRange)
 ax.set_aspect(xRange)
 ax.grid(True, alpha=.5, lw=.2, ls='--')
 fig.savefig('{}S_{}_{}.pdf'.format(PATH_IMG, rid, spltNm[-1]),
             bbox_inches='tight',
             pad_inches=0.1,
             transparent=True)
Beispiel #5
0
# Experiment Selector ---------------------------------------------------------
expOutRootPath = PATH_IMG  # + driveID
expOutExpPath = expOutRootPath + '/' + fldrName
monet.makeFolder(expOutRootPath)
monet.makeFolder(expOutExpPath)
# Create output folder --------------------------------------------------------
(dirTraces, dirMean) = (dirsTraces[0], dirsMean[0])
expOutSetPath = expOutExpPath + '/' + EXP + '/'
monet.makeFolder(expOutSetPath)
# Mean response ---------------------------------------------------------------
print(aux.PADL)
print('* Loading mean response data...')
# Load mean response and aggregate --------------------------------------------
filenames = monet.readExperimentFilenames(dirMean)
landscapeData = monet.loadLandscapeData(filenames, male=MALE, female=FEMALE)
aggregatedNodesData = monet.aggregateGenotypesInLandscape(
    landscapeData, drvPars.get('HLT'))
# Get the max range for each node ---------------------------------------------
maxPops = []
for i in aggregatedNodesData["landscape"]:
    maxPops.append(i[burn][-1] * 1)
# Get the crosses through thresholds ------------------------------------------
(chngDays, prtcDays) = ([], [])
for j in range(len(aggregatedNodesData['landscape'])):
    nodePop = aggregatedNodesData['landscape'][j]
    thrsBool = monet.comparePopToThresholds(nodePop,
                                            gIx, [0, 1],
                                            thresholds,
                                            refPop=maxPops[j])
    chngDays.append(monet.getConditionChangeDays(thrsBool))
    prtcDays.append(monet.countConditionDays(thrsBool))
###############################################################################