Filtering reads on the go!
What if, from all of the reads in a file, you are only interested in some of those reads? You can use a filter!
Let's say that you are interested only in those reads that start with the pattern "ATGCA". A tiny filtering function can do the job, making use of the srFilter() function:
myStartFilter <- srFilter(function(x) substr(sread(x), 1, 5) == "ATGCA")
This function, which has been created for you, takes a ShortRead derived object as an input and outputs the reads starting with the pattern "ATGCA". Let's put this function to use!
Cet exercice fait partie du cours
Introduction to Bioconductor in R
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Load package ShortRead
library(ShortRead)
# Check class of fqsample
___
# Filter reads into selectedReads using myStartFilter
selectedReads <- fqsample[___(___)]
# Check class of selectedReads
___