Giter Site home page Giter Site logo

Palette of colors about pyani HOT 2 CLOSED

MathGon avatar MathGon commented on June 3, 2024
Palette of colors

from pyani.

Comments (2)

widdowquinn avatar widdowquinn commented on June 3, 2024

Good question.

I've not really settled on a best way, yet. I think one of the weak points at the moment is the customisability of colours - especially for the class markers at the leaves of the trees.

For now, the defaults are set in pyani_config.py, so are only modifiable before module installation, or by manually changing the module, post-install (not a great thing). Some of the colours are matplotlib or R builtins, others are custom colour schemes defined in the config file, or in pyani_graphics.py. It's a bit messy.

So far as the script average_nucleotide_identity.py is concerned, it will only use the defaults, unless you edit it directly.

It is possible to use the module interactively, or to write your own wrapper script - I'm in the process of writing the relevant documentation in the docs branch. It's very rudimentary, and the only available file is still incomplete: https://github.com/widdowquinn/pyani/blob/docs/docs/using_pyani_as_a_module.ipynb

Briefly, the heatmap rendering is done with either heatmap_mpl() for matplotlib output, or heatmap_r() for the R output. The function prototypes are not quite the same: heatmap_mpl() takes a pandas DataFrame, where heatmap_r() currently takes a tab-separated data file (which can be trivially generated from a pandas DataFrame); matplotlib uses the output filename to determine output format, but this is specified for the R function. Otherwise, they are both quite similar:

def heatmap_mpl(df, outfilename=None, title=None, cmap=None,
                vmin=None, vmax=None, labels=None, classes=None):
    """Returns matplotlib heatmap with cluster dendrograms.
    - df - pandas DataFrame with relevant data
    - outfilename - path to output file (indicates output format)
    - cmap - colourmap option
    - vmin - float, minimum value on the heatmap scale
    - vmax - float, maximum value on the heatmap scale
    - labels - dictionary of alternative labels, keyed by default sequence
               labels
    - classes - dictionary of sequence classes, keyed by default sequence
                labels
    """

def heatmap_r(infilename, outfilename, title=None, cmap="bluered",
              vmin=None, vmax=None, gformat=None, labels=None, classes=None):
    """Uses R to draw heatmap, and returns R code used for rendering.
    - infilename - path to tab-separated table with data
    - outfilename - path to output file
    - cmap - colourmap option
    - vmin - float, minimum value on the heatmap scale
    - vmax - float, maximum value on the heatmap scale
    - gformat - string indicating graphics output format
    - labels - dictionary of alternative labels, keyed by default sequence
               labels
    - classes - dictionary of sequence classes, keyed by default sequence
                labels
    """

The cmap argument only controls the heatmap colours, but this can be set when calling the function.

The class colours are hardcoded in the R function to be rainbow(n) for n classes. In matplotlib the colours are currently hardcoded in pyani_config.MPL_CBAR. Making this something changeable in the function prototype/a separate config file is definitely an enhancement worth making, IMO.

from pyani.

widdowquinn avatar widdowquinn commented on June 3, 2024

TODO: using .env, pydotenv, a proper config.py Config class and/or other methods, implement colour palette definitions and other parameterisation.

from pyani.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.