Visualising Community Structure
Visualising the Taxonomic Profile
Last episode we used Metaphlan to output a table of the community structure of our metatranscriptome. Whilst this is somewhat human readable, it can be much easier to interpret by visualising the data in graph form. This is especially true of outputs with more taxa than ours, which only had taxa that could be resolved to species level and below.
There are two ways we shall explore for visualising the data:
Krona, which outputs interactive plots
Graphlan, which outputs static, publication ready plots
Interactive plots with Krona
Krona (Ondov et al. 2011)!!!! renders your Metaphlan output into a zoomable, multi-layered pie chart, and allows for hierarchical data (in our case taxonomic levels) to be explored.
In order to create a Krona plot we can use a tool to convert our output into a Krona-ready input. This tool is conveniently called metaphlan2krona. The command to use it is simple and looks like this:
Code
metaphlan2krona.py -p analysis/metaphlan/metaphlan_output.txt -k analysis/metaphlan/metaphlan.krona.txtRun this command and wait a few seconds for it to run. For our table it should only take a few moments, but on larger tables it could take a little longer.
Once our metaphlan.krona.txt file is generated we can then feed that directly into Krona, using:
Code
ktImportText analysis/metaphlan/metaphlan.krona.txt -o analysis/krona.htmlThis will also only take a short few moments to process.
Once it has ran you should be able to see krona.html in your analysis/ directory. Unfortunately we cannot view html files using the command line, and so we shall instead have to download it to your local computer.
First, open up gitbash in your CloudSPAN folder. Then we shall use the “secure copy” or scp function to download the file from your instance using this command:
Code
scp -i login-key-instanceXXX.pem ubuntu@instanceXXX.cloud-span.aws.york.ac.uk:~/cs_course/analysis/krona.html .replacing XXX with your instance number. Much like cp or mv commands, this is telling the command where to copy from (ubuntu@instanceXXX.cloud-span.aws.york.ac.uk:~/cs_course/analysis/krona.html) and then where to copy to (remember, the . means current working directory).
If you are struggling to get the download to work, don’t worry, you can access a copy of it here.
You may notice that the sections of the pie chart are incorrectly labelled with abundances rather than taxa names. This is because Krona expects all levels of taxonomy when generating the chart and has misread the abundances as a label also. To see more of a “real world” example we shall now look at the output of a Metaphlan run that captured all taxonomic levels (the --tax_lev flag set to a for “all”).
Generating a more detailed Krona plot
We have hidden a pre-ran Metaphlan all levels output in your data folder in a hidden directory, data/.fullmetaphlanrun. You can process this with Krona in the same way as before:
Code
ktImportText data/.fullmetaphlanrun/*.krona.txt -o analysis/krona_alltaxa.htmlNow you can download it from our instance to your local computer, again using scp:
Code
scp -i login-key-instanceXXX.pem ubuntu@instanceXXX.cloud-span.aws.york.ac.uk:~/cs_course/analysis/krona.html .Once again, substituting XXX for your instance number. Again if you’re struggling to get this to work, don’t worry, you can find a copy of it here.
As you can see tise plot is in much greater detail than our previous one. You can click on the different sections to see summaries of the abundances at different levels, as well as double click on a section to zoom into the sub-structure that particular clade (you can use the back and forward arrows at the top left to navigate back and forward).
From the interactive Krona figure, try and answer these questions:
What are the % abundances of the Coprothermobacterota and Firmicutes phyla respectively?
What is the % abundance of the SGB8555 strain of Coprothemobacter proteolyticus?
71% and 16%
10%
Because Krona outputs are portable .html files these can be sent to collaborators or uploaded for others to browse. However this format is not entirely suitable for publication. Next we shall try using Graphlan to produce publication ready figures.
Static plots with Graphlan
Graphlan does not yet work :(