Group samples or features by a metadata column

Hello :qiime2: :wave:

I was reading about a similar problem I have with changing the sample names without starting from the beginning, but I didn't understand how to correctly use it.

I've added the new column to the meta data but I don't know what to write in the --p-axis/mode.
This is the command I'm trying to run:

sage: qiime feature-table group [OPTIONS]

Group samples or features in a feature table using metadata to define the
mapping of IDs to a group.

--i-table ARTIFACT PATH FeatureTable[Frequency]
The table to group samples or features on.
--p-axis [feature|sample] Along which axis to group. Each ID in the
given axis must exist in metadata.
--m-metadata-file MULTIPLE PATH
Metadata file or artifact viewable as
metadata. This option may be supplied
multiple times to merge metadata.
--m-metadata-column MetadataColumn[Categorical]
Column from metadata file or artifact
viewable as metadata. A column defining the
groups. Each unique value will become a new
ID for the table on the given axis.
--p-mode [median-ceiling|sum|mean-ceiling]
How to combine samples or features within a
group. sum will sum the frequencies across
all samples or features within a group;
mean-ceiling will take the ceiling of the
mean of these frequencies; median-ceiling
will take the ceiling of the median of these
frequencies. [required]
--o-grouped-table ARTIFACT PATH FeatureTable[Frequency]
A table that has been grouped along the
given axis. IDs on that axis are replaced
by values in the metadata column.
[required if not passing --output-dir]
--output-dir DIRECTORY Output unspecified results to a directory
--cmd-config PATH Use config file for command options
--verbose Display verbose output to stdout and/or
stderr during execution of this action.
[default: False]
--quiet Silence output if execution is successful
(silence is golden). [default: False]
--help Show this message and exit.


Hi :wave:

You should indicate sample since you want to rename or group samples, not features.

BTW, if you want to reanme sample IDs, here is the plugin for it.

This plugin will group your samples into new grouped samples according to provided metadata column.

this is the command and error I got:

--i-table all_runs_old_A_only.qza --m-metadata-file metadata_23A.tsv --m-metadata-column 'new_ID' --p-axis 'sample' --p-strict --o-renamed-table all_runs_A_only_newID.qza

--i-table: command not found

Could you provide a screenshot of command with error?

was supposed to download the plugin first?

Nope, but it should start with qiime feature-table rename-ids, shouldn't it?


qiime feature-table rename-ids --i-table all_runs_old_A_only.qza --m-metadata-file metadata_23A.tsv --m-metadata-column "[new_ID]” --p-axis 'sample' --p-strict --o-renamed-table all_runs_A_only_newID.qza

Didn't execute

Am I missing somthing?

Looks like it should work.

Can you try this code?

qiime feature-table rename-ids \
  --i-table all_runs_old_A_only.qza \
  --m-metadata-file metadata_23A.tsv \
  --m-metadata-column new_ID \
  --p-axis 'sample' \
  --p-strict \
  --o-renamed-table all_runs_A_only_newID.qza

(1/1) Invalid value for '--m-metadata-file': There was an issue with

retrieving column 'new_ID' from the metadata.

Could you attach or send me via PM your table to rename and metadata with new IDs?

qiime feature-table rename-ids --i-table all_runs_old_A_only.qza --m-metadata-file merge_1.tsv --m-metadata-column "[new_ID]” --p-axis 'sample' --p-strict --o-renamed-table all_runs_A_only_newID.qza

The previous metadata was incorrect -> the correct one is "merge_1.tsv"
I'm running it now :crossed_fingers:

When I tried to visualise it I got the following error:

Plugin error from feature-table:

The following IDs are not present in the metadata: '10An', '12An', '13An', '16An', '18An', '19An', '1An', '22An', '24An', '25An', '27An', '28An', '29An', '2An', '31An', '32An', '3An', '4An', '5An', '6An', '7An', '8An', '9An'

Debug info has been saved to /tmp/qiime2-q2cli-err-_ew_crwj.log

The "_An" samples are the new IDs .. they should've been renamed.

Then instead of

You should use --p-no-strict as described:

 --p-strict / --p-no-strict
                       Whether the naming needs to be strict (each id in the
                       table must have a new id). Otherwise, only the ids
                       described in `metadata` will be renamed and the others
                       will keep their original id names.     [default: False]

Got the same error again

I think that would be faster way to debug

I got it!
The problem was that for visualisation I used the wrong metadata, I choose the new on with the new IDs at the SampleID column -> and this worked!

Than you for your help and quick responses :pray:

1 Like

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