Formatting a QIIME2 feature table for the R version of DADA2?

Hello,

I would like to explore the possibility of using the collapseNoMismatch function available in the R implementation of DADA2 to merge the feature tables that I generated using the QIIME2 implementation of DADA2. (only discovered that this function existed after doing all of the denoising and read merging in QIIME2 using qiime dada2 denoise-paired). Does anyone have any tips on getting QIIME2 generated ASV tables into the right form to work with DADA2 in R. Judging from this post:

Exporting DADA2 (R package) results to work with qiime2

I see that the feature tables will need to be transposed for the R implementation, but is there an easy way to have the row headers be the actual sequences rather than the feature ID that is the default row header in QIIME2, since i think this is necessary for the R version? (short of copy and pasting the sequences from the rep seq file…)

Thank you!
Colleen

Hi @ctekellogg,
Have you seen the nifty qiime2R package? I think that will make your life pretty easy.
I’m not sure if there is an easy way to replace the hashed IDs with their corresponding sequences in Qiime2, certainly doable in R, you’ll need to import both your table and rep-seqs file and use the latter to rename rownames in your table.
By the way, you can also transpose your table either in Q2 with the feature-table transpose action too.

Sure there is — secret QIIME 2 method. Use qiime feature-table group to relabel.

We have a few examples floating around the forum of using this as a sneaky way to relabel sample IDs, e.g., here:

But group can operate on feature IDs as well, and the same trick applies… additionally, we can transform a FeatureData[Sequence] artifact to metadata so that the sequence gets read in as the new label. Proof (using the moving pics tutorial data and Artifact API):

>>> import qiime2 as q2, pandas as pd
>>> from qiime2.plugins import feature_table as ft
>>> tab = q2.Artifact.load('table.qza')
>>> seqs = q2.Artifact.load('rep-seqs.qza')
>>> t2, = ft.actions.group(tab, 'feature', seqs.view(q2.Metadata).get_column('Sequence'), 'sum')
>>> tab.view(pd.DataFrame).columns
Index(['4b5eeb300368260019c1fbc7a3c718fc', 'fe30ff0f71a38a39cf1717ec2be3a2fc',
       'd29fe3c70564fc0f69f2c03e0d1e5561', '868528ca947bc57b69ffdf83e6b73bae',
       '154709e160e8cada6bfb21115acc80f5', '1d2e5f3444ca750c85302ceee2473331',
       '0305a4993ecf2d8ef4149fdfc7592603', 'cb2fe0146e2fbcb101050edb996a0ee2',
       '997056ba80681bbbdd5d09aa591eadc0', '3c9c437f27aca05f8db167cd080ff1ec',
       ...
       'ad492bcae03f566b36a19e31f04d659a', 'eb8ef4756ed538fe480d979e740a04d8',
       '5db2cf37007f874e25eb2c901917e15a', 'fa3729663b98de0c0af7913e9f30c19e',
       '504572e3afd673db749ee5e8e3e57b97', 'a6b6f29a1196cacfc392e3d71f55e2a2',
       '0e5df3d01cc073e3c9674c2534169f03', '06845c67bc4203081a981200f33e87eb',
       '98d250a339a635f20e26397dafc6ced3', '1830c14ead81ad012f1db0e12f8ab6a4'],
      dtype='object', length=770)
>>> t2.view(pd.DataFrame).columns
Index(['TACGGAGGATCCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGAGCGTAGATGGATGTTTAAGTCAGTTGTGAAAGTTTGCGGCTCAACCGTAAAATTGCAGTTGATACTGGATATCTT',
       'TACGTAGGGTGCGAGCGTTAATCGGAATTACTGGGCGTAAAGCGAGCGCAGACGGTTACTTAAGCAGGATGTGAAATCCCCGGGCTCAACCTGGGAACTGCGTTCTGAACTGGGTGACTA',
       'TACGTAGGTCCCGAGCGTTGTCCGGATTTATTGGGCGTAAAGCGAGCGCAGGCGGTTAGATAAGTCTGAAGTTAAAGGCTGTGGCTTAACCATAGTACGCTTTGGAAACTGTTTAACTTG',
       'TACGGAGGATCCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGAGCGTAGATGGATGTTTAAGTCAGTTGTGAAAGTTTGCGGCTCAACCGTAAAATTGCAGTTGATACTGGATGTCTT',
       'TACGGAGGATCCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGAGCGTAGGTGGATTGTTAAGTCAGTTGTGAAAGTTTGCGGCTCAACCGTAAAATTGCAGTTGAAACTGGCAGTCTT',
       'TACGGAGGGTGCGAGCGTTAATCGGAATAACTGGGCGTAAAGGGCACGCAGGCGGTGACTTAAGTGAGGTGTGAAAGCCCCGGGCTTAACCTGGGAATTGCATTTCATACTGGGTCGCTA',
       'TACGGAGGATCCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGAGCGTAGGCGGACGCTTAAGTCAGTTGTGAAAGTTTGCGGCTCAACCGTAAAATTGCAGTTGATACTGGGTGTCTT',
       'TACGTAGGTGGCAAGCGTTATCCGGAATTATTGGGCGTAAAGCGCGCGTAGGCGGTTTTTTAAGTCTGATGTGAAAGCCCACGGCTCAACCGTGGAGGGTCATTGGAAACTGGAAAACTT',
       'TACGTATGTCACAAGCGTTATCCGGATTTATTGGGCGTAAAGCGCGTCTAGGTGGTTATGTAAGTCTGATGTGAAAATGCAGGGCTCAACTCTGTATTGCGTTGGAAACTGCATGACTAG',
       'TACGGAAGGTCCAGGCGTTATCCGGATTTATTGGGTTTAAAGGGAGCGTAGGCTGGAGATTAAGTGTGTTGTGAAATGTAGACGCTCAACGTCTGAATTGCAGCGCATACTGGTTTCCTT',
       ...
       'TACGTAGAAGACTAGTGTTATTCATCTTTAATAGGTTTAAAGGGTACCTAGACGGTAAATTTAATCTTTAACAGGATATGTTTTTACTAGAGTTTTATATGAGGAGGGGAGTATTTATGG',
       'CACGGAAGGGGCAAGCGTTGCTCGTAAGTATTGGGCGTAAAGAGTTTGTAGGCGGTTTTTCAAAAAACTTGGTTTTCCATCCGGCTACGACATGGTTAACCTTGCTTGAGTTCAGTCTTT',
       'TACGGAGGATGCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGTGCGCAGGCGGAAGATCAAGTCAGCGGTAAAATTGAGAGGCTCAACCTCTTCGAGCCGTTGAAACTGGTTTTCTTG',
       'GACGGAGGGTGCTAGCGTTGTTCGGAATTACTGGGCGTAAAGGGCGCGTAGGCGGCCCTGTCAGTCGGGTGTGAAAGCCCGGGGCTCAACCCCGGAACGGCACCCGAGACGGCAGGGCTG',
       'GACGGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGATTGTAAAGTCCTCTGTTAAAGATCTGGGCTTAACCCAGTTCAAGCAGTGGAAACTTATAATCTA',
       'TACGAAGGGTGCAAGCGTTATTCGGAATCATTGGGCGTAAAGCGCGCGCAGGCGGATCAGCAAGTCAGATGTGAAATCTCAGGGCTCAACCCTGAAACTGCGTCTGAAACTGCTAGTCTA',
       'TACGTAGGGTGCAAGCGTTATCCGGAATTACTGGGCGTAAAGGGTGCGTAGGCGGCATGGCAAGTCAGAAGTGAAAGGCAATAGCTTAACTATTGTTAGCTTTTGAAACTGCTAAGCTTG',
       'TACGGAGGGTGCGAGCGTTATTCGGATTCACTGGGCGTAAAGCGCATGTAGGCGGTTTCGTAAGTCTGATGTGAAAGCCCTCGACTTAATCGAGGAAGTGCATTGGATACTGCGAGGCTA',
       'TACGTAGGTGGCGAGCGTTATCCGGAATTACTGGGTGTAAAGGGCGTGTAGGCGGCACTGTAAGTCAGATGTGAAATCTCCCGGCTCAACCGGGAGCGTGCATCTGATACTGCAGTACTT',
       'TACGTAGGGTGCAAGCATTATCCGGAGTGACTGGGCGTAAAGAGTTGCGTAGGCGGTTTAATAAGTGAATAGTGAAACCTGGTGGCTCAACCATACAGACTATTATTCAAACTGTTAAAC'],
      dtype='object', length=770)

So the CLI equivalent would be something like:

qiime feature-table group \
    --i-table table.qza \
    --p-axis feature \
    --m-metadata-file rep-seqs.qza \
    --m-metadata-column Sequence \
    --p-mode sum \
    --o-grouped-table new-table.qza

Enjoy!

1 Like

Hi @Mehrbod_Estaki - I have not seen that R package. I’ll take a look as I imagine it will come in handy, if not now, in the future.

And, @Nicholas_Bokulich - thank you for this example to (attempt to) make the changes in QIIME2 first before exporting the feature tables for R.

I’ll give this a shot!
Thank you,
Colleen

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.