# ---- R Script for qpAdm Analysis for Modern Italian populations using aDNA ----
# 1. Define Paths for Dataset
prefix <- "D:\\Bioinformatics\\01_Admixtools_Dataset\\v54.1.p1_HO_Jovialis_Plink\\v54.1.p1_HO_Jovialis"
my_f2_dir <- "D:\\Bioinformatics\\my_f2_dir_Jovialis"
# 2. Load Necessary Libraries
# Ensure 'admixtools' and 'tidyverse' are installed
# install.packages("tidyverse")
# Follow the admixtools installation guide from its repository or CRAN.
library(admixtools)
library(tidyverse)
# 3. Define Populations
target <- c('Jovialis')
left <- c('Steppe_EMBA', 'C_Italian_N', 'CHG_Iran_N')
right <- c('WHG', 'Ust_Ishim', 'Kostenki14', 'MA1_HG', 'Goyet', 'ElMiron', 'Vestonice16', 'Villabruna', 'EHG', 'Levant_N', 'Natufian', 'Mota', 'Anatolia_N')
# 4. Generate f2 Stats
mypops <- c(right, target, left)
extract_f2(prefix, my_f2_dir, pops = mypops, overwrite = TRUE, maxmiss = 1)
f2_blocks <- f2_from_precomp(my_f2_dir, pops = mypops, afprod = TRUE)
# 5. Run the Model
results <- qpadm(prefix, left, right, target, allsnps = TRUE)
results$weights
results$popdrop
# ---- End of Script ----
# Additional Notes:
# - Jovialis and Italian_South.HO samples are modeled with 'C_Italian_N'
# - 'Italian_North.HO', 'TSI.DG' are modeled with 'C_Italian_ChL'
# - Italian_South.HO is divided into 'Italian_South_ITS4', 'Italian_South_ITS5', 'Italian_South_ITS7'