# DataMatrix and StateMatrix¶

class fwdpy11.DataMatrix

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

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

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

Return a buffer representing neutral variants. This buffer may be used to create a NumPy ndarray object.

Changed in version 0.1.2: Return a buffer instead of 1d numpy.array

Changed in version 0.2.0: Type is fwdpy11.StateMatrix

property neutral_keys

Keys for neutral mutations used to generate matrix

Changed in version 0.6.1: Type changed to numpy.ndarray

property 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

Return a buffer representing neutral variants. This buffer may be used to create a NumPy ndarray object.

Changed in version 0.1.2: Return a buffer instead of 1d numpy.array

Changed in version 0.2.0: Type is fwdpy11.StateMatrix

property selected_keys

Keys for selected mutations used to generate matrix

Changed in version 0.6.1: Type changed to numpy.ndarray

property 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.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

property positions

The mutation positions.

Changed in version 0.6.1: Type changed to numpy.ndarray

property shape

Shape of the matrix.