eb9441d7f6347f6b9ed58aeae694c75ec7b3eb61
galt
  Thu Aug 28 17:03:18 2025 -0700
Improve the column names for single cell output using combined facets and matrix, changed column count to cell count, column val to read count. Also updated the 4 html files with improved notations about those columns, and corrected note about expCount field. Added a new tag for trackDb singleCellColumnNames off to support old default column names. fixes #34628

diff --git src/hg/hgc/facetedBar.c src/hg/hgc/facetedBar.c
index 4e2c18bb184..9770a420b76 100644
--- src/hg/hgc/facetedBar.c
+++ src/hg/hgc/facetedBar.c
@@ -120,41 +120,62 @@
 /* Set up url that has enough context to get back to us.  */
 struct dyString *returnUrl = dyStringNew(0);
 dyStringPrintf(returnUrl, "../cgi-bin/hgc?g=%s", trackName);
 if (item != NULL)
     dyStringPrintf(returnUrl, "&i=%s", item);
 dyStringPrintf(returnUrl, "&%s", cartSidUrlString(cart));
 
 /* Working within a form we save context.  It'd be nice to work outside of form someday. */
 printf("<form action=\"../cgi-bin/hgc\" name=\"facetForm\" ");
 printf("method=\"GET\">\n");
 printf("<div style=\"background-color:white\">");
 cartSaveSession(cart);
 cgiContinueHiddenVar("g");
 cgiContinueHiddenVar("i");
 
+char *valFieldName = "val";
+
+boolean singleCell = !trackDbSettingOff(tdb, "singleCellColumnNames");
+
+if (singleCell)
+    {
+    if (sameString(selected->fields[1], "count"))
+	selected->fields[1] = cloneString("cell count");
+    int i;
+    for (i = selected->fieldCount -1; i >= 0; --i)
+	{
+	if (sameString(selected->fields[i], "val"))
+	    {
+	    selected->fields[i] = cloneString("read count");
+	    break;
+	    }
+	}
+    valFieldName = "read count";
+    }
 
 /* Set up context for functions that wrap output fields */
 struct wrapContext context = {
-		              .valIx = fieldedTableFindFieldIx(selected, "val"),
+                              .valIx = fieldedTableFindFieldIx(selected, valFieldName),
 			      .colorIx = fieldedTableFindFieldIx(selected, "color"), 
 			     };
 context.maxVal = fieldedTableMaxInCol(selected, context.valIx);
 
 /* Add wrapper function(s) */
-hashAdd(wrapperHash, "val", wrapVal);
+hashAdd(wrapperHash, valFieldName, wrapVal);
 
 /* Pick which fields to display.  We'll take the first field whatever it is
  * named, and also count, and the "val" field we added and wrapped. */
 char displayList[256];
+if (singleCell)
+    safef(displayList, sizeof(displayList), "%s,cell count,read count", selected->fields[0]);
+else
     safef(displayList, sizeof(displayList), "%s,count,val", selected->fields[0]);
 
 facetedTableWriteHtml(facTab, cart, selected, selectedFf, displayList,
     returnUrl->string, 45, wrapperHash, &context, 7);
 
-
 /* Clean up and go home. */
 printf("</div></form>\n");
 facetedTableFree(&facTab);
 sqlDisconnect(&conn);
 }