Skip to content

Commit a5f2543

Browse files
Update v61_pedigree_model_fitting.Rmd
1 parent 44463d2 commit a5f2543

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

vignettes/articles/v61_pedigree_model_fitting.Rmd

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ multi_model_ce <- buildPedigreeMx(
186186
```{r, include = FALSE}
187187
fitted_multi_ace <- NULL # ensure variable exists for later use
188188
fitted_multi_mace <- NULL # ensure variable exists for later use
189+
fitted_multi_ce <- NULL # ensure variable exists for later use
189190
```
190191
```{r, eval = run_models}
191192
fitted_multi_ace <- mxRun(multi_model_ace,
@@ -199,15 +200,33 @@ fitted_multi_ce <- mxRun(multi_model_ce, intervals= TRUE)
199200
saveRDS(fitted_multi_ce, "inst/extdata/fitted_multi_ce.rds")
200201
```
201202

203+
```{r, eval = FALSE, include = FALSE}
204+
tt_ace <- mxTryHard(fitted_multi_ace, intervals = TRUE)
205+
saveRDS(tt_ace, "inst/extdata/fitted_multi_ace_tryhard.rds")
206+
tt_mace <- mxTryHard(fitted_multi_mace, intervals = TRUE)
207+
saveRDS(tt_mace, "inst/extdata/fitted_multi_mace_tryhard.rds")
208+
209+
tt_ce <- mxTryHard(fitted_multi_ce, intervals = TRUE)
210+
saveRDS(tt_ce, "inst/extdata/fitted_multi_ce_tryhard.rds")
211+
```
212+
213+
Note that fitting these models can take some time, especially with many families and large pedigrees. The `mxTryHard()` function can be used to attempt to find better-fitting solutions if the initial optimization does not converge well. In practice, you may want to experiment with different starting values or optimization settings to improve convergence.
214+
202215
```
203216
fitted_multi_ace <- mxRun(multi_model_ace)
204217
fitted_multi_mace <- mxRun(multi_model_mace)
218+
fitted_multi_ce <- mxRun(multi_model_ce)
205219
```
206-
```{r, include = FALSE, eval = file.exists(rds_file_ace) && !run_models && file.exists(rds_file_mace)}
220+
221+
```{r, include = FALSE, eval = file.exists(rds_file_ace) && !run_models && file.exists(rds_file_mace) && file.exists(file.path(rds_dir, "fitted_multi_ce.rds"))}
207222
fitted_multi_ace <- readRDS(rds_file_ace)
208223
fitted_multi_mace <- readRDS(rds_file_mace)
209224
fitted_multi_ce <- readRDS(file.path(rds_dir, "fitted_multi_ce.rds"))
210225
```
226+
227+
228+
229+
211230
```{r, eval = has_openmx && !is.null(fitted_multi_ace)}
212231
summary(fitted_multi_ace,verbose=T)
213232
summary(fitted_multi_ace)$CI
@@ -246,17 +265,20 @@ cat("Common nuclear (Vcn):", fitted_multi_mace$ModelOne$Vcn$values/total_var_ma
246265
cat("Mitochondrial (Vmt):", fitted_multi_mace$ModelOne$Vmt$values/total_var_mace, "\n")
247266
cat("Unique environ. (Ver):", fitted_multi_mace$ModelOne$Ver$values/total_var_mace, "\n")
248267
```
249-
Now we can compare the ACE and MACE models to see if including the mitochondrial component changes our estimates of heritability and environmental contributions. This can provide insights into the role of mitochondrial inheritance in the trait of interest (LRS) in these squirrels.
268+
Now we can compare the ACE and MACE models to see if including the mitochondrial component changes our estimates of heritability and environmental contributions. This can provide insights into the role of mitochondrial inheritance in the trait of interest (LRS) in these squirrels. In the original paper, the authors found that a maternally inherited component (which could be due to mitochondria or maternal effects) explained a significant portion of the variance in LRS,.
250269

251-
```{r, eval = has_openmx && !is.null(fitted_multi_ace) && !is.null(fitted_multi_mace)}
270+
```{r, eval = has_openmx && !is.null(fitted_multi_ace) && !is.null(fitted_multi_mace) && !is.null(fitted_multi_ce)}
252271
253272
mxCompare(fitted_multi_mace, fitted_multi_ace)
273+
mxCompare(fitted_multi_ace, fitted_multi_ce)
254274
255-
tt_ace <- mxTryHard(fitted_multi_ace, intervals = TRUE)
256-
saveRDS(tt_ace, "inst/extdata/fitted_multi_ace_tryhard.rds")
257-
tt_mace <- mxTryHard(fitted_multi_mace, intervals = TRUE)
258-
saveRDS(tt_mace, "inst/extdata/fitted_multi_mace_tryhard.rds")
259275
260-
tt_ce <- mxTryHard(fitted_multi_ce, intervals = TRUE)
261-
saveRDS(tt_ce, "inst/extdata/fitted_multi_ce_tryhard.rds")
262276
```
277+
278+
However, as you can see when we compare the ACE and MACE models, the inclusion of the mitochondrial component does not substantially change the estimates of additive genetic and common nuclear environmental variance, suggesting that the mitochondrial component may not be a major contributor to LRS in this dataset.
279+
280+
281+
282+
283+
284+

0 commit comments

Comments
 (0)