Wildtype vs Hatchery o.lurida

Olympia oyster wildtype sequences vs hatchery in Central Sound ```{r setup, include=FALSE}

call varients for hatchery

for i in {01..05}; do
  /home/shared/bcftools-1.14/bcftools mpileup -Ou -f \
  /home/shared/8TB_HDD_02/thielkla/Karina-chinook/Olurida_v081.fa \
  /home/shared/8TB_HDD_02/thielkla/Karina-chinook/CSBM18H/CSMB18H.${i}.bam \
  | /home/shared/bcftools-1.14/bcftools call -mv -Ov \
  -o ~/Karina-chinook/output/H${i}.vcf
done

call varients for wildtype

for i in {01..05}; do
  /home/shared/bcftools-1.14/bcftools mpileup -Ou -f \
  /home/shared/8TB_HDD_02/thielkla/Karina-chinook/Olurida_v081.fa \
  /home/shared/8TB_HDD_02/thielkla/Karina-chinook/CSMB17W/CSMB17W.${i}.bam \
  | /home/shared/bcftools-1.14/bcftools call -mv -Ov \
  -o ~/Karina-chinook/output/W${i}.vcf
done

Merge so there can be a comparison

for f in ~/Karina-chinook/output/*.vcf; do
  /home/shared/htslib-1.14/bgzip "$f"         # compress to .vcf.gz
  /home/shared/htslib-1.14/tabix -p vcf "$f.gz"  # index for random access
done
ls ~/Karina-chinook/output/*.vcf.gz > ~/Karina-chinook/output/vcflist.txt
/home/shared/bcftools-1.14/bcftools merge \
-l ~/Karina-chinook/output/vcflist.txt -Oz -o ~/Karina-chinook/output/merged.vcf.gz

/home/shared/bcftools-1.14/bcftools index ~/Karina-chinook/output/merged.vcf.gz
/home/shared/bcftools-1.14/bcftools merge \
-l ~/Karina-chinook/output/vcflist.txt -Oz -o ~/Karina-chinook/output/merged.vcf.gz

/home/shared/bcftools-1.14/bcftools index ~/Karina-chinook/output/merged.vcf.gz

##Compare FST #Create text file that list samples

/home/shared/vcftools-0.1.16/bin/vcftools --gzvcf ~/Karina-chinook/output/merged.vcf.gz \
  --weir-fst-pop hatchery.txt \
  --weir-fst-pop wild.txt \
  --out ~/Karina-chinook/output/hatchery_vs_wild
head -20 ~/Karina-chinook/output/hatchery_vs_wild.weir.fst 
CHROM   POS WEIR_AND_COCKERHAM_FST
Contig0 1975    -nan
Contig0 2017    -nan
Contig0 2025    -nan
Contig0 2034    -nan
Contig0 2044    -nan
Contig0 7951    -nan
Contig0 8075    -nan
Contig0 18797   -nan
Contig0 52863   -nan
Contig0 52875   -nan
Contig0 52903   -nan
Contig0 52942   0.6
Contig0 52944   0.6
Contig0 52980   0.6
Contig0 53000   -nan
Contig0 53001   -nan
Contig0 53015   -nan
Contig0 53035   -nan
Contig0 53070   -nan

🧠 Interpretation

•   A mean FST near zero (or negative) suggests little to no genetic differentiation between the hatchery and wild populations.


•   Some negative FST values are possible due to sampling noise or low allele frequency variance; they are usually interpreted as zero.


•   A few high FST values (up to 1) indicate loci with strong differentiation — potentially under selection or drift.
# Install if not already installed
#install.packages("DT")

# Load the package
library(DT)

# Read your CSV file
hatchery_vs_wild.weir.fst <- read.csv("~/Karina-chinook/output/Top_1__FST_Loci.csv")

# Display interactive table
datatable(fst_data, options = list(pageLength = 10, scrollX = TRUE), rownames = FALSE)