adamos1945
(najib abdellaoui)
October 21, 2024, 12:45am
1
hello,
I am working on qiime2-2024-5 for analysing my 16sRNA data. for that purpose, i used the following command:
qiime feature-classifier extract-reads \
--i-sequences 99_otus.qza \
--p-f-primer AACMGGATTAGATACCCKG \
--p-r-primer ACGTCATCCCCACCTTCC \
--o-reads ref-seqs.qza
then i got the following taxonomy file:
as well rep-seqs:
how is it possible to convert the feature ID into OTU?
thank you so much.
colinvwood
(Colin Wood)
October 21, 2024, 5:41pm
2
Hello @adamos1945 ,
I'm unsure what you mean by converting the feature IDs into OTUs--could you explain?
adamos1945
(najib abdellaoui)
October 25, 2024, 12:40am
3
sorry for the for the trouble, as you can see the tables have feature ID as hash identifier: ```
8743b52063cd84097a65d1633f5c74f5, i would like to convert the ID to OTU such as OTU1, OTU2....
is it possible to do it through qiime2 for taxonomy table, OTU table and tree?
thank you for your help.
You can rename features using the feature-table
plugin:
https://docs.qiime2.org/2024.5/plugins/available/feature-table/rename-ids/
But... this may be a bad idea!
You can technically do this with the feature-table rename-ids
function (see here ) but personally I wouldn't recommend it. Changing the feature-ids in your feature table will break the link between the id and say your phylogenetic tree, taxonomy, and rep-seqs artifacts, which you may need for downstream analysis. What I generally do is get my data to the final stages and for plotting purposes I change the names on the fly in R.
If you can give us a more specific example of what you want to do and with what platform we may be able to help you get there more efficiently.
adamos1945
(najib abdellaoui)
October 25, 2024, 5:18am
5
thank you so mcuh for your help.
i could solve it through use of following commands:
awk '{gsub(/[^A-Za-z0-9_,:]/,""); split($0, arr, ","); for (i in arr) {split(arr[i], id, ":"); print id[1]}}' tree.nwk >feature_ids.txt
awk 'BEGIN {count=1} {print $1 "\tOTU" count++}' feature_ids.txt > otu_mapping.txt
awk 'NR==FNR {map[$1]=$2; next} {for (i in map) gsub(i, map[i])} 1' otu_mapping.txt tree.nwk > tree_with_otus.nwk
just curious, why is it a bad idea to convert the feature ID to OTU ID?
Changing the feature-ids in your feature table will break the link between the id and say your phylogenetic tree, taxonomy, and rep-seqs artifacts, which you may need for downstream analysis.
I suppose OTU1 and ASV2 are easier to write about in a publication. Brevity is clarity!
Why is renaming helpful to you?
Here's another thing to consider:
The linux command awk
is great, but does not record any history.
Once you make the tree_with_otus.nwk
file, it's provenance is gone!
We often answer questions by looking for clues in the Qiime2 artifact provenance history, if you use awk
you are on your own.
1 Like