0.1 load R packages; read in vcf and sample sheet

Code
library(vcfR)
library(ggplot2)
library(SNPfiltR)
library(StAMPP)
library(adegenet)
v<-read.vcfR("~/Downloads/yhpa_final_filtered.vcf.gz")
samps<-read.csv("~/Downloads/Table1.for.manuscript.csv")

0.2 remove single auropalliata sample and then calculate FST between groups

Code
#remove sample
vsub<-v[,colnames(v@gt) != "ao_LSUMZ_39731"]
vsub
***** Object of Class vcfR *****
45 samples
26 CHROMs
2,274 variants
Object size: 4.2 Mb
7.873 percent missing data
*****        *****         *****
Code
#remove invariant SNPs
vsub<-min_mac(vsub, 1)
1.14% of SNPs fell below a minor allele count of 1 and were removed from the VCF

Code
vsub
***** Object of Class vcfR *****
45 samples
26 CHROMs
2,248 variants
Object size: 4.2 Mb
7.858 percent missing data
*****        *****         *****
Code
#subset sampling file and fix pop IDs
samps<-samps[samps$sample_ID %in% colnames(vsub@gt),]
samps[16,5]<-"SoCal"
samps[17,5]<-"SoCal"
samps[18,5]<-"SoCal"

#reorder sample file to match vcf
samps<-samps[match(colnames(vsub@gt)[-1],samps$sample_ID),]

#convert vcfr to geno
gen<-vcfR2genlight(vsub)
#assign pops
pop(gen)<-samps$Subspecies
#calc FST
x<-stamppFst(gen)
#reassign
m<-x$Fsts
#fill in upper triangle of matrix
m[upper.tri(m)] <- t(m)[upper.tri(m)]
#melt for plotting
heat <- reshape::melt(m)
Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by
the caller; using TRUE

Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by
the caller; using TRUE

0.3 plot

Code
#reorder factors for plotting
plot.order<-c("tresmariae","oratrix (west)","oratrix (east)","belizensis","SoCal","unknown")
heat$X1<-factor(heat$X1, levels=plot.order)
heat$X2<-factor(heat$X2, levels=plot.order)

#plot with labels
ggplot(data = heat, aes(x=X1, y=X2, fill=value)) + 
  geom_tile(color = "black", size=.5)+
  geom_text(data=heat,aes(label=round(value, 2)), size=2.25)+
  theme_minimal()+
  scale_fill_gradient2(low = "white", high = "darkgrey", space = "Lab", name="Fst") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        axis.text.y = element_text(angle = 45, hjust = 1))
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
Warning: Removed 6 rows containing missing values or values outside the scale range
(`geom_text()`).

Code
#ggsave(file="~/Desktop/YHPA.fst.pdf", units="in",width=4,height=3) #saves g