#Installing packages #install.packages(“qqman”) library(qqman) library(ggplot2)

#This GWAS dataset is taken from our published paper (Torre, A. et. al., 2021).

library(qqman)
## 
## For example usage please run: vignette('qqman')
## 
## Citation appreciated but not required:
## Turner, (2018). qqman: an R package for visualizing GWAS results using Q-Q and manhattan plots. Journal of Open Source Software, 3(25), 731, https://doi.org/10.21105/joss.00731.
## 
library(ggplot2)
# import data
tassel_glm <- read.table("~/Documents/R_plots/segi_more-trait/segi_mlm-manhattan.txt", header = T, sep = "\t")

# Manhattan plot
#Remove NaNs values from the input file if there are any

manhattan(tassel_glm, chr="Chr", bp="Pos", snp="Marker", p="p", suggestiveline = FALSE, genomewideline = FALSE,
          col = c("blue4", "orange3"),
          ylim=c(0,8), cex.lab=1.5, cex.axis = 2,cex = 1)

# QQ plot
qq(tassel_glm$p)

se_pca <- read.csv (file= "~/Documents/R_plots/SEGI_PCA/segi_filter_PCA.csv", header = T)

#Plot PCA with color

se_p1 <- ggplot(se_pca, aes(x= PC1, y=PC2))+
  geom_hline(yintercept = 0, lty = 2) +
  geom_vline(xintercept = 0, lty = 2) +
  geom_point(alpha = 0.8, size = 4, aes(color = Grove))

#segi_p1

#segi_p2 <- segi_p1 + theme(legend.position = "none")


se_p1 + theme(
  panel.border = element_blank(),
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  axis.line = element_line(colour = "black"),
  text = element_text(family="Times New Roman", face="bold", size=16),
  panel.background = element_blank(),
  axis.text.y = element_text(size=16),
  axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size=16)
)