Hi Matt,
Based on the genlight object you sent me, below is an example of a GWAS analysis using GAPIT and a Manhattan plot.
Cheers,
Luis
devtools::install_github("mijangos81/GAPIT")
library(dartRverse)
library(GAPIT)
library(CMplot)
impute1 <- readRDS("impute1")
locKeep <- locNames(impute1)[which(impute1@position != 0)]
mapped <- gl.keep.loc(impute1, loc.list = locKeep)
mapped@chromosome <- mapped@other$loc.metrics$Chrom_Linum_lewisii_NDSU_LiLewi_1.0
mapped@chromosome <- as.factor(as.numeric(mapped@chromosome))
mapped$position <- mapped@other$loc.metrics$ChromPosSnp_Linum_lewisii_NDSU_LiLewi_1.0
# Run GWAS (Blink model)
data_gapit <- mapped
# Build phenotype data frame for Root_Length trait
pheno_df <- data_gapit$other$ind.metrics[, c("id", "Style_Morph")]
colnames(pheno_df) <- c("Taxa", "Style_Morph")
pheno_df$Style_Morph <- as.numeric(pheno_df$Style_Morph)
# Convert genlight to GAPIT HAPMAP format
geno_hmp <- gl2gapit(x = data_gapit)
# Execute GWAS with Blink and 6 PCs
GAPIT(
Y = pheno_df,
G = as.data.frame(geno_hmp),
PCA.total = 6,
model = "Blink"
)
# Manhattan plots
all_files <- list.files(full.names = TRUE)
# Identify BLINK result files
result_files <- all_files[grepl("GWAS_Results\\.BLINK", all_files) &
grepl("NYC", all_files)]
# Read GWAS results and chromosome lookup
gwas_tab <- read.csv(result_files)
# Prepare data frame for CMplot (SNP, Chr, Pos, p-value)
plot_df <- gwas_tab[, c("SNP", "Chr", "Pos", "P.value")]
polychrome <- function(n) rep(colorspace::darken(c(
"#3283FE","#FEAF16","#B00068","#1CFFCE","#90AD1C","#2ED9FF","#DEA0FD","#AA0DFE",
"#F8A19F","#325A9B","#C4451C","#1C8356","#85660D","#B10DA1","#FBE426","#1CBE4F",
"#FA0087","#FC1CBF","#F7E1A0","#C075A6","#782AB6","#AAF400","#BDCDFF","#822E1C",
"#B5EFB5","#7ED7D1","#1C7F93","#D85FF7","#683B79","#66B0FF","#5A5156","#E4E1E3",
"#F6222E","#FE00FA","#16FF32","#3B00FB"
), .2), length.out = n)
# Plot Manhattan with genome-wide and suggestive thresholds
CMplot(
plot_df,
plot.type = "m",
LOG10 = TRUE,
col = polychrome(length(unique(plot_df$Chr))),
threshold = c(5e-8, 1e-5),
threshold.col = c("red", "blue"),
amplify = TRUE,
main = "Style_Morph",
signal.cex = 1,
file.name = "Style_Morph"
)