@@ -49,13 +49,11 @@ def _accumulate_individual_values(
4949class _GeneticValue :
5050 """GeneticValue class to compute genetic values of individuals.
5151
52- Parameters
53- ----------
54- ts : tskit.TreeSequence
55- Tree sequence data with mutation
56- trait_df : pandas.DataFrame
57- Dataframe that includes causal site ID, causal allele, simulated effect
58- size, and trait ID.
52+ :param ts: Tree sequence data with mutation
53+ :type ts: tskit.TreeSequence
54+ :param trait_df: Dataframe that includes causal site ID, causal allele,
55+ simulated effect size, and trait ID.
56+ :type trait_df: pandas.DataFrame
5957 """
6058
6159 def __init__ (self , ts , trait_df ):
@@ -102,10 +100,8 @@ def _individual_genetic_values(self, tree, site, causal_allele, effect_size):
102100 def _run (self ):
103101 """Computes genetic values of individuals.
104102
105- Returns
106- -------
107- pandas.DataFrame
108- Dataframe with genetic value, individual ID, and trait ID.
103+ :returns: Dataframe with genetic value, individual ID, and trait ID.
104+ :rtype: pandas.DataFrame
109105 """
110106
111107 num_ind = self .ts .num_individuals
@@ -139,56 +135,53 @@ def genetic_value(ts, trait_df):
139135 """
140136 Obtains genetic value from a trait dataframe.
141137
142- Parameters
143- ----------
144- ts : tskit.TreeSequence
145- The tree sequence data that will be used in the quantitative trait
138+ :param ts: The tree sequence data that will be used in the quantitative trait
146139 simulation.
147- trait_df : pandas.DataFrame
148- Trait dataframe.
149-
150- Returns
151- -------
152- pandas.DataFrame
153- Pandas dataframe that includes genetic value of individuals in the
140+ :type ts: tskit.TreeSequence
141+ :param trait_df: Trait dataframe.
142+ :type trait_df: pandas.DataFrame
143+ :returns: Pandas dataframe that includes genetic value of individuals in the
154144 tree sequence.
145+ :rtype: pandas.DataFrame
146+
147+ .. seealso::
148+ :func:`trait_model` Return a trait model, which can be used as `model` input.
149+
150+ :func:`sim_trait` Return a trait dataframe, which can be used as a
151+ `trait_df` input.
155152
156- See Also
157- --------
158- trait_model : Return a trait model, which can be used as `model` input.
159- sim_trait : Return a trait dataframe, whch can be used as a `trait_df` input.
160- sim_env : Genetic value dataframe output can be used as an input to simulate
161- environmental noise.
153+ :func:`sim_env` Genetic value dataframe output can be used as an input
154+ to simulate environmental noise.
162155
163- Notes
164- -----
165- The `trait_df` input has some requirements that will be noted below.
156+ .. note::
157+ The `trait_df` input has some requirements that will be noted below.
166158
167- 1. Columns
159+ 1. Columns
168160
169- The following columns must be included in `trait_df`:
161+ The following columns must be included in `trait_df`:
170162
171- * **site_id**: Site IDs that have causal allele.
172- * **effect_size**: Simulated effect size of causal allele.
173- * **causal_allele**: Causal allele.
174- * **trait_id**: Trait ID.
163+ * **site_id**: Site IDs that have causal allele.
164+ * **effect_size**: Simulated effect size of causal allele.
165+ * **causal_allele**: Causal allele.
166+ * **trait_id**: Trait ID.
175167
176- 2. Data requirements
168+ 2. Data requirements
177169
178- * Site IDs in **site_id** column must be sorted in an ascending order. Please
179- refer to :py:meth:`pandas.DataFrame.sort_values` for details on sorting
180- values in a :class:`pandas.DataFrame`.
170+ * Site IDs in **site_id** column must be sorted in an ascending order. Please
171+ refer to :py:meth:`pandas.DataFrame.sort_values` for details on sorting
172+ values in a :class:`pandas.DataFrame`.
181173
182- * Trait IDs in **trait_id** column must start from zero and be consecutive.
174+ * Trait IDs in **trait_id** column must start from zero and be consecutive.
183175
184- The genetic value dataframe contains the following columns:
176+ The genetic value dataframe contains the following columns:
185177
186- * **trait_id**: Trait ID.
187- * **individual_id**: Individual ID inside the tree sequence input.
188- * **genetic_value**: Genetic values that are obtained from the trait dataframe.
178+ * **trait_id**: Trait ID.
179+ * **individual_id**: Individual ID inside the tree sequence input.
180+ * **genetic_value**: Genetic values that are obtained from the trait
181+ dataframe.
182+
183+ .. rubric:: Examples
189184
190- Examples
191- --------
192185 See :ref:`genetic_value` for worked examples.
193186 """
194187
@@ -217,44 +210,34 @@ def genetic_value(ts, trait_df):
217210def normalise_genetic_value (genetic_df , mean = 0 , var = 1 , ddof = 1 ):
218211 """Normalise genetic value dataframe.
219212
220- Parameters
221- ----------
222- genetic_df : pandas.DataFrame
223- Genetic value dataframe.
224- mean : float, default 0
225- Mean of the resulting genetic value.
226- var : float, default 1
227- Variance of the resulting genetic value.
228- ddof : int, default 1
229- Delta degrees of freedom. The divisor used in computing the variance
213+ :param genetic_df: Genetic value dataframe.
214+ :type genetic_df: pandas.DataFrame
215+ :param mean: Mean of the resulting genetic value.
216+ :type mean: float
217+ :param var: Variance of the resulting genetic value.
218+ :type var: float
219+ :param ddof: Delta degrees of freedom. The divisor used in computing the variance
230220 is N - ddof, where N represents the number of elements.
221+ :type ddof: int
222+ :returns: Dataframe with normalised genetic value.
223+ :rtype: pandas.DataFrame
224+ :raises ValueError: If `var` <= 0.
231225
232- Returns
233- -------
234- pandas.DataFrame
235- Dataframe with normalised genetic value.
236-
237- Raises
238- ------
239- ValueError
240- If `var` <= 0.
226+ .. note::
227+ The following columns must be included in `genetic_df`:
241228
242- Notes
243- -----
244- The following columns must be included in `genetic_df`:
229+ * **trait_id**: Trait ID.
230+ * **individual_id**: Individual ID inside the tree sequence input.
231+ * **genetic_value**: Simulated genetic values.
245232
246- * **trait_id**: Trait ID.
247- * **individual_id**: Individual ID inside the tree sequence input.
248- * **genetic_value**: Simulated genetic values.
233+ The dataframe output has the following columns:
249234
250- The dataframe output has the following columns:
235+ * **trait_id**: Trait ID.
236+ * **individual_id**: Individual ID inside the tree sequence input.
237+ * **genetic_value**: Normalised genetic values.
251238
252- * **trait_id**: Trait ID.
253- * **individual_id**: Individual ID inside the tree sequence input.
254- * **genetic_value**: Normalised genetic values.
239+ .. rubric:: Examples
255240
256- Examples
257- --------
258241 See :ref:`normalise_genetic_value` section for worked examples.
259242 """
260243 if var <= 0 :
0 commit comments