Learn R Programming

qrqc (version 1.26.0)

getKmer-methods: Get a Data Frame of k-mer Frequency by Position from a SequenceSummary Object

Description

An object that inherits from class SequenceSummary contains k-mer frequency data by position gathered by readSeqFile when kmer=TRUE. getKmer is an accessor function that is useful for custom ggplot2 aesthetics.

Usage

getKmer(x)

Arguments

x
an S4 object that inherits from class SequenceSummary from, as returned from readSeqFile.

Value

getKmer returns a data.frame with columns:
kmer
the k-mer sequence.
position
the position in the read.
count
the frequency of the k-mer at this position.

Methods

signature(x="SequenceSummary")
getKmer is an accessor function that only works if there is k-mer data, thus it only works if readSeqFile was called with kmer=TRUE (and hash.prop is greater than 0).

See Also

getGC, getSeqlen, getBase, getBaseProp, getQual, getMCQual, kmerKLPlot, kmerEntropyPlot

Examples

Run this code
  ## Load a FASTQ file, with sequence and k-mer hashing on by default.
  s.fastq <- readSeqFile(system.file('extdata', 'test.fastq', package='qrqc'))

  ## plot counts of a subset of k-mers by position
  s.kmers <- getKmer(s.fastq)
  top.kmers <- s.kmers$kmer[order(s.kmers$count, decreasing=TRUE)[1:40]]
  p <- ggplot(subset(s.kmers, kmer %in% top.kmers)) + geom_bar(aes(x=position, y=count,
    fill=kmer), stat="identity")
  p

Run the code above in your browser using DataLab