This is a test version of Biostars. For the public version, visit https://www.biostars.org.
FASTA to Position Frequency Matrix

What tools are out there that can generate a position frequency matrix from a FASTA file (or a BED file)? I have a file containing many short (10bp) reads and want the count of each base at each position. I could write up something to do it, but I'm working with 50-100M sequences per file, and was wondering if any currently available tool is particularly fast.

motif fasta pwm pfm

2 answers

What I eventually went with was using the Biostrings package in R to do most of the heavy lifting.

After loading in the sequences, I converted them to a DNAStringSet object using DNAStringSet(seq_list) and then got the counts at each position with consensusMatrix(DNAStringSet_object)

This can then be converted to a proportion table with base R prop.table()

You could also try the DiffLogo R package (specifically, getPwmFromFile) but I have no experience in using the package so not sure how easy it is to use/speed.

Log in to answer this question.