Why do the structures seem to differ between the multiqc report and usage in a notebook?

I have a custom table loaded:

In the MultiQC report it displays as expected

ToL ID Species Class Order
idDroMela1 Drosophila melanogaster Insecta Diptera

But when I access this via the python functions

```{python}
pprint(multiqc.get_module_data(module="dtol"))
```

It prints

{'idDroMela1': {'Class': 'Insecta',
                'Order': 'Diptera',
                'Species': 'Drosophila melanogaster'}}

and

```{python}
if "dtol" in multiqc.list_modules():
    display(multiqc.get_plot("dtol", "dtol-section").show())
```

prints

Species Class Order
idDroMela1 Drosophila melanogaster Insecta Diptera

Hi @mahesh.binzerpanchal,

I don’t really understand the question sorry - what is it that you’re trying to do / that doesn’t work? It looks valid to me?

Phil

I want the table given by get_module_data to be the same as what’s given internally to MultiQC when it’s putting the table in the report. The ToL ID is lost on the same table.

The ID itself is there as the key?

{'idDroMela1':

You mean you want the column heading ToL ID to be shown?

This is part of the table config and not the module data, which is why it’s not returned.

Yes, I would like the heading to be displayed in the Notebook version too to be displayed. How would I go about getting that out?

Where’s the data coming from? dtol isn’t a stock module… Is this custom content?

Yes, it’s loaded through the config with

custom_data:
  dtol:
    file_format: "tsv"
    section_name: "DToL"
    description: "Darwin Tree of Life identifier and related meta data."
    plot_type: "table"
sp: # Search pattern
  dtol:
    fn: "DToL.tsv"

When the MultiQC report displays it, it displays with the “ToL ID” header, but it’s not possible it seems in a notebook to get the exact same table.

I feel like the issue is the same with the plots as well. Even though you can display plots in a notebook, they’re not as feature rich as you get in the MultiQC html.

Everything is possible with a little config :slight_smile:

table_config = {
    "col1_header": "ToL ID"
}

I’m not entirely sure why get_plot() isn’t returning the table with this config though, if it is ending up in the report. I guess there is some order of logic somewhere that’s being lost…

Phil

Tables in notebooks are different from plots because they are not rendered with Plotly, but rather we just wrap data in a Pandas DataFrame object and return it to the cell, so the notebook would display it with it’s intefrated widget. This, there is not going to be any of the HTML-verion rich functionality there, for now.

However, the col1 header should be possible to display as you are pointing out, so I added that in this PR:

1 Like

So, setting the config in the yaml didn’t help for the notebook case. It works for the normal multiqc report, but the pandas DataFrame object remains the same.
Hopefully Vlad’s PR fixes that though.

It’s also a shame we don’t get the same HTML version rich functionality there. What was the decision behind that?

MultiQC tables use a bunch of custom javascript, which is why we didn’t package it up in the same way. In contrast, Plotly plots are generally well supported natively by notebook environments.

You can try using MultiQC tables yourself if you want, the function is multiqc.plot.table() - but it’s likely that we need to pull some extra magic to somehow inject in the custom CSS and JavaScript for them to function properly.

Feel free to open an issue for this on the MultiQC repo if it’s something you’d like to see.

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