dizak/mothulity

Remove mpld3

Closed this issue · 5 comments

dizak commented

Description

The mpld3 package which is used by the mothulity.utilities.draw_rarefaction function to produce an interactive rarefaction plot requires matplotlib<=2.0.0 and numpy<=1.13.3. This, in turn, restricts requires python<3.7.

The plot produced is not worth the problem it causes. It should be replaced with plain matplotlib for now. In the future, another solution (probably bokeh or self-crafted d3.js code) should be used.

dizak commented

@Setnea are you willing to do that?

dizak commented

@Setnea assigned you as we spoke.

I forgot mpld3 is also used to produce the scatter plot - mothulity.utilities.draw_scatter.

Another thing to bear in mind is that the way the rarefaction and NMDS plots are embedded into the final report must change. You can see how it is done with other static plots, like dendrograms or heatmaps.

I propose to try out alternative solutions to keep our output in html form.
That way we don't have to change other parts of the report processing, especially that we're planning to make plots more interactive in the future.

dizak commented

It is a great idea, especially that I like the output sample you have shown me in person. Keep in mind that when the report is generated, the rarefaction plot HTML is parsed by bs4 and only selected part of it are embedded into the final HTML report.

The process looks like this:

  1. Save the HTML to file with mothulity_draw

  2. mothulity finds the ./alpha/{}raref.html and parses it with mothulity.utilities.parse_html

  3. mothulity.utilities.parse_html looks for div and script tags

elif html_type == "rarefaction" or html_type == "nmds":
return {"div": str(soup.div),
"script": str(soup.script)}

  1. The output from mothulity.utilities.parse_html is passed as one of the mothulity.mothulity template_vars

So, draw_rarefaction must render HTML with the plot inside a single div container and there must a proper js script inside the script tag

If you find it too cumbersome for the limited time we have, then just use the static image

dizak commented

Closed with #153