Skip to content

Instantly share code, notes, and snippets.

@hliang
Created August 4, 2014 21:07
Show Gist options
  • Save hliang/1fa9901f7fe636ac0e31 to your computer and use it in GitHub Desktop.
Save hliang/1fa9901f7fe636ac0e31 to your computer and use it in GitHub Desktop.
number of reads vs. coverage
excap_cov.df = read.table("input.txt", header=F, sep="\t")
colnames(excap_cov.df) = c("sample_name", "total_reads", "pct_mapped", "pct_dup",
"mean_cov", "pct_on_target", "pct_10X", "pct_20X", "pct_50X",
"mean_insert_size", "std_dev_insert_size")
# convert character of percentage into numeric
excap_cov.df$pct_dup = as.numeric(sub("%","", excap_cov.df$pct_dup))/100
excap_cov.df$pct_mapped = as.numeric(sub("%","", excap_cov.df$pct_mapped))/100
plot(excap_cov.df$total_reads, excap_cov.df$pct_50X, type="n", xlim=c(4E7, 17E7), ylim=c(0.1, 1),
xlab="Number of Reads (millions)", ylab="Percent of Target Bases",
xaxt="n")
axis(1, at=c(4E7,6E7,8E7,10E7,12E7,14E7,16E7), lab=c(40,60,80,100,120,140,160), las=TRUE)
points(excap_cov.df$total_reads, excap_cov.df$pct_10X, col=2)
points(excap_cov.df$total_reads, excap_cov.df$pct_20X, col=3)
points(excap_cov.df$total_reads, excap_cov.df$pct_50X, col=4)
#points(excap_cov.df$total_reads, excap_cov.df$pct_dup*4, col=5)
#points(excap_cov.df$total_reads, excap_cov.df$pct_on_target, col=6)
abline(h=c(0.8, 0.85, 0.9, 0.95, 1), v=c(4E7,5E7,6E7), col="gray", lty=2)
#axis(2, at=0.9, lab=0.9)
legend("bottomright", c("10X", "20X", "50X"),
cex=1.0, col=c(2,3,4), pch=c(1))
# ####### sample input #########
# Sample_166 58813472 99.1595531037515% 6.53918450889311% 75.958748 0.720462 0.988849 0.962762 0.726212 205.337706 58.299572
# Sample_24 81387961 99.1211390588837% 7.73714057572404% 100.646632 0.699841 0.991437 0.976463 0.842493 208.112771 58.11621
# Sample_342 102884512 99.5059567372006% 8.7230955658487% 130.156246 0.720437 0.994725 0.985788 0.909254 210.253886 60.151855
# Sample_39 80207169 99.3799980647615% 7.90178783097556% 101.543205 0.715267 0.99169 0.976851 0.846229 207.140338 58.748312
# Sample_306 67518068 99.3890361317803% 6.3031817658713% 89.36837 0.734432 0.989541 0.968627 0.786992 204.999749 56.458639
# Sample_433 83194307 99.346550239309% 7.35631615063642% 106.274024 0.717374 0.991882 0.978217 0.858742 208.344091 60.73573
# Sample_409 93837178 99.313161357005% 11.4215522447073% 120.520611 0.754171 0.992857 0.981756 0.884586 200.518061 53.214942
# Sample_42 79439315 99.216979652959% 11.8172032875488% 95.268749 0.709971 0.991094 0.971653 0.813539 202.84699 57.401023
# Sample_429 75583441 99.0963999641138% 7.89564488561799% 97.773103 0.733215 0.991193 0.972376 0.819246 205.827773 57.607437
# Sample_4 78982334 99.0092176815134% 8.624254162632% 102.545717 0.742471 0.991759 0.974714 0.834647 199.473671 54.357755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment