Skip to content

Instantly share code, notes, and snippets.

@sashaphanes
Created April 19, 2013 18:41
Show Gist options
  • Save sashaphanes/5422314 to your computer and use it in GitHub Desktop.
Save sashaphanes/5422314 to your computer and use it in GitHub Desktop.
RNAseq reads covered 5,000 biallelic human autosomal SNPs (all are heterogeneous, assume they are not in LD). Simple R statements plot the distribution of the alternative allelic frequency under sequencing coverage 2x, 5x, 10x, 20x, respectively. Calculate the p-values with the hypothesis that there are no differential allelic expression for the…
plot(x=c(0:2)/2, dbinom(c(0:2),2,0.5), pch=20, col="red", type ="b", xlim =c(0,1), ylim =c(0, 0.6), xlab = "AltFreq", ylab="Probability" )
lines (x=c(0:5)/5, dbinom(c(0:5),5,0.5), pch=20, col="brown",type ="b" )
lines (x=c(0:10)/10, dbinom(c(0:10),10,0.5), pch=20, col="green",type ="b")
lines (x=c(0:20)/20, dbinom(c(0:20),20,0.5), pch=20, col="blue",type ="b")
legend(0.8, 0.58, legend="2x", col="red", pch=20, lty = 1, bty="n" )
legend(0.8, 0.56, legend="5x", col="brown", pch=20, lty = 1, bty="n" )
legend(0.8, 0.54, legend="10x", col="green", pch=20, lty = 1, bty="n" )
legend(0.8, 0.52, legend="20x", col="blue", pch=20, lty = 1, bty="n" )
RefAlleleCount:AltAlleleCount = 1:4, pvalue: 0.375: binom.test(4,5, 0.5)$p.value == binom.test(1,5, 0.5)$p.value
RefAlleleCount:AltAlleleCount = 2:8, pvalue: 0.109375: binom.test(8,10, 0.5)$p.value == binom.test(2,10, 0.5)$p.value
RefAlleleCount:AltAlleleCount = 4:16, pvalue: 0.01181793: binom.test(16,20, 0.5)$p.value == binom.test(4,20, 0.5)$p.value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment