Mercurial > repos > bimib > marea_2
changeset 255:3e16bced8062 draft
Uploaded
author | luca_milaz |
---|---|
date | Sun, 04 Aug 2024 14:23:00 +0000 |
parents | 2af2d2641e3e |
children | 4058344a661f |
files | marea_2/flux_to_map.py |
diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/marea_2/flux_to_map.py Sun Aug 04 14:10:44 2024 +0000 +++ b/marea_2/flux_to_map.py Sun Aug 04 14:23:00 2024 +0000 @@ -5,7 +5,6 @@ import sys import numpy as np import pandas as pd -import matplotlib.pyplot as plt import itertools as it import scipy.stats as st import lxml.etree as ET @@ -818,6 +817,14 @@ """Convert an RGBA color to HEX format.""" return '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255)) +def reds_cmap(value): + """Map normalized value to RGB color using the Reds colormap.""" + # The `Reds` colormap starts with white and transitions to red + r = value + g = 0 + b = 0 + return (r, g, b) + def computeEnrichmentMedoids(metabMap :ET.ElementTree, class_pat :Dict[str, List[List[float]]], ids :List[str]) -> None: metabMap_mean = metabMap.copy() @@ -845,13 +852,10 @@ for key, value in means.items(): means[key] = means[key] / max_flux_means - cmap = plt.cm.Reds - norm = plt.Normalize(vmin=0, vmax=1) - - colors_median_rgb = {k: cmap(norm(v)) for k, v in medians.items()} + colors_median_rgb = {k: reds_cmap(v) for k, v in medians.items()} colors_median = {k: rgba_to_hex(c) for k, c in colors_median_rgb.items()} - colors_mean_rgb = {k: cmap(norm(v)) for k, v in means.items()} + colors_mean_rgb = {k: reds_cmap(v) for k, v in means.items()} colors_mean = {k: rgba_to_hex(c) for k, c in colors_mean_rgb.items()} for rxn_id in ids: