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:
PhenotypingProtocolClass 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 broadcastnrepto an array of shape(nenv,)Ifnumpy.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_envto an array of shape(ntrait,)Ifnumpy.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_repto an array of shape(ntrait,)Ifnumpy.ndarray, then must be of shape(ntrait,)var_err (numeric, numpy.ndarray) –
Error variance parameter.
If numeric, then broadcast
var_errto 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
Make a shallow copy of the
G_E_Phenotypingobject.Make a deep copy of the
G_E_Phenotypingobject.Read a
G_E_Phenotypingfrom an HDF5 file.Phenotype a set of genotypes using a genomic prediction model.
Set the broad sense heritability for environments.
Set the narrow sense heritability for environments.
Write a
G_E_Phenotypingobject to an HDF5 file.Attributes
Genomic prediction model.
Number of environments.
Number of replications per environment.
Random number generator.
Variance across environments.
Error variance for each trait.
Variance across replicates.
- copy()[source]#
Make a shallow copy of the
G_E_Phenotypingobject.- Returns:
out – A shallow copy of the
G_E_Phenotypingobject.- Return type:
- deepcopy(memo=None)[source]#
Make a deep copy of the
G_E_Phenotypingobject.- Parameters:
memo (dict, None) – An optional dictionary of memo metadata.
- Returns:
out – A deep copy of the
G_E_Phenotypingobject.- Return type:
- classmethod from_hdf5(filename, groupname=None, gpmod=None)[source]#
Read a
G_E_Phenotypingfrom an HDF5 file.- Parameters:
filename (str, Path, h5py.File) – If
strorPath, an HDF5 file name from which to read. File is closed after reading. Ifh5py.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 whichG_E_Phenotypingdata is stored. IfNone,G_E_Phenotypingis read from base HDF5 group.gpmod (GenomicModel) – A genomic model to bind to the
G_E_Phenotypingprotocol. This will be eliminated when a better storage mechanism is available.
- Returns:
out – An
G_E_Phenotypingread from an HDF5 file.- Return type:
- 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). IfNone, 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_Phenotypingobject to an HDF5 file.- Parameters:
filename (str, Path, h5py.File) – If
strorPath, an HDF5 file name to which to write. File is closed after writing. Ifh5py.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. IfNone, 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.