-
Notifications
You must be signed in to change notification settings - Fork 0
Export Frequency Counts
Adam Taranto edited this page Sep 23, 2024
·
4 revisions
This section describes how to export frequency counts of k-mers.
import oxli
kmer_table3 = oxli.KmerCountTable(ksize=3)
# Count some k-mers
kmer_table3.consume('AAAAA') # 'AAA' x 3
kmer_table3.count('TTT') # 'AAA' + 1
kmer_table3.count('AAC') # count 1
# Export (frequency,count) tuples
kmer_table3.histo(zero=False) # [(1, 1), (4, 1)]
# Include frequencies with 0 counts
kmer_table3.histo(zero=True) # [(0, 0), (1, 1), (2, 0), (3, 0), (4, 1)]
Convert frequency count list into a Pandas dataframe.
import pandas as pd
histo_output = kmer_table3.histo(zero=True)
# Create a Pandas DataFrame from the list of tuples
df = pd.DataFrame(histo_output, columns=['Frequency', 'Count'])
print(df)
Frequency Count
0 0 0
1 1 1
2 2 0
3 3 0
4 4 1
Installing Oxli
Basic Setup
For Developers
Getting Started
Getting Started
Counting Kmers
Basic Counting
Extracting from Files
Handling Bad Kmers
Looking up Counts
Single Kmer Lookup
Multiple Kmer Lookup
Removing Records Remove Kmers Abundance Filtering
Exploring Count Tables
Iterating Records
Attributes
Set Operations
Basic SetOps
Exporting Data
Histo: Export Frequency Counts
Dump: Write Hash:Count Pairs
Save and Load KmerCountTables