Spaces:
Running on Zero
Label the +1 pseudocount in Studio CSV fold changes
I replayed seven saved Studio runs from the released checkpoint on MPS. In 75 of 629 exported rows, untreated expression was zero and predicted expression was positive, yet the CSV reported a finite fold_change. For example, one row with untreated log expression 0 and predicted log expression 0.737 exported a fold change of 2.0903 and a percent change of 109.03.
The expression values use log1p. Exponentiating their difference gives (1 + predicted expression) / (1 + untreated expression), which includes a pseudocount of 1. I renamed both CSV columns to identify that pseudocount. I checked that all 629 data rows stayed identical.
Regression test (save as test.cjs and run node test.cjs from the Space checkout). With untreated expression 1 and predicted expression 3, the pseudocount ratio is 2. The test fails on the current CSV headers and passes with this change.
const assert = require("node:assert/strict");
const fs = require("node:fs");
const vm = require("node:vm");
let csv;
const source = fs.readFileSync("static/app.js", "utf8");
vm.runInNewContext(source.replace(/\}\)\(\);\s*$/, `
appState.currentResult = { all_genes: [{
sym: "+GENE", ctrl_expr: Math.log1p(1),
pred_expr: Math.log1p(3), lfc: Math.log(2),
}] };
downloadPredictionsCsv();
})();`), {
performance, window: {}, setTimeout() {},
document: {
readyState: "loading", addEventListener() {},
createElement: () => ({ click() {} }),
body: { appendChild() {}, removeChild() {} },
},
Blob: class { constructor(parts) { csv = parts.join(""); } },
URL: { createObjectURL() {}, revokeObjectURL() {} },
});
const [header, row] = csv.trim().split("\n");
assert.equal(header.split(",").slice(-2).join(","),
"pct_change_with_pseudocount_1,fold_change_with_pseudocount_1");
assert.equal(row.split(",").slice(-2).join(","), "100.00,2.0000");
🤖 Generated with Claude Code