Skip to content

Commit 20e7b30

Browse files
committed
Move more code over to the plugin from core
1 parent df1f51e commit 20e7b30

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

multiqc_xenium_extra/xenium_extra.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
from pathlib import Path
5-
from typing import Any, Dict, Optional
5+
from typing import Any, Dict, Optional, Tuple
66

77
import importlib_metadata
88
import numpy as np
@@ -14,11 +14,43 @@
1414
from multiqc.plots import bargraph, box, linegraph, scatter, table
1515
from multiqc.plots.table_object import ColumnDict, TableConfig
1616
from multiqc.utils import mqc_colour
17-
from multiqc.modules.xenium.xenium import GENE_CATS, categorize_feature
1817

1918
log = logging.getLogger("multiqc")
2019

2120

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+
2254
def xenium_extra_execution_start():
2355
"""Code to execute after config files and command line flags have been parsed.
2456

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "multiqc_xenium_extra"
7-
version = "1.0.0"
7+
version = "1.0.1"
88
authors = [
99
{name = "Phil Ewels", email = "phil.ewels@seqera.io"},
1010
]

0 commit comments

Comments
 (0)