Created
July 14, 2017 18:13
-
-
Save aaiezza/050edf9a162b48f8477618f4efbdfdfd to your computer and use it in GitHub Desktop.
Nucleotides Sliding Window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require( zoo ) | |
require( iterpc ) | |
# Could be retreived from anywhere of course… | |
nucleotideSequence <- sample( c('A','T','C','G'), 1000, replace=TRUE, prob=c(.1,.1,.4,.4) ) | |
windowWidth <- 3 | |
kmers <- rollapply( nucleotideSequence, width = windowWidth, by = 1, paste, collapse='' ) | |
possibleKmers <- apply( getall( iterpc(4, 3, c('A','T','C','G'), replace = TRUE) ), 1, paste, collapse = '' ) | |
table( factor( kmers, levels = possibleKmers ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment