Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions code/reference_data/rss_ld_sketch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@
" G = np.array(dosage_matrix, dtype=np.float32).T # (n_samples, n_variants)\n",
" del dosage_matrix\n",
" G = fill_missing_col_means(G)\n",
"\n",
" # variant-wise scaling\n",
" col_mean = G.mean(axis=0, keepdims=True)\n",
" col_std = G.std(axis=0, keepdims=True)\n",
" # avoid division by zero\n",
" col_std[col_std == 0] = 1.0\n",
" G = (G - col_mean) / col_std\n",
"\n",
" U = W.T @ G # (B, n_variants)\n",
" del G\n",
"\n",
Expand Down Expand Up @@ -806,6 +814,7 @@
},
{
"cell_type": "markdown",
"id": "1968fbf4",
"metadata": {},
"source": [
"### Step 4 -- Load LD sketch data into R\n",
Expand All @@ -822,7 +831,10 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a05b576",
"metadata": {},
"outputs": [],
"source": [
"library(pecotmr)\n",
"\n",
Expand All @@ -843,12 +855,11 @@
"})\n",
"cat(\"R dimensions:\", dim(res_r$LD_matrix), \"\\n\")\n",
"res_r$LD_matrix[1:3, 1:3]"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
"id": "aad6e458",
"metadata": {},
"source": [
"**Tested output** (ADSP R5 EUR chr22, 10000 pseudo-samples, 2Mb region, 9188 variants):\n",
Expand Down Expand Up @@ -903,7 +914,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.13"
"version": "3.12.2"
},
"sos": {
"kernels": [
Expand All @@ -920,4 +931,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}