|
2 | 2 |
|
3 | 3 | import logging |
4 | 4 | from pathlib import Path |
5 | | -from typing import Any, Dict, Optional |
| 5 | +from typing import Any, Dict, Optional, Tuple |
6 | 6 |
|
7 | 7 | import importlib_metadata |
8 | 8 | import numpy as np |
|
14 | 14 | from multiqc.plots import bargraph, box, linegraph, scatter, table |
15 | 15 | from multiqc.plots.table_object import ColumnDict, TableConfig |
16 | 16 | from multiqc.utils import mqc_colour |
17 | | -from multiqc.modules.xenium.xenium import GENE_CATS, categorize_feature |
18 | 17 |
|
19 | 18 | log = logging.getLogger("multiqc") |
20 | 19 |
|
21 | 20 |
|
| 21 | +# Define gene categories for coloring based on Xenium naming conventions |
| 22 | +GENE_CATS = { |
| 23 | + "Pre-designed": {"color": "rgba(31, 119, 180, 0.8)"}, # Standard gene names - blue with transparency |
| 24 | + "Custom": {"color": "rgba(255, 127, 14, 0.8)"}, # Orange with transparency |
| 25 | + "Negative Control Probe": {"color": "rgba(214, 39, 40, 0.8)"}, # Red with transparency |
| 26 | + "Negative Control Codeword": {"color": "rgba(255, 153, 0, 0.8)"}, # Yellow/Orange with transparency |
| 27 | + "Genomic Control Probe": {"color": "rgba(227, 119, 194, 0.8)"}, # Pink with transparency |
| 28 | + "Unassigned Codeword": {"color": "rgba(127, 127, 127, 0.8)"}, # Gray with transparency |
| 29 | + "Deprecated Codeword": {"color": "rgba(188, 189, 34, 0.8)"}, # Olive with transparency |
| 30 | +} |
| 31 | + |
| 32 | + |
| 33 | +def categorize_feature(feature_name) -> Tuple[str, str]: |
| 34 | + """Categorize a feature based on its name |
| 35 | + Splits the feature name into category and feature id""" |
| 36 | + # Check prefixes directly instead of using regex for better performance |
| 37 | + category = "" |
| 38 | + feature_id = feature_name.split("_")[1] if "_" in feature_name else feature_name |
| 39 | + if feature_name.startswith("Custom_"): |
| 40 | + category = "Custom" |
| 41 | + elif feature_name.startswith("NegControlProbe_"): |
| 42 | + category = "Negative Control Probe" |
| 43 | + elif feature_name.startswith("NegControlCodeword_"): |
| 44 | + category = "Negative Control Codeword" |
| 45 | + elif feature_name.startswith("GenomicControlProbe_"): |
| 46 | + category = "Genomic Control Probe" |
| 47 | + elif feature_name.startswith("UnassignedCodeword_"): |
| 48 | + category = "Unassigned Codeword" |
| 49 | + else: |
| 50 | + category = "Pre-designed" # Default category for standard gene names |
| 51 | + return category, feature_id |
| 52 | + |
| 53 | + |
22 | 54 | def xenium_extra_execution_start(): |
23 | 55 | """Code to execute after config files and command line flags have been parsed. |
24 | 56 |
|
|
0 commit comments