Is there anyway to modify the code to display allele frequencies instead of density? Also, what about display frequencies in multiple populations?
I have allele frequencies for the Neanderthal allele at sites where both Neanderthal genomes are homozygous and overlap with putative introgressed haplotypes in the form of Plink frequency output (--freq --missing --within cluster --out output).
I want to plot the allele frequencies along the SNPs' genomic coordinates.
Basically, I want to generate something like this Figure 1A from Sankararaman et al. (2014) (http://www.nature.com/nature/journal/v507/n7492/fig_tab/nature12961_F1.html) except the Y-axis would be frequency.
Anyone know how I could do this?
2 answers
I figured out how to modify Isran's code. In case anyone else needs/wants it, here it is.
snps<-read.table("filename.txt",header=T)
goodChrOrder <- c(1:22,"X","Y")
snps$CHR <- factor(snps$CHR,levels=goodChrOrder)
library(ggplot2)
freq = ggplot(snps,aes(COORD,MAF, colour=CLST)) + geom_point() +
facet_wrap(~ CHR,ncol=2) + # separate plots for each chr, x-scales can differ from chr to chr
ggtitle("Distribution of allele frequency across genome") +
xlab("Position in the genome") +
ylab("SNP frequency") +
pdf("filename.pdf",20,20)
print(freq)
dev.off()
I often use Irsan's solution from Plotting Density Of Snps On Chromosomes Works for me :)
Log in to answer this question.