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!
This exercise is part of the course
Introduction to Bioconductor in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load package ShortRead
library(ShortRead)
# Check class of fqsample
___
# Filter reads into selectedReads using myStartFilter
selectedReads <- fqsample[___(___)]
# Check class of selectedReads
___