## Load in an example dataset:
sff <- loadIonSampleData()
## Get a list of available clip modes:
availableClipModes(sff)
## Check the current clipMode. It should default to "full":
clipMode(sff)
## full clipping is the most conservative, resulting in shorter reads
hist(width(sff))
summary(width(sff))
## These reads should also be free of adapters although the first base looks suspect:
alphabetByCycle(DNAStringSet(substr(sread(sff), 1,15)), alphabet=c("A","C","T","G"))
cols <- c("green","blue","black","red","darkgrey")
leg <- c("A","C","T","G","N")
matplot(t(alphabetByCycle(DNAStringSet(substr(sread(sff), 1,15)),
alphabet=c("A","C","T","G"))), type="l", lty=1, col=cols)
legend("topright", col=cols, legend=leg, pch=18, cex=.8)
## Compare this to unclipped reads using "raw" mode:
clipMode(sff) <- "raw"
hist(width(sff),breaks=500,col="grey",xlab="Read Length",main="Raw Read Length")
alphabetByCycle(DNAStringSet(substr(sread(sff), 1,15)), alphabet=c("A","C","T","G"))
cols <- c("green","blue","black","red","darkgrey")
leg <- c("A","C","T","G","N")
matplot(t(alphabetByCycle(DNAStringSet(substr(sread(sff), 1,15)),
alphabet=c("A","C","T","G"))), type="l", lty=1, col=cols)
legend("topright", col=cols, legend=leg, pch=18, cex=.8)
## Extract clip points for further analysis:
full.clippoints <- fullClip(sff)
raw.clippoints <- rawClip(sff)
table(start(full.clippoints))
table(start(raw.clippoints))
par(mfrow=c(1,2))
hist(end(full.clippoints))
hist(end(raw.clippoints))
par(mfrow=c(1,1))
## determine how much was trimmed from each read by clipping
barplot(table(end(raw.clippoints) - end(full.clippoints)))
## Custom clip points can also be set using an IRanges object:
customClip(sff) <- IRanges(start = 1, end = 4)
clipMode(sff) <- "custom"
table(counts=as.character(sread(sff)))
Run the code above in your browser using DataLab