To find SNPs unique to each species/line (W, A, L, U) from your VCF files (W, AxL, AxU), and identify genes that have distinct or clustered SNPs to help distinguish transcripts, follow this structured approach:
Step-by-step Plan
Step 1: Prepare your VCF files
Ensure all VCFs are:
bgzipped (bgzip file.vcf)
indexed with tabix (tabix -p vcf file.vcf.gz)
Use a common reference genome and coordinates
Step 2: Separate AxL and AxU into A and L, and A and U
If AxL and AxU are diploid heterozygous VCFs from hybrids:
You can extract putative parental SNPs:
Shared SNPs between AxL and AxU likely belong to A
SNPs unique to AxL → L
SNPs unique to AxU → U
Commands (using bcftools):
bashCopyEdit# Shared SNPs (likely A)
bcftools isec -n=2 -w1 AxL.vcf.gz AxU.vcf.gz -Oz -o A.vcf.gz
Unique to AxL (likely L)
bcftools isec -n=1 -w1 AxL.vcf.gz AxU.vcf.gz -Oz -o L.vcf.gz
Unique to AxU (likely U)
bcftools isec -n=1 -w1 AxU.vcf.gz AxL.vcf.gz -Oz -o U.vcf.gz
You now have 4 "species":
W.vcf.gz
A.vcf.gz
L.vcf.gz
U.vcf.gz
Step 3: Find Unique SNPs per species
Using bcftools isec, compare all 4 VCFs to find unique SNPs in each.
Example for W:
bashCopyEditbcftools isec -n=1 -w1 W.vcf.gz A.vcf.gz L.vcf.gz U.vcf.gz -Oz -o W_unique.vcf.gz
Repeat similarly for A, L, and U.
Step 4: Annotate SNPs with Gene Information
Use snpEff or VEP to annotate each VCF with gene names and effects.
Example with snpEff:
bashCopyEditsnpEff ann your_genome W_unique.vcf.gz > W_annotated.vcf
Extract SNPs by gene:
bashCopyEditbcftools query -f '%CHROM\t%POS\t%GENE\n' W_annotated.vcf | sort | uniq > W_genes.txt
Step 5: Identify Genes with Clusters of SNPs
Cluster detection (e.g., 2+ SNPs within 100 bp in the same gene):
Python or R scripts can:
Group SNPs by gene
Sort by position
Count number of SNPs per gene
Detect clusters based on proximity
Example R snippet:
rCopyEditlibrary(dplyr)
df <- read.table("W_genes.txt", header=FALSE)
colnames(df) <- c("chr", "pos", "gene")
df %>%
group_by(gene) %>%
arrange(pos) %>%
mutate(dist = pos - lag(pos)) %>%
filter(!is.na(dist) & dist < 100) %>%
summarise(n_clustered_snps = n()) %>%
filter(n_clustered_snps >= 2)
Optional: Compare Gene Lists
To find species-distinct genes, intersect and subtract gene lists (e.g., using comm, diff, or bedtools if you have BED annotations).
Summary Output:
W_unique.vcf, A_unique.vcf, L_unique.vcf, U_unique.vcf
Gene lists for each species with:
Total number of unique SNPs
Genes with clustered SNPs
Possibly annotated functional effect
Would you like:
A pipeline script for all of this?
Help adjusting for multi-sample VCFs or pooled samples?
A visual plot of gene-specific SNP clustering?
Let me know what format you're working with exactly (multi-sample or not), and whether you want the final output in Excel, text, or a visual form.