How do I create a tree from a subset of samples?

Hi, @thermokarst,
Sorry, I have another question about the tree.
I use qiime2 and DADA2 demultiplex the 2 batches of samples separately. Then merge the batches rep-seqs.qza, and assign the taxonomy together.
But now I want to draw a tree of a subset of samples, 10 samples are from the 1st batch, 10 samples are from the 2nd batch. May I know how can I get a tree of the subset samples?
Thanks in advance.

Hi @Lu_Yang β€” I split this post off into a new topic, we generally try and keep each topic thread limited to one discussion point, that way it makes searching the forum easier for other users!

You will want to filter your representative sequences, twice, once per batch group. This will create two new subsets of representative sequences β€” you can then create trees for those subsets. Let me know if you need more specific guidance on how to make this happen, but I think if you read the references linked to above you should be set! :t_rex:

1 Like

Hi, @thermokarst,

I set the code as below
qiime feature-table filter-seqs --i-data rep-seqs.qza --m-metadata-file test.txt --o-filtered-data formate.qza
in which test.txt is the same format as the sample-metadata.txt, it only contains the SampleID I want to retain.
But I got the error as below.
Plugin error from feature-table:
All features were filtered out of the data.
Debug info has been saved to /var/folders/1l/6kmg2wlx57sc8kdq8n5mwl5r0000gn/T/qiime2-q2cli-err-oglum6sa.log.

Then I try as below.
qiime feature-table filter-seqs --i-data rep-seqs.qza --m-metadata-file mapping.txt --p-where test.txt --o-filtered-data formate.qza
In which the mapping.txt is the whole SampleID, test.txt is the SampleID I want to retain. Then I got the error as below.
Plugin error from feature-table:
Selection of IDs failed with query:
SELECT β€œ#SampleID” FROM metadata WHERE test.txt GROUP BY β€œ#SampleID” ORDER BY β€œ#SampleID”;
Debug info has been saved to /var/folders/1l/6kmg2wlx57sc8kdq8n5mwl5r0000gn/T/qiime2-q2cli-err-5dzqfayd.log

Could you do me a favor? Thanks in advance.

Hi @Lu_Yang! The first command is failing because your rep-seqs.qza have Feature IDs, but you are using your Sample IDs to filter with. You will need to filter your feature tables based on the sample IDs, then grab the Feature IDs from a feature-table summarize visualization, then use those IDs to filter the rep seqs. Please see this forum post for more detailed step-by-step instructions.

This workflow is a pain right now β€” we have an open issue to streamline this a bit. Let me know if you get stuck! :t_rex:

Hi, @thermokarst,

Thanks for your help. I have followed that post, I used the code as below
qiime feature-table filter-samples --i-table table.qza --m-metadata-file mapping.txt --p-where β€˜"#SampleID" IN (β€œD1.1.27.15”, β€œD2.1.27.15”,β€œD3.1.27.15”,β€œD1.2.7.15”,β€œD2.2.7.15”,β€œD3.2.7.15”,β€œD1.2.14.15”,β€œD2.2.14.15”,β€œD3.2.14.15”,β€œD1.2.22.15”,β€œD2.2.22.15”,β€œD3.2.22.15”,β€œD1.3.2.15”,β€œD2.3.2.15”,β€œD3.3.2.15”)’ --o-filtered-table table-formate.qza
qiime feature-table summarize --i-table table-formate.qza --o-visualization table-formate.qzv
qiime tools view table-formate.qzv
Then set download the csv file, also add the β€˜feature ID and frequency’, the features-to-filter.tsv is shown like this,
Feature ID Frequency
D3.3.2.15 117193
Then I use the code 'qiime feature-table filter-seqs --i-data rep-seqs.qza --m-metadata-file features-to-filter.tsv --o-filtered-data formate.qza’
I got the error.:thinking:
Plugin error from feature-table: All features were filtered out of the data.
Debug info has been saved to /tmp/qiime2-q2cli-err-9ht3hmxh.log.
Any possible way to solve?
Have a nice day!:star_struck:

Hi @Lu_Yang!

The error indicates that β€œAll features were filtered out of the data.” That means that the file features-to-filter.tsv includes every single one of your features in your rep-seqs.qza file, which I think given what you are trying to ultimately accomplish here (make several trees of sample subsets), means you can skip that filtering step, and use just your rep-seqs.qza file when creating the tree for that set of subsamples. Does that make sense?

Keep us posted on your progress! :t_rex:

Hi, @thermokarst,

Now it works! Awesome! I found my problem. There are two tables, feature-frequency-details.csv and sample-frequency-details.csv, I have used the wrong table. Now I use the samples-frequency-detais.csv. I created a tree. Great!
Thanks for your help!
Wish you a great Thanks Giving Day!

1 Like

In the new QIIME 2 2017.12 release you can provide a feature-table to feature-table filter-seqs to remove sequences that do not have corresponding IDs in the table!