6b0035d19769346baffe193ef9419c269d46f8d8
max
  Wed Sep 9 06:09:41 2026 -0700
hprc2annot: pcLAI column 10 is the ancestry centroid, not a segment coordinate

Reading the pcLAI authors' own format description
(github.com/AI-sandbox/hprc-pclai, README "Output format (BED)") while building
the same annotation as a native hg38 track showed that column 10 of the source
BED had been described wrongly here. It is not the PCA coordinate of a longer
ancestry segment the window belongs to; the authors call it the centroid, the
discretized pcLAI ancestry of the window written as the PCA centroid of its
ancestry cluster. That is why it only ever takes four values -- four clusters,
not four long shared segments. The old reading also implied a segmentation step
the method does not have: pcLAI predicts one coordinate per window, and the
blocks visible in the display are runs of windows with similar predictions.

Field renamed pcaSegment -> centroid in pclai.as with the description corrected,
and the mouseOver, the detailsScript exportFields and the description page
follow. The README also settles that windows are a fixed 1000 SNPs rather than a
fixed number of bases, and that thickStart is specified to equal chromStart, so
the occasional thickStart == chromStart-1 the converter works around is a bug in
their files rather than something we misread.

A field name and its description live inside each bigBed, so editing pclai.as
does nothing to a built collection. hprc2annotRewriteAs.sh re-emits a built
bigBed with the current .as -- no re-download, no column change, item count
checked across the round trip, and safe to re-run, unlike hprc2annotFixBed.sh.
All 460 pclai.bb were rewritten with it. Worth knowing: those files had been
built from an older pclai.as than the tree and nothing had noticed, so this is
the tool to run after any .as description edit.

genark: the "...Url" inside a detailsScript value must not be rebased the way
bigDataUrl is. hgc resolves a relative detailsScript Url against the track's own
bigDataUrl when it builds the details page, and bigDataUrl has already been
rebased, so the prefix landed twice: the pcLAI scatterplot had been asking for
contrib/hprc2annot/contrib/hprc2annot/pclaiRefPanel.json and quietly getting
nothing on every GenArk hub. In this layout the panel file is symlinked beside
the .bb, so relative-to-the-.bb is the bare file name; rebaseBeside() does that
and is idempotent, so addContrib can be re-run.

refs #35415

diff --git src/hg/makeDb/scripts/hprc2annot/hprc2annotBuildOne.sh src/hg/makeDb/scripts/hprc2annot/hprc2annotBuildOne.sh
index c884502a184..4302c95cc68 100755
--- src/hg/makeDb/scripts/hprc2annot/hprc2annotBuildOne.sh
+++ src/hg/makeDb/scripts/hprc2annot/hprc2annotBuildOne.sh
@@ -162,32 +162,34 @@
   inCount=$(grep -vcE '^track|^#|^browser' "$TMP/in.bed")
   grep -vE '^track|^#|^browser' "$TMP/in.bed" \
     | awk -F'\t' 'BEGIN{OFS="\t"}{print $1,$2,$3}' \
     | sizeFilter "$PANSIZES" | LC_COLLATE=C sort -k1,1 -k2,2n > "$TMP/c.bed"
   readDrops
   notEmpty "$TMP/c.bed" bed || exit 6
   bedToBigBed -type=bed3 -tab "$TMP/c.bed" "$PANSIZES" "$OUT/censatCentromeres.bb" 2>"$TMP/bb.log" \
     || { echo "BB_FAIL censatCen $ACC" >&2; cat "$TMP/bb.log" >&2; exit 6; }
   stat "$inCount" "$(wc -l < "$TMP/c.bed")" "centromere regions"
   ;;
 
 pclai)
   dl "$url" "$TMP/in.bed" || exit 5
   inCount=$(grep -vc '^#' "$TMP/in.bed")
   # -> bed9+3, name left blank (values shown on mouseover). Force thick = full item
-  # (source has occasional thickStart=chromStart-1). Parse the source name
-  # "SAMPLE/hN/<window>_(PC1,PC2)" into window + pca; col10 -> pcaSegment.
+  # (source has occasional thickStart=chromStart-1, against its own documented
+  # format). Parse the source name "SAMPLE/hN/<window>_(PC1,PC2)" into window +
+  # pca; col10 is the source's "centroid" column, the discretized ancestry of the
+  # window written as the PCA centroid of its ancestry cluster.
   grep -v '^#' "$TMP/in.bed" \
     | awk -F'\t' 'BEGIN{OFS="\t"}
         { seg=$4; sub(/^[^/]*\/[^/]*\//,"",seg); k=split(seg,b,"_"); pca=b[k];
           win=(pca!="")?substr(seg,1,length(seg)-length(pca)-1):seg;
           print $1,$2,$3,"",$5,$6,$2,$3,$9,win,pca,$10 }' \
     | sizeFilter "$PANSIZES" | LC_COLLATE=C sort -k1,1 -k2,2n > "$TMP/p.bed"
   readDrops
   notEmpty "$TMP/p.bed" bed || exit 6
   bedToBigBed -type=bed9+3 -tab -as=$SCR/pclai.as "$TMP/p.bed" "$PANSIZES" "$OUT/pclai.bb" 2>"$TMP/bb.log" \
     || { echo "BB_FAIL pclai $ACC" >&2; cat "$TMP/bb.log" >&2; exit 6; }
   stat "$inCount" "$(wc -l < "$TMP/p.bed")" "ancestry windows"
   ;;
 
 segdups)
   dl "$url" "$TMP/in.bed" || exit 5