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
def preProcessSubLandscape(pop, landReps, fName, drive, nodesAggLst, nodeAggIx, MF=(True, True), cmpr='bz2', SUM=True, AGG=True, SPA=True, REP=True, SRP=True): if SUM: sumData = monet.sumLandscapePopulationsFromFiles(pop, MF[0], MF[1]) print(sumData) sumAgg = exp.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]) if REP: 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
print(aux.CBLU + '- Loading mean... ' + aux.PADC, end='\r') (ykFaPath, tpFaPath) = (monet.filterFilesByIndex(aFiles, sectorsIx[1], MALE, FEMALE), monet.filterFilesByIndex(aFiles, sectorsIx[0], MALE, FEMALE)) (ykAggData, tpAggData) = (fun.loadSummedMeanResponse(ykFaPath, GDICT, True, True), fun.loadSummedMeanResponse(tpFaPath, GDICT, True, True)) # Garbage print(aux.CBLU + '- Loading traces... ' + aux.PADC, end='\r') landscapeReps = monet.loadAndAggregateLandscapeDataRepetitions(gFiles, GDICT, male=True, female=True) (ykLand, tpLand) = (monet.filterAggregateGarbageByIndex(landscapeReps, sectorsIx[1]), monet.filterAggregateGarbageByIndex(landscapeReps, sectorsIx[0])) # Plots ------------------------------------------------------------------ print(aux.CBLU + '- Plotting...' + aux.PADC, end='\r') geneSpatiotemporalsNorm = monet.rescaleGeneSpatiotemporals( geneSpatiotemporals) overlay = monet.plotGenotypeOverlayFromLandscape( geneSpatiotemporalsNorm, style={ "aspect": 50 * STYLE['aspect'], "cmap": CMAPS }, vmax=1 # 50 ) figsArray = (monet.plotLandscapeDataRepetitions(ykLand, STYLE),