94087f3f31945d133c187137ebbf0eddaf808dc3
gperez2
  Tue May 26 10:50:26 2026 -0700
Per author request, reordered the bars shown on the Genome Browser image to follow the biological tissue order. Following Max's suggestion in #37619, added the barChartReorder.py script and documented the reorder step in the mm10 and mm39 makedocs. refs #37001

diff --git src/hg/makeDb/doc/mm39/mouseDevTimecourse.txt src/hg/makeDb/doc/mm39/mouseDevTimecourse.txt
index 3af70f1ab91..5d66af27981 100644
--- src/hg/makeDb/doc/mm39/mouseDevTimecourse.txt
+++ src/hg/makeDb/doc/mm39/mouseDevTimecourse.txt
@@ -167,16 +167,49 @@
             label_color[cols[0]] = cols[4]
     with open(cats) as f:
         lines = f.readlines()
     out = []
     for line in lines:
         if not line.strip():
             out.append(line)
             continue
         cols = line.rstrip("\n").split("\t")
         cols[1] = label_color[cols[0]]
         out.append("\t".join(cols) + "\n")
     with open(cats, "w") as f:
         f.writelines(out)
     print("updated .categories: " + cats)
 EOF
+
+# 2026-05-26 (Gerardo): Reorder the bars shown on the Genome Browser image so
+# they follow the biological tissue order Peng requested (matching the .facets
+# row order set on 2026-05-13). Redmine #36998 note-46, #37001 note-29,
+# #37619 note-4.
+#
+# The bar order shown on the Genome Browser image is set by the column order
+# of expScores inside the .bb file at build time, so the .bb files have to be
+# rebuilt with the per-tissue expScores values reordered in every row, and a
+# matching .categories file in the same new order. The barChartReorder.py
+# script handles this: it reorders the expScores values in every bed row
+# dumped from the input .bb, writes a matching .categories file, and rebuilds
+# the .bb with bedToBigBed. Run `barChartReorder.py --help` for argument
+# descriptions.
+
+cd /hive/data/outside/woldlab/mouseDevTimecourse/mm39
+
+SCRIPT=~/kent/src/hg/makeDb/scripts/barChartReorder/barChartReorder.py
+
+# Reorder both M21 .bb files (TPM and FPKM) using the same .facets order.
+# Both runs write the same .categories output; the second overwrites with
+# identical content.
+for variant in TPM FPKM; do
+    "$SCRIPT" \
+        --bb            mouse_development_${variant}_M21_mm39.bb \
+        --categories    mouse_development_M21.categories \
+        --facets        mouse_development_M21.facets \
+        --chromSizes    /hive/data/genomes/mm39/chrom.sizes \
+        --outBb         mouse_development_${variant}_M21_mm39.bb.new \
+        --outCategories mouse_development_M21.categories.new
+    mv mouse_development_${variant}_M21_mm39.bb.new mouse_development_${variant}_M21_mm39.bb
+    mv mouse_development_M21.categories.new        mouse_development_M21.categories
+done
 ##############################################################################