DataMatrix and StateMatrix#

class fwdpy11.DataMatrix(*args)#

Represent a sample from a population in a matrix format.

There are two possible representations of the data:

1. As a genotype matrix, where individuals are encoded a 0,1, or 2 copies of the derived mutation. There is one column per diploid here, and one row per variable site.

2. As a haplotype matrix, with two columns per diploid, and each column containing a 0 (ancestral) or 1 (derived) label. Each row represents a variable site.

Changed in version 0.2.0: Changed layout to row = variable site. Changed to match fwdpp 0.7.0 layout where the neutral and selected data are represented as a fwdpy11.StateMatrix

merge()#

Merge the neutral and selected data.

Return type:

tuple

Returns:

a numpy.ndarray composed of neutral and selected mutations. Rows (mutations) are sorted by position. The second tuple element contains the mutation keys.

New in version 0.6.1.

property ncol#

Sample size of the matrix

property neutral#

fwdpy11.StateMatrix for neutral variants

property neutral_keys#

Keys for neutral mutations used to generate matrix.

neutral_matrix()#
Returns:

Neutral mutations and keys

Return type:

tuple

The neutral matrix is a numpy.ndarray

New in version 0.6.1.

property selected#

fwdpy11.StateMatrix for selected variants

property selected_keys#

Keys for selected mutations used to generate matrix.

selected_matrix()#
Returns:

Selected mutations and keys

Return type:

tuple

The selected matrix is a numpy.ndarray

New in version 0.6.1.

class fwdpy11.StateMatrix#

Simple matrix representation of variation data.

These are not constructed directly. Rather, they are generated when a fwdpy11.DataMatrix is generated .

This object supports the buffer protocol .

New in version 0.2.0.

property positions#

The mutation positions.

Changed in version 0.6.1: Type changed to numpy.ndarray

property shape#

Shape of the matrix.