**Last updated:** 2023-01-10

**Checks:** 7
0

**Knit directory:** `dgrp-starve/`

This reproducible R Markdown
analysis was created with workflowr (version
1.7.0). The *Checks* tab describes the reproducibility checks
that were applied when the results were created. The *Past
versions* tab lists the development history.

`set.seed(20221101)`

was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version
e2609b9.
See the *Past versions* tab to see a history of the changes made
to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use `wflow_publish`

or
`wflow_git_commit`

). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:

```
Untracked files:
Untracked: code/aaaTest
Untracked: code/analysisSR.R
Untracked: code/geneGO.R
Untracked: code/multiPrep.R
Untracked: code/regress.81916.err
Untracked: code/regress.81916.out
Untracked: code/regress.81918.err
Untracked: code/regress.81918.out
Untracked: code/regress.R
Untracked: code/regress.sbatch
Untracked: code/regressF.81919.err
Untracked: code/regressF.81919.out
Untracked: code/regressF.R
Untracked: code/regressF.sbatch
Untracked: code/snpGene.77509.err
Untracked: code/snpGene.77509.out
Untracked: code/snpGene.77515.err
Untracked: code/snpGene.77515.out
Untracked: code/snpGene.sbatch
Untracked: data/eQTL_traits_females.csv
Untracked: data/eQTL_traits_males.csv
Untracked: data/fMeans.txt
Untracked: data/fRegress.txt
Untracked: data/goGroups.txt
Untracked: data/mMeans.txt
Untracked: data/mPart.txt
Untracked: data/mRegress.txt
Untracked: data/starve-f.txt
Untracked: data/starve-m.txt
Untracked: data/xp-f.txt
Untracked: data/xp-m.txt
Untracked: figure/
Untracked: lmm.R
Untracked: qqdum.R
Untracked: scoreAnalysisMulticomp.R
Untracked: temp.Rmd
Unstaged changes:
Deleted: analysis/database.Rmd
Deleted: analysis/scripts.Rmd
Modified: code/baseScript-lineComp.R
Modified: code/fourLinePrep.R
```

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.

These are the previous versions of the repository in which changes were
made to the R Markdown (`analysis/multiReg.Rmd`

) and HTML
(`docs/multiReg.html`

) files. If you’ve configured a remote
Git repository (see `?wflow_git_remote`

), click on the
hyperlinks in the table below to view the files as they were in that
past version.

File | Version | Author | Date | Message |
---|---|---|---|---|

Rmd | e2609b9 | nklimko | 2023-01-10 | wflow_publish("analysis/multiReg.Rmd") |

html | 67ec408 | nklimko | 2023-01-10 | Build site. |

Rmd | 3900dc4 | nklimko | 2023-01-10 | wflow_publish("analysis/multiReg.Rmd") |

html | 736d53e | nklimko | 2023-01-10 | Build site. |

Rmd | 5cc6e18 | nklimko | 2023-01-10 | wflow_publish("analysis/*") |

html | 51648b6 | nklimko | 2023-01-10 | Build site. |

Rmd | 3a150c2 | nklimko | 2023-01-10 | wflow_publish("analysis/multiReg.Rmd") |

html | 9e86f56 | nklimko | 2023-01-08 | Build site. |

html | bb13ec2 | nklimko | 2022-12-21 | Build site. |

Rmd | 4a73a00 | nklimko | 2022-12-21 | wflow_publish("analysis/multiReg.Rmd") |

html | e9e8b44 | nklimko | 2022-12-21 | Build site. |

Rmd | 30960d8 | nklimko | 2022-12-21 | wflow_publish("analysis/multiReg.Rmd") |

html | e81425f | nklimko | 2022-12-21 | Build site. |

Rmd | 7270330 | nklimko | 2022-12-21 | wflow_publish("analysis/multiReg.Rmd") |

html | 497fd4e | nklimko | 2022-12-21 | Build site. |

Rmd | 790533a | nklimko | 2022-12-21 | wflow_publish("analysis/multiReg.Rmd") |

html | 177257f | nklimko | 2022-12-21 | Build site. |

Rmd | 7b1c552 | nklimko | 2022-12-21 | wflow_publish("analysis/multiReg.Rmd") |

Multiple regression is the process of determining the coefficients of a model with each coefficient corresponding to the effect of one explanatory variable.

With Genomic Reduced Maximum Likelihood, or GREML, a design matrix is calculated using a Genomic Relationship matrix and a vector of 1s to find the intercepts.

Multiplying the vector for starvation resistance by the inverse of the design matrix solves for the coefficients of the multivariate model. The residuals must also be subtracted and consitute the random effect of the mixed model.

For each data set, the expression data matrix(line x gene) and the starvation resistance vector(line x 1) were taken from prior lab data. From the PCA Project, a dataframe containing line, starvation resistancec, and expression data per gene was repurposed for this model.

The Transcriptomic Relation Matrix was calculated using the cross product of a scaled expression matrix and multiplied by the inverse of the number of columns.

```
#read in expression data
fMeans <- fread("data/fMeans.txt")
#create matrix of only gene expression, trims line and starvation
X <- as.matrix(fMeans[,3:11340])
rownames(X) <- fMeans[,line]
y <- fMeans[,starvation]
###Create model for covariates to adjust for (only an intercept in our case)
mu <- rep(1, length(y))
###Compute transcriptomic relationship matrix (accounts for structure based on expression levels)
W <- scale(X)
TRM <- tcrossprod(W)/ncol(W)
###Fit mixed model
fit <- greml(y = y, X = mu, GRM = list(TRM), verbose = TRUE, maxit = 100)
```

```
[1] "Iteration:" "1" "Theta:" "6.31" "6.11"
[1] "Iteration:" "2" "Theta:" "12.61" "11.49"
[1] "Iteration:" "3" "Theta:" "25.16" "20.29"
[1] "Iteration:" "4" "Theta:" "49.6" "31.59"
[1] "Iteration:" "5" "Theta:" "93.98" "38.09"
[1] "Iteration:" "6" "Theta:" "159.37" "26.87"
[1] "Iteration:" "7" "Theta:" "217.58" "4.08"
[1] "Iteration:" "8" "Theta:" "238.43" "0"
[1] "Iteration:" "9" "Theta:" "240.78" "0"
[1] "Iteration:" "10" "Theta:" "240.8" "0"
[1] "Iteration:" "11" "Theta:" "240.78" "0"
[1] "Iteration:" "12" "Theta:" "240.8" "0"
[1] "Iteration:" "13" "Theta:" "240.78" "0"
[1] "Iteration:" "14" "Theta:" "240.81" "0"
[1] "Iteration:" "15" "Theta:" "240.8" "0"
[1] "Iteration:" "16" "Theta:" "240.81" "0"
[1] "Iteration:" "17" "Theta:" "240.81" "0"
[1] "Iteration:" "18" "Theta:" "240.8" "0"
[1] "Iteration:" "19" "Theta:" "240.82" "0"
[1] "Iteration:" "20" "Theta:" "240.8" "0"
[1] "Iteration:" "21" "Theta:" "240.8" "0"
[1] "Iteration:" "22" "Theta:" "240.81" "0"
[1] "Iteration:" "23" "Theta:" "240.83" "0"
[1] "Iteration:" "24" "Theta:" "240.79" "0"
[1] "Iteration:" "25" "Theta:" "240.8" "0"
[1] "Iteration:" "26" "Theta:" "240.82" "0"
[1] "Iteration:" "27" "Theta:" "240.81" "0"
[1] "Iteration:" "28" "Theta:" "240.81" "0"
[1] "Iteration:" "29" "Theta:" "240.79" "0"
[1] "Iteration:" "30" "Theta:" "240.81" "0"
[1] "Iteration:" "31" "Theta:" "240.8" "0"
[1] "Iteration:" "32" "Theta:" "240.81" "0"
[1] "Iteration:" "33" "Theta:" "240.8" "0"
[1] "Iteration:" "34" "Theta:" "240.79" "0"
[1] "Iteration:" "35" "Theta:" "240.82" "0"
[1] "Iteration:" "36" "Theta:" "240.8" "0"
[1] "Iteration:" "37" "Theta:" "240.82" "0"
[1] "Iteration:" "38" "Theta:" "240.81" "0"
[1] "Iteration:" "39" "Theta:" "240.81" "0"
[1] "Iteration:" "40" "Theta:" "240.81" "0"
[1] "Iteration:" "41" "Theta:" "240.79" "0"
[1] "Iteration:" "42" "Theta:" "240.8" "0"
[1] "Iteration:" "43" "Theta:" "240.8" "0"
[1] "Iteration:" "44" "Theta:" "240.82" "0"
[1] "Iteration:" "45" "Theta:" "240.83" "0"
[1] "Iteration:" "46" "Theta:" "240.79" "0"
[1] "Iteration:" "47" "Theta:" "240.82" "0"
[1] "Iteration:" "48" "Theta:" "240.8" "0"
[1] "Iteration:" "49" "Theta:" "240.79" "0"
[1] "Iteration:" "50" "Theta:" "240.8" "0"
[1] "Iteration:" "51" "Theta:" "240.81" "0"
[1] "Iteration:" "52" "Theta:" "240.8" "0"
[1] "Iteration:" "53" "Theta:" "240.81" "0"
[1] "Iteration:" "54" "Theta:" "240.81" "0"
[1] "Iteration:" "55" "Theta:" "240.77" "0"
[1] "Iteration:" "56" "Theta:" "240.79" "0"
[1] "Iteration:" "57" "Theta:" "240.79" "0"
[1] "Iteration:" "58" "Theta:" "240.82" "0"
[1] "Iteration:" "59" "Theta:" "240.81" "0"
[1] "Iteration:" "60" "Theta:" "240.8" "0"
[1] "Iteration:" "61" "Theta:" "240.81" "0"
[1] "Iteration:" "62" "Theta:" "240.82" "0"
[1] "Iteration:" "63" "Theta:" "240.8" "0"
[1] "Iteration:" "64" "Theta:" "240.79" "0"
[1] "Iteration:" "65" "Theta:" "240.82" "0"
[1] "Iteration:" "66" "Theta:" "240.81" "0"
[1] "Iteration:" "67" "Theta:" "240.81" "0"
[1] "Iteration:" "68" "Theta:" "240.81" "0"
[1] "Iteration:" "69" "Theta:" "240.81" "0"
[1] "Iteration:" "70" "Theta:" "240.81" "0"
[1] "Iteration:" "71" "Theta:" "240.8" "0"
[1] "Iteration:" "72" "Theta:" "240.82" "0"
[1] "Iteration:" "73" "Theta:" "240.81" "0"
[1] "Iteration:" "74" "Theta:" "240.79" "0"
[1] "Iteration:" "75" "Theta:" "240.82" "0"
[1] "Iteration:" "76" "Theta:" "240.81" "0"
[1] "Iteration:" "77" "Theta:" "240.81" "0"
[1] "Iteration:" "78" "Theta:" "240.82" "0"
[1] "Iteration:" "79" "Theta:" "240.81" "0"
[1] "Iteration:" "80" "Theta:" "240.81" "0"
[1] "Iteration:" "81" "Theta:" "240.8" "0"
[1] "Iteration:" "82" "Theta:" "240.8" "0"
[1] "Iteration:" "83" "Theta:" "240.78" "0"
[1] "Iteration:" "84" "Theta:" "240.81" "0"
[1] "Iteration:" "85" "Theta:" "240.81" "0"
[1] "Iteration:" "86" "Theta:" "240.8" "0"
[1] "Iteration:" "87" "Theta:" "240.8" "0"
[1] "Iteration:" "88" "Theta:" "240.81" "0"
[1] "Iteration:" "89" "Theta:" "240.82" "0"
[1] "Iteration:" "90" "Theta:" "240.81" "0"
[1] "Iteration:" "91" "Theta:" "240.81" "0"
[1] "Iteration:" "92" "Theta:" "240.81" "0"
[1] "Iteration:" "93" "Theta:" "240.79" "0"
[1] "Iteration:" "94" "Theta:" "240.81" "0"
[1] "Iteration:" "95" "Theta:" "240.81" "0"
[1] "Iteration:" "96" "Theta:" "240.8" "0"
[1] "Iteration:" "97" "Theta:" "240.82" "0"
[1] "Iteration:" "98" "Theta:" "240.82" "0"
[1] "Iteration:" "99" "Theta:" "240.82" "0"
[1] "Iteration:" "100" "Theta:" "240.81" "0"
```

```
stat <- glma(fit = fit, W = W)
#qqplot
qq(stat[,4], main="Female Gene p-values")
```

```
#read in expression data
mMeans <- fread("data/mMeans.txt")
#create matrix of only gene expression, trims line and starvation
X <- as.matrix(mMeans[,3:13577])
rownames(X) <- mMeans[,line]
y <- mMeans[,starvation]
###Create model for covariates to adjust for (only an intercept in our case)
mu <- rep(1, length(y))
###Compute transcriptomic relationship matrix (accounts for structure based on expression levels)
W <- scale(X)
TRM <- tcrossprod(W)/ncol(W)
###Fit mixed model
fit <- greml(y = y, X = mu, GRM = list(TRM), verbose = TRUE, maxit = 100)
```

```
[1] "Iteration:" "1" "Theta:" "4.69" "4.49"
[1] "Iteration:" "2" "Theta:" "9.33" "8.18"
[1] "Iteration:" "3" "Theta:" "18.37" "13.58"
[1] "Iteration:" "4" "Theta:" "35.17" "18.65"
[1] "Iteration:" "5" "Theta:" "62.48" "17.2"
[1] "Iteration:" "6" "Theta:" "94.45" "5.5"
[1] "Iteration:" "7" "Theta:" "115.08" "0"
[1] "Iteration:" "8" "Theta:" "121.35" "0"
[1] "Iteration:" "9" "Theta:" "121.71" "0"
[1] "Iteration:" "10" "Theta:" "121.7" "0"
[1] "Iteration:" "11" "Theta:" "121.71" "0"
[1] "Iteration:" "12" "Theta:" "121.71" "0"
[1] "Iteration:" "13" "Theta:" "121.72" "0"
[1] "Iteration:" "14" "Theta:" "121.71" "0"
[1] "Iteration:" "15" "Theta:" "121.71" "0"
[1] "Iteration:" "16" "Theta:" "121.71" "0"
[1] "Iteration:" "17" "Theta:" "121.71" "0"
[1] "Iteration:" "18" "Theta:" "121.7" "0"
[1] "Iteration:" "19" "Theta:" "121.71" "0"
[1] "Iteration:" "20" "Theta:" "121.71" "0"
[1] "Iteration:" "21" "Theta:" "121.7" "0"
[1] "Iteration:" "22" "Theta:" "121.71" "0"
[1] "Iteration:" "23" "Theta:" "121.71" "0"
[1] "Iteration:" "24" "Theta:" "121.71" "0"
[1] "Iteration:" "25" "Theta:" "121.7" "0"
[1] "Iteration:" "26" "Theta:" "121.7" "0"
[1] "Iteration:" "27" "Theta:" "121.71" "0"
[1] "Iteration:" "28" "Theta:" "121.71" "0"
[1] "Iteration:" "29" "Theta:" "121.7" "0"
[1] "Iteration:" "30" "Theta:" "121.71" "0"
[1] "Iteration:" "31" "Theta:" "121.7" "0"
[1] "Iteration:" "32" "Theta:" "121.71" "0"
[1] "Iteration:" "33" "Theta:" "121.71" "0"
[1] "Iteration:" "34" "Theta:" "121.71" "0"
[1] "Iteration:" "35" "Theta:" "121.7" "0"
[1] "Iteration:" "36" "Theta:" "121.7" "0"
[1] "Iteration:" "37" "Theta:" "121.7" "0"
[1] "Iteration:" "38" "Theta:" "121.71" "0"
[1] "Iteration:" "39" "Theta:" "121.7" "0"
[1] "Iteration:" "40" "Theta:" "121.71" "0"
[1] "Iteration:" "41" "Theta:" "121.71" "0"
[1] "Iteration:" "42" "Theta:" "121.7" "0"
[1] "Iteration:" "43" "Theta:" "121.71" "0"
[1] "Iteration:" "44" "Theta:" "121.7" "0"
[1] "Iteration:" "45" "Theta:" "121.71" "0"
[1] "Iteration:" "46" "Theta:" "121.71" "0"
[1] "Iteration:" "47" "Theta:" "121.7" "0"
[1] "Iteration:" "48" "Theta:" "121.71" "0"
[1] "Iteration:" "49" "Theta:" "121.71" "0"
[1] "Iteration:" "50" "Theta:" "121.7" "0"
[1] "Iteration:" "51" "Theta:" "121.71" "0"
[1] "Iteration:" "52" "Theta:" "121.7" "0"
[1] "Iteration:" "53" "Theta:" "121.72" "0"
[1] "Iteration:" "54" "Theta:" "121.72" "0"
[1] "Iteration:" "55" "Theta:" "121.71" "0"
[1] "Iteration:" "56" "Theta:" "121.7" "0"
[1] "Iteration:" "57" "Theta:" "121.71" "0"
[1] "Iteration:" "58" "Theta:" "121.71" "0"
[1] "Iteration:" "59" "Theta:" "121.7" "0"
[1] "Iteration:" "60" "Theta:" "121.71" "0"
[1] "Iteration:" "61" "Theta:" "121.71" "0"
[1] "Iteration:" "62" "Theta:" "121.71" "0"
[1] "Iteration:" "63" "Theta:" "121.71" "0"
[1] "Iteration:" "64" "Theta:" "121.71" "0"
[1] "Iteration:" "65" "Theta:" "121.71" "0"
[1] "Iteration:" "66" "Theta:" "121.7" "0"
[1] "Iteration:" "67" "Theta:" "121.71" "0"
[1] "Iteration:" "68" "Theta:" "121.71" "0"
[1] "Iteration:" "69" "Theta:" "121.7" "0"
[1] "Iteration:" "70" "Theta:" "121.71" "0"
[1] "Iteration:" "71" "Theta:" "121.71" "0"
[1] "Iteration:" "72" "Theta:" "121.71" "0"
[1] "Iteration:" "73" "Theta:" "121.71" "0"
[1] "Iteration:" "74" "Theta:" "121.71" "0"
[1] "Iteration:" "75" "Theta:" "121.71" "0"
[1] "Iteration:" "76" "Theta:" "121.71" "0"
[1] "Iteration:" "77" "Theta:" "121.71" "0"
[1] "Iteration:" "78" "Theta:" "121.71" "0"
[1] "Iteration:" "79" "Theta:" "121.71" "0"
[1] "Iteration:" "80" "Theta:" "121.7" "0"
[1] "Iteration:" "81" "Theta:" "121.69" "0"
[1] "Iteration:" "82" "Theta:" "121.71" "0"
[1] "Iteration:" "83" "Theta:" "121.7" "0"
[1] "Iteration:" "84" "Theta:" "121.71" "0"
[1] "Iteration:" "85" "Theta:" "121.7" "0"
[1] "Iteration:" "86" "Theta:" "121.71" "0"
[1] "Iteration:" "87" "Theta:" "121.7" "0"
[1] "Iteration:" "88" "Theta:" "121.7" "0"
[1] "Iteration:" "89" "Theta:" "121.71" "0"
[1] "Iteration:" "90" "Theta:" "121.71" "0"
[1] "Iteration:" "91" "Theta:" "121.71" "0"
[1] "Iteration:" "92" "Theta:" "121.71" "0"
[1] "Iteration:" "93" "Theta:" "121.7" "0"
[1] "Iteration:" "94" "Theta:" "121.7" "0"
[1] "Iteration:" "95" "Theta:" "121.71" "0"
[1] "Iteration:" "96" "Theta:" "121.71" "0"
[1] "Iteration:" "97" "Theta:" "121.71" "0"
[1] "Iteration:" "98" "Theta:" "121.71" "0"
[1] "Iteration:" "99" "Theta:" "121.71" "0"
[1] "Iteration:" "100" "Theta:" "121.7" "0"
```

```
stat <- glma(fit = fit, W = W)
#qqplot
qq(stat[,4], main="Male Gene p-values")
```

Multiple regression of both female and male structures show effects of the genetic architecture on the models as both systematically deviate from linearity.

QQ Plots from Linear Regression

`sessionInfo()`

```
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /opt/ohpc/pub/Software/openblas_0.3.10/lib/libopenblas_haswellp-r0.3.10.dev.so
locale:
[1] LC_CTYPE=en_US.utf-8 LC_NUMERIC=C
[3] LC_TIME=en_US.utf-8 LC_COLLATE=en_US.utf-8
[5] LC_MONETARY=en_US.utf-8 LC_MESSAGES=en_US.utf-8
[7] LC_PAPER=en_US.utf-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] qgg_1.1.1 qqman_0.1.8 cowplot_1.1.1 ggplot2_3.3.5
[5] data.table_1.14.2 dplyr_1.0.8 workflowr_1.7.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.8.3 lattice_0.20-45 getPass_0.2-2 ps_1.6.0
[5] assertthat_0.2.1 rprojroot_2.0.3 digest_0.6.29 utf8_1.2.2
[9] R6_2.5.1 MatrixModels_0.5-1 evaluate_0.15 coda_0.19-4
[13] highr_0.9 httr_1.4.2 pillar_1.7.0 rlang_1.0.4
[17] rstudioapi_0.13 SparseM_1.81 whisker_0.4 callr_3.7.0
[21] jquerylib_0.1.4 Matrix_1.5-3 rmarkdown_2.16 splines_4.0.3
[25] statmod_1.4.37 stringr_1.4.0 munsell_0.5.0 compiler_4.0.3
[29] httpuv_1.6.5 xfun_0.30 pkgconfig_2.0.3 mcmc_0.9-7
[33] htmltools_0.5.2 tidyselect_1.1.2 tibble_3.1.6 fansi_1.0.3
[37] calibrate_1.7.7 crayon_1.5.1 withr_2.5.0 later_1.3.0
[41] MASS_7.3-56 grid_4.0.3 jsonlite_1.8.0 gtable_0.3.0
[45] lifecycle_1.0.1 DBI_1.1.2 git2r_0.30.1 magrittr_2.0.3
[49] scales_1.2.0 cli_3.3.0 stringi_1.7.6 fs_1.5.2
[53] promises_1.2.0.1 bslib_0.3.1 ellipsis_0.3.2 generics_0.1.2
[57] vctrs_0.4.1 tools_4.0.3 glue_1.6.2 purrr_0.3.4
[61] parallel_4.0.3 processx_3.5.3 fastmap_1.1.0 survival_3.3-1
[65] yaml_2.3.5 colorspace_2.0-3 knitr_1.38 sass_0.4.1
[69] quantreg_5.94 MCMCpack_1.6-3
```