After the install I do not recomment to run update scripts in KronaTools because we won't use them and it will start a huge download.
We need to be able to call Krona from bash so make sure that ktImportText command works.
After that, we just need a taxa-bar-plots.qzv file to work with this Python script: generate-krona.py (2.1 KB)
Simply, the script extracts level-7.csv from taxa-bar-plots.qzv, creates tsv files for krona, generates krona file as html, removes anthing unnecessary in the process.
You can read the comments to make changes in the script. Script is written to work with python3.
Have fun.
(First time posting a tutorial, I need all the criticism and suggestions to improve it. )
Awesome work @the_dummy! I am looking forward to giving this a spin!
Looks like you are just a stone's-throw away from writing your own QIIME 2 plugin... interested in giving that a try? We can point you in the right direction!
#extract level-7.csv from taxa barplots
Why extract from the barplot.qzv? Why not accept a feature table and taxonomy file (or a feature table that has been collapsed to a specific level) as input? That would be the first step toward making this a little more plugin-like and efficient.
Why extract from the barplot.qzv? Why not accept a feature table and taxonomy file (or a feature table that has been collapsed to a specific level) as input? That would be the first step toward making this a little more plugin-like and efficient.
This is a very good idea. With this, you won't need to visualize everything if you want a limit to a level.
Another good reason to write this as a QIIME 2 plugin — you can take a FeatureTable[Frequency] artifact as input, QIIME 2 will validate the input type and transform it into a pandas.DataFrame for manipulating and saving as a TSV for krona. No need to figure out the biom-format API (which while useful for many other things is not needed here since you are really just formatting the table for krona)
Hey, I’m glad you’re recovering!
This is a really nice work and I’am in complete agrement you should work on a plugin. People would use it.
Cheers
Quick question does the script require the taxa-bar-plots.qzv and the level-7.csv files to be in a specific folder. Another thing I work with fungal data using the UNITE database, does this have to be considered?
Since my background is molecular biology I’m having serious trouble. Is there any material other than q2 plugin development which would help me understand the idea of developing a plugin, the perspective, whatever that is called. Maybe an outside video, paper etc. about this process.
I feel like I need to understand the logic first. I don’t believe that I lack the required programming skills.
I really want to make this into a plugin to give back to the community. Any help would be appreciated.
Thanks for your hard work! It will all be so worth it in the end!
The tutorial you've found is unfortunately really the only tutorial we have that explains the process for a first-time plugin developer. The other main resource we have is what I would call the desk reference for QIIME 2 development: https://dev.qiime2.org/latest/
But that is not really what you are looking for.
I have found that the best way to learn to write a QIIME 2 plugin is to look at the source code of other plugins and use that as a template... in your case, check out a plugin like q2-diversity and focus on a visualizer action like alpha-group-significance.
We know we need better resources to help new plugin developers... but in the meantime we are here to answer your questions! So ask away — if we get a good back-and-forth discussion we may split it off into a separate forum topic that we can point to as a new learning resource for plugin development
I have checked taxa barplot. That gave me some ideas and moral support .
I think I can use extract function in this plugin.
Seems like I need to make scripts as _version.py, _method.py etc. so that it is easier to upgrade at some point. I don’t know much about the reason of importing different scripts instead of making a single one, maybe some explanation could enlighten me.
Extraction seems easy but I didn’t see a clear way to make .qzv file.
There were some js files, but I don’t know anything about js. What does that part do with the plugin? Is it about .qzv generation, because as I told before, I couldn’t see something related.
Good questions! barplot may not be the best one to look at since it uses some javascript (that's what the .js files are all about). Maybe look at diversity beta-group-significance instead as a simpler example.
What for specifically? Is there a line in the q2-taxa source code that you are referring to? Or do you mean the qiime tools extract function? If you give me your use case I may be able to think of a solution.
Splitting up your code into separate modules just makes everything easier to navigate; it helps keep things neat and tidy for maintenance and testing. You don't need to, it's just good practice.
QIIME 2 does that for you! You would create an index template file as described here and set up the appropriate plugin registrations as described in that tutorial.
For example, see how it is done in beta-group-significance. Most of that command is working to run the tests and generate the plots/outputs. Then it is all tossed into an HTML template with these lines:
The first 2 lines are setting the path to the index.html template, then the following lines are loading that template and inserting different data (stats results, plots) into different sections of the template. For example, the result_html (a table of results rendered as html) is being inserted (and formatting) at this point in the template:
At no point in the code is the HTML being built "from scratch", though I suppose that is another valid option.
In your case, it looks like KRONA is already outputting an html... so maybe you don't even need to follow these steps. Instead, save that HTML file as output_dir/index.html... give it a spin and let's see!