Lefse after QIIME2

Dear all,

I am currently looking for ways to analyse my 16s data using Maaslin and Lefse after performed QIIME2 analysis, does anyone did that before? I have problem in the beginning now in the installing and what is the input files from QIIME2 that I should use.

Any recommendation?

Thanks.

regards
Clara

4 Likes

Hi @Clara, I know we spoke, but give me a couple of days, I had a conversation with @gregcaporaso during one of the QIIME2 training sessions which I was able to export the table.gza w/ metadata in order to format for LEfSe use. I will post the how-to when I get past this weekend call. Ben

2 Likes

Thanks @ben, that will be really helpful.

I have used my QIIME2 feature tables as inputs for LEFSE, but the process is somewhat complicated because it requires jumping between different Python versions as well as manually editing input files. In short:

  1. Collapse your rarefied feature table by taxa to the desired level
  2. Unzip the collapsed table .qza file, then convert to .txt
  3. Use QiimeToMaaslin to format the table (you have to slightly modify the feature table before the script works, because it expects a QIIME1-formatted OTU table)
  4. Edit the output table have just the metadata of interest (class, subclass, sample ID) and use this table as your LEFSE input

Note that QiimeToMaaslin only works with Python 2, trying it with Python 3 gives errors

2 Likes

Thanks @Zachary_Bendiks, I have changed the layout of my OTU table according to the requirement without using QiimeToMaaslin, do you think is ok? The other thing is, how can I know whether I am using Python 2 or Python 3?

Sorry to ask some too basic question, but I found this command in one of the website to format the input file:
format_input.py OTU_table_genus_lefse.tsv OTU_table_genus_lefse.in -c 1 -s 2 -u 3 -o 1000000
but I got error message :
format_input.py: command not found

I tried to google for the reason, seems like .py is the problem, is it true?

As long as the table is formatted correctly, it won’t matter how you do it. I like QiimetoMaaslin because it speeds up the process of creating a LEFSE-compatible table, but it certainly isn’t necessary.

It looks like you need to download and install Q2M first.

  1. Download the entire directory from GitHub
  2. Run the setup.py script to install it. You have to call the function directly, so if you downloaded the GitHub folder to /home/Desktop/qiimetomaaslin, you need to run /home/Desktop/qiimetomaaslin/setup.py
  3. When you call Q2M functions, make sure you call them directly as well. Also, you may need to type in “python” before calling the script (ex: python /path/to/Q2M/format_input.py)

**Note that Q2M also requires a some R packages to work properly

To check Python versions, type python -V into the command line

Thanks for linking to that tool! We might be able to create a format/transformer pair to ease this process in the future. I know Lefse has come up before on the forum.

1 Like

@Clara

Prepare Qiime2 files for LEfSe:

collapse the table.gza to the L6 level

qiime taxa collapse
--i-table table.qza
--o-collapsed-table collapse.table.qza
--p-level 6
--i-taxonomy taxonomy.qza

calculate relative-frequency for the collapsed table (instead of counts you get relative abundance)

qiime feature-table relative-frequency
--i-table collapse.table.qza
--o-relative-frequency-table collapse.frequency.table.qza \
--output-dir collapse.frequency/

export biom file

qiime tools export
collapse.frequency.table.qza
--output-dir collapse.frequency/

convert biom to text file (for lefse comparison) QIIME1.9.1 command

biom convert \
-i collapse.frequency.table.biom
-o collapse.frequency.table.txt
--header-key "taxonomy" --to-tsv

You will need to format the text file for LEfSe. Meaning depending on if you have class or subclasses you will have to add 2-3 rows to the top of the file. Row 1 needs to be your class, Row 2 needs to be your subclass, and Row 3 will be your All ";" throughout the taxonomy will have to be changed to "|".

I hope that helps.

17 Likes

Hi Dr. Benjamin,

I followed your instructions for preparing the feature-table from Qiime2 for Lefse and worked perfectly.

Just a question I’d like to ask: Do I need to rarefy the samples to the same sampling depth before doing these steps?

Lefse has its own normalization methods, but I do not know what approach would be more correct.

Thanks very much,
Fernando Studart

1 Like

@fstudart

I think that that question should be asked of your data in general before you get to the lefse step. If you're upstream assessment of alpha and beta has been done w/ rarefied data then MAYBE you should analyze the data rarefied (edited). I tell you that we do not rarefy for LEfSe, but we do assess alpha/beta rarefied.

5 Likes

Hi Dr. Benjamin,

Thanks very much for your reply. In our lab, we use the same approach: alpha/beta rarefied.

Thanks,
FS

1 Like

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