Last updated: 2025-07-29
Checks: 6 1
Knit directory:
Importance-of-markers-for-QTL-detection-by-machine-learning-methods/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of
the R Markdown file created these results, you’ll want to first commit
it to the Git repo. If you’re still working on the analysis, you can
ignore this warning. When you’re finished, you can run
wflow_publish
to commit the R Markdown file and build the
HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20221222)
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 job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
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 558710b. 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:
Ignored files:
Ignored: .Rproj.user/
Ignored: analysis/figure/
Ignored: output/imp.tot.RData
Ignored: output/lddecay.tiff
Ignored: output/mod.rda
Unstaged changes:
Modified: analysis/GWAS.Rmd
Modified: analysis/gwas-GLM.Rmd
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/gwas-GLM.Rmd
) and HTML
(docs/gwas-GLM.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 | fe9e0c4 | WevertonGomesCosta | 2025-07-28 | add gwas-glm .rmd and .html |
html | fe9e0c4 | WevertonGomesCosta | 2025-07-28 | add gwas-glm .rmd and .html |
Rmd | 3e6c8e6 | WevertonGomesCosta | 2025-03-25 | add gwas-GLM.rmd |
Rmd | 5889c62 | WevertonGomesCosta | 2025-03-25 | add gwas-GLM.Rmd |
Nesse script, vamos realizar uma análise de associação genômica ampla (GWAS) utilizando o modelo linear generalizado (GLM) com o pacote GAPIT. O objetivo é identificar marcadores genéticos associados a características fenotípicas específicas.
#Vamos carregar os pacotes necessários para a análise. Se o pacote GAPIT não
#estiver instalado, você pode instalá-lo usando o comando abaixo (descomente a
#linha de instalação):
#install.packages("devtools")
#library(devtools)
#devtools::install_github("jiabowang/GAPIT", force=TRUE)
library(GAPIT)
library(tidyverse)
Os dados utilizados neste exemplo são simulados pelo software GENES e
foram gerados para fins de análise. Eles incluem informações
fenotípicas, genotípicas e um mapa genético. Para executar este script,
certifique-se de que os arquivos necessários estejam disponíveis no
diretório data/
:
# Carregando os dados fenotípicos, genotípicos e o mapa genético
pheno <- read.table("data/FEN.txt")[, c(1:5, 9:13)]
head(pheno)
V1 V2 V3 V4 V5 V9 V10 V11
1 105.4142 105.1269 104.8504 104.5909 104.7855 104.4782 105.1641 104.5857
2 99.4438 101.3238 102.9940 104.0350 103.8966 100.5017 103.5687 103.0709
3 97.7980 102.0987 105.3410 104.1339 104.2567 96.5674 102.5507 103.5267
4 101.2721 104.0863 105.0626 103.6401 104.2028 99.9238 102.3068 103.8091
5 104.9151 104.0448 103.1747 103.7256 104.9352 103.9866 102.9234 103.8994
6 100.9011 101.6252 102.8092 103.1760 103.8143 101.4402 101.3351 102.7348
V12 V13
1 104.7281 104.8005
2 103.6733 104.0019
3 103.8272 104.2087
4 103.2741 104.1401
5 103.8341 104.0395
6 102.9343 103.2702
# Ajustando os nomes das colunas para garantir que a coluna ID seja a primeira
geno <- read.table("data/GEN.txt") + 1
geno[1:5,1:5]
V1 V2 V3 V4 V5
1 1 1 1 1 1
2 1 1 1 1 1
3 1 1 1 1 1
4 0 0 0 0 0
5 1 1 1 1 1
# Carregando o mapa genético
GM <- readRDS("data/map.rds")
GM$GL <- as.numeric(GM$GL)
GM$marker <- as.character(GM$marker)
head(GM)
marker GL Tamanho
1 1 1 0.0
2 2 1 0.5
3 3 1 1.0
4 4 1 1.5
5 5 1 2.0
6 6 1 2.5
Para garantir que os dados estejam no formato correto para a análise, precisamos ajustar as colunas de ID e marcador nos data frames de genótipo e mapa genético. A coluna ID deve ser a primeira no data frame de genótipos, e a coluna marker deve ser a primeira no data frame do mapa genético.
Vamos ajustar o modelo GLM para cada um dos fenótipos disponíveis no conjunto de dados. O loop abaixo itera sobre os fenótipos e executa a análise GWAS para cada um deles, salvando os resultados em arquivos separados.
O pacote GAPIT é utilizado para realizar a análise de associação, especificando o modelo GLM e os dados genotípicos e fenotípicos. O modelo GLM é adequado para dados fenotípicos contínuos e pode ser utilizado para identificar associações entre marcadores genéticos e características fenotípicas
# Definindo os índices dos genótipos e fenótipos
traits <- 1:ncol(pheno)
# Ajuste da GWAS e coleta dos resultados
for (j in 1:10) {
# Atualizando Y para garantir que a coluna ID seja a primeira
Y <- pheno[j]
Y$ID <- rownames(pheno)
Y <- Y[, c("ID", names(Y)[names(Y) != "ID"])]
modelo <- GAPIT(
Y = Y,
GD = GD,
GM = GM,
model = "GLM",
file.output = T,
file.path = "output/"
)
}
Após a execução do modelo GLM, os resultados são salvos em arquivos CSV. Vamos ler esses arquivos, adicionar informações sobre o método e a variável analisada, e consolidar os resultados em um único data frame.
results_gwas <-
list.files(path = "output/",
pattern = "GAPIT.Association.GWAS_Results",
full.names = TRUE)
results_gwas <- map(results_gwas, function(i) {
gwas <- read.csv(i, header = T, sep = ",")
gwas$variable <- str_split_i(i, "[.]", -2)
gwas$method <- "GLM"
gwas
})
results_gwas <- bind_rows(results_gwas)
save(results_gwas, file = "output/results_gwas.rda")
Após a execução do código acima, você terá um data frame
results_gwas
contendo os resultados da análise GWAS para
cada fenótipo, com as colunas adicionais variable
e
method
indicando a variável analisada e o método
utilizado.
O próximo passo é analisar esses resultados para verificar quais métodos apresentaram melhor desempenho na identificação de marcadores associados aos fenótipos estudados. Isso será feita no próximo script, onde compararemos os resultados do GLM com os resultados obtidos por métodos de machine learning GWAS.html.
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8 LC_CTYPE=Portuguese_Brazil.utf8
[3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.utf8
time zone: America/Sao_Paulo
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.9.4 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4
[5] purrr_1.1.0 readr_2.1.5 tidyr_1.3.1 tibble_3.3.0
[9] ggplot2_3.5.2 tidyverse_2.0.0 GAPIT_3.5.0
loaded via a namespace (and not attached):
[1] sass_0.4.10 generics_0.1.4 stringi_1.8.7 hms_1.1.3
[5] digest_0.6.37 magrittr_2.0.3 timechange_0.3.0 evaluate_1.0.4
[9] grid_4.4.1 RColorBrewer_1.1-3 fastmap_1.2.0 rprojroot_2.0.4
[13] workflowr_1.7.1 jsonlite_2.0.0 whisker_0.4.1 promises_1.3.3
[17] scales_1.4.0 jquerylib_0.1.4 cli_3.6.5 rlang_1.1.6
[21] withr_3.0.2 cachem_1.1.0 yaml_2.3.10 tools_4.4.1
[25] tzdb_0.5.0 httpuv_1.6.16 vctrs_0.6.5 R6_2.6.1
[29] lifecycle_1.0.4 git2r_0.36.2 fs_1.6.6 pkgconfig_2.0.3
[33] pillar_1.11.0 bslib_0.9.0 later_1.4.2 gtable_0.3.6
[37] glue_1.8.0 Rcpp_1.1.0 xfun_0.52 tidyselect_1.2.1
[41] rstudioapi_0.17.1 knitr_1.50 farver_2.1.2 htmltools_0.5.8.1
[45] rmarkdown_2.29 compiler_4.4.1