In these exercises will gain some experience working with the BSgenome packages.
suppressPackageStartupMessages(library(BSgenome.Hsapiens.UCSC.hg19))library(BSgenome.Hsapiens.UCSC.hg19)length(seqnames(BSgenome.Hsapiens.UCSC.hg19))## [1] 298
contigLengths <- seqlengths(BSgenome.Hsapiens.UCSC.hg19)
sum(contigLengths[order(contigLengths,decreasing = FALSE)][1:3])## [1] 35839
alpFreq <-alphabetFrequency(BSgenome.Hsapiens.UCSC.hg19$chr20)
alpFreq["N"]## N
## 3520000
library(ggplot2)
alpFreq <-alphabetFrequency(BSgenome.Hsapiens.UCSC.hg19$chr20)
atcgFreq <- alpFreq[c("A","T","C","G")]
atcgFreqDF <- data.frame(Bases=names(atcgFreq),Frequency=atcgFreq)
ggplot(atcgFreqDF,aes(y=Frequency,x=Bases,fill=Bases))+geom_bar(stat = "identity")+theme_minimal()mySeq <- BSgenome.Hsapiens.UCSC.hg19$chr20[1000000:1000020]
complement(mySeq)## 21-letter DNAString object
## seq: CACCCTCTCTTGACCTTGTTC
mySet <- DNAStringSet(complement(mySeq))
names(mySet) <- "testFasta"
writeXStringSet(mySet,filepath ="data/testFasta.fa")chr8:128748315-128748869mySeq <- BSgenome.Hsapiens.UCSC.hg19$chr8[128748315:128748869]Compare the sequence to that found in IGV and identify start of translated region in gene
Count the number of classical start codons (ATG) in the first exon.
countPattern("ATG",mySeq)## [1] 0
gapdhSeq <- BSgenome.Hsapiens.UCSC.hg19$chr12[6643976:6644027]
countPattern("ATG",gapdhSeq)## [1] 1