Reference

Utilities

Functions for processing data.

anc_to_deme_dict Converts the ancestral population assignments of demes into a dictionary mapping ancestral population IDs to deme indices.
calc_migration_matrix Calculates a migration matrix based on deme sizes and a global migration rate. The migration rate can be scaled based on population size or set as a constant.
coords_to_deme_dict Finds the cells a given set of coordinates belong to in a raster and returns a dictionary mapping the cell indices to the centroid coordinates of those cells.
coords_to_sample_dict Convert sample coordinates to sample dictionaries for simulation and analysis. Can optionally include empirical data, which is accepted as a path to a VCF file.
create_raster Creates a raster dataset from a numpy array and reference raster and writes it to a new GeoTiff file.
mtp_thresh_from_coords This function takes the coordinates of empirical sampling localities, finds which raster cells they belong to, extracts the values of the first layer for those localities, and finds the minimum value.
raster_to_demes Converts a raster to a 2D np.ndarray of deme sizes using either linear, threshold, or sigmoid transformation functions. For more detail about transformation functions, see this brief overview.
split_landscape_by_pop Uses nearest-neighbor interpolation to classify a landscape raster based on the ancestral population assigned to sampled individuals.

Demography

Methods to create and manipulate demographic models.

spDemography
spDemography.add_ancestral_populations Adds ancestral populations to the given demographic model, mapping demes in the spatial simulation to ancestral populations.
spDemography.stepping_stone_2d Create a 2D stepping stone model, either for a single time step or for multiple time steps of deme size change.

Plotting

Functions for visualizing data.

plot_landscape Plots a static map of a transformed landscape at the timestep of your choice.
plot_model Plots the demes and migration rates for a given timestep as an interactive map.
plot_timeseries Plots the total number of individuals across the landscape across time.

Simulation

Thin wrappers around msprime simulation functions.

sim_ancestry A thin wrapper around msprime.sim_ancestry.
sim_mutations A thin wrapper around msprime.sim_mutations.

Analysis

Functions for analyzing data.

calc_sumstats Calculates a suite of genetic summary statistics on allele counts matrices generated by filter_gt or otherwise generated through scikit-allel.
filter_gt Filter genotype matrices output by ts.genotype_matrix() to filter out monomorphic sites, loci in linkage disequilibrium, and recreate missing data patterns common to empirical genotype data.