Skip to the content.

Train your own classifier

What users should set / edit

A) Input files (paths)

B) Metadata column to predict

C) Sample filtering choice (body site / subset)

Users should set the WHERE clause, e.g.

'[Body_Site_Ed] IN ("skin_hand", "skin_penile")'

D) Output directory name

E) Training parameters (optional)


Step 1 — Filter the OTU/feature table (example: skin)

qiime feature-table filter-samples \
  --i-table otu_Table_allsamples.qza \
  --m-metadata-file metadata_final_withZIFMsamples.txt \
  --p-where '[Body_Site_Ed] IN ("skin_hand", "skin_penile")' \
  --o-filtered-table filtered-table.qza

Step 2 — Train a classifier on the filtered table

This trains a supervised classifier using QIIME2’s sample-classifier plugin. It trains a Random Forest model to predict Body_Site_Ed from the filtered feature table. Feature selection + parameter tuning are enabled.

qiime sample-classifier classify-samples \
  --i-table filtered-table.qza \
  --m-metadata-file metadata_final_withZIFMsamples.txt \
  --m-metadata-column Body_Site_Ed \
  --p-optimize-feature-selection \
  --p-estimator RandomForestClassifier \
  --p-parameter-tuning \
  --p-n-jobs 8 \
  --p-n-estimators 500 \
  --p-random-state 123 \
  --output-dir my_custom_rf