Skip to content

Instantly share code, notes, and snippets.

@timyates
Created June 25, 2010 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timyates/31ccce346f1a588acedd to your computer and use it in GitHub Desktop.
Save timyates/31ccce346f1a588acedd to your computer and use it in GitHub Desktop.
# A Possible solution to http://saaientist.blogspot.com/2010/06/encounter-with-incanter-about-clojure.html
# in R
data = data.frame( position=c( 123, 245, 832, 1234, 2345, 8315, 9213 ),
qual= c( 29, 93, 51, 63, 75, 9, 59 ),
ref= c( 'A', 'C', 'C', 'T', 'A', 'C', 'T' ),
alt= c( 'G', 'G', 'T', 'G', 'C', 'A', 'G' ) )
ti.data = data[ paste( data$ref, data$alt, sep='' ) %in% c( 'AG', 'CT' ), ]
tv.data = data[ paste( data$ref, data$alt, sep='' ) %in% c( 'AC', 'CG', 'GT', 'AT' ), ]
t( sapply( seq( from=10, to=100, by=10 ), function( i ) {
ti.count = dim( ti.data[ ( ti.data$qual <= i & ti.data$qual > i - 10 ), ] )[1]
tv.count = dim( tv.data[ ( tv.data$qual <= i & tv.data$qual > i - 10 ), ] )[1]
list( cutoff=i, ratio=ti.count / tv.count )
} ) )
@timyates
Copy link
Author

Don't know if this even works... Not enough input data ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment