G_E_Phenotyping#

class pybrops.breed.prot.pt.G_E_Phenotyping.G_E_Phenotyping(gpmod, nenv=1, nrep=1, var_env=None, var_rep=None, var_err=None, rng=None, **kwargs)[source]#

Bases: PhenotypingProtocol

Class implementing phenotyping protocols for simulating phenotyping with no GxE interaction.

Construct a phenotyping protocol that simulates environments as having a fixed effect, but no genotype by environment interaction. Variance across environments are equal.

Parameters:
  • gpmod (GenomicModel) – True genomic model to use for prediction.

  • nenv (int) – Number of environments.

  • nrep (int, numpy.ndarray) –

    Number of replications per environment.

    If int, then broadcast nrep to an array of shape (nenv,) If numpy.ndarray, then must be of shape (nenv,)

  • var_env (numeric, numpy.ndarray) –

    Environmental variance parameter for each trait. Determines distribution of fixed effect added to each environment.

    If numeric, then broadcast var_env to an array of shape (ntrait,) If numpy.ndarray, then must be of shape (ntrait,)

  • var_rep (numeric, numpy.ndarray) –

    Replication variance parameter for each trait.

    Replication variance is assumed to be constant across environments. Replication is nested within each environment.

    If numeric, then broadcast var_rep to an array of shape (ntrait,) If numpy.ndarray, then must be of shape (ntrait,)

  • var_err (numeric, numpy.ndarray) –

    Error variance parameter.

    If numeric, then broadcast var_err to an array of shape (ntrait,).

    If numpy.ndarray, then must be of shape (ntrait,).

  • rng (numpy.random.Generator, numpy.random.RandomState, None) – Random number source.

  • kwargs (dict) – Additional keyword arguments.

Methods

copy

Make a shallow copy of the G_E_Phenotyping object.

deepcopy

Make a deep copy of the G_E_Phenotyping object.

from_hdf5

Read a G_E_Phenotyping from an HDF5 file.

phenotype

Phenotype a set of genotypes using a genomic prediction model.

set_H2

Set the broad sense heritability for environments.

set_h2

Set the narrow sense heritability for environments.

to_hdf5

Write a G_E_Phenotyping object to an HDF5 file.

Attributes

gpmod

Genomic prediction model.

nenv

Number of environments.

nrep

Number of replications per environment.

rng

Random number generator.

var_env

Variance across environments.

var_err

Error variance for each trait.

var_rep

Variance across replicates.

copy()[source]#

Make a shallow copy of the G_E_Phenotyping object.

Returns:

out – A shallow copy of the G_E_Phenotyping object.

Return type:

G_E_Phenotyping

deepcopy(memo=None)[source]#

Make a deep copy of the G_E_Phenotyping object.

Parameters:

memo (dict, None) – An optional dictionary of memo metadata.

Returns:

out – A deep copy of the G_E_Phenotyping object.

Return type:

G_E_Phenotyping

classmethod from_hdf5(filename, groupname=None, gpmod=None)[source]#

Read a G_E_Phenotyping from an HDF5 file.

Parameters:
  • filename (str, Path, h5py.File) – If str or Path, an HDF5 file name from which to read. File is closed after reading. If h5py.File, an opened HDF5 file from which to read. File is not closed after reading.

  • groupname (str, None) – If str, an HDF5 group name under which G_E_Phenotyping data is stored. If None, G_E_Phenotyping is read from base HDF5 group.

  • gpmod (GenomicModel) – A genomic model to bind to the G_E_Phenotyping protocol. This will be eliminated when a better storage mechanism is available.

Returns:

out – An G_E_Phenotyping read from an HDF5 file.

Return type:

G_E_Phenotyping

property gpmod: GenomicModel#

Genomic prediction model.

property nenv: Integral#

Number of environments.

property nrep: ndarray#

Number of replications per environment.

phenotype(pgmat, miscout=None, **kwargs)[source]#

Phenotype a set of genotypes using a genomic prediction model.

Parameters:
  • pgmat (PhasedGenotypeMatrix) – Genomes of the individuals to phenotype.

  • miscout (dict, None, default = None) – Pointer to a dictionary for miscellaneous user defined output. If dict, write to dict (may overwrite previously defined fields). If None, user defined output is not calculated or stored.

  • kwargs (dict) – Additional keyword arguments.

Returns:

out – A pandas.DataFrame containing phenotypes for individuals.

Return type:

pandas.DataFrame

property rng: Generator | RandomState#

Random number generator.

set_H2(H2, pgmat, **kwargs)[source]#

Set the broad sense heritability for environments.

Parameters:
  • H2 (float, numpy.ndarray) – Broad sense heritability.

  • pgmat (PhasedGenotypeMatrix) – Founder genotypes.

  • kwargs (dict) – Additional keyword arguments

Return type:

None

set_h2(h2, pgmat, **kwargs)[source]#

Set the narrow sense heritability for environments.

Parameters:
  • h2 (float, numpy.ndarray) – Narrow sense heritability.

  • pgmat (PhasedGenotypeMatrix) – Founder genotypes.

  • kwargs (dict) – Additional keyword arguments

Return type:

None

to_hdf5(filename, groupname=None, overwrite=True)[source]#

Write a G_E_Phenotyping object to an HDF5 file.

Parameters:
  • filename (str, Path, h5py.File) – If str or Path, an HDF5 file name to which to write. File is closed after writing. If h5py.File, an already opened HDF5 file to which to write. File remains open after writing.

  • groupname (str, None) – If str, an HDF5 group name under which object data is stored. If None, object is written to the base HDF5 group.

  • overwrite (bool) – Whether to overwrite values in an HDF5 file if a field already exists.

Return type:

None

property var_env: ndarray#

Variance across environments.

property var_err: ndarray#

Error variance for each trait.

property var_rep: ndarray#

Variance across replicates.