Skip to content

Commit

Permalink
fix -omics tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
zoepiran committed May 3, 2024
1 parent 921bde6 commit a40e7f8
Showing 1 changed file with 0 additions and 89 deletions.
89 changes: 0 additions & 89 deletions docs/tutorials/biolord_omics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -480,95 +480,6 @@
"adata_emb = adata_emb[np.concatenate(idx)]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"tags": []
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'adata_preds' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-15-51b7e9f00b20>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpca\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0madata_preds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0msc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mneighbors\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0madata_preds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0msc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mumap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0madata_preds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'adata_preds' is not defined"
]
}
],
"source": [
"sc.pp.pca(adata_preds)\n",
"sc.pp.neighbors(adata_preds)\n",
"sc.tl.umap(adata_preds)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"adata_preds.obs[\"status_control_counter\"] = adata_preds.obs[\"status_control\"].copy()\n",
"adata_preds.obs[\"status_control_counter\"] = adata_preds.obs[\"status_control_counter\"].cat.rename_categories(\n",
" {\"Infected\": \"Infected (c-pred.)\", \"Uninfected\": \"Uninfected (c-pred.)\"}\n",
")\n",
"\n",
"adata_preds.uns[\"status_control_counter_colors\"] = [\"#bdc3c7\", \"#f01313\", \"#6f8e32\"]\n",
"\n",
"size = 4\n",
"fig, axs = plt.subplots(1, 2, figsize=(2 * (size + 1), size))\n",
"\n",
"for i, c in enumerate([\"status_control_counter\", \"zone\"]):\n",
" sc.pl.umap(adata_preds, color=[c], ax=axs[i], show=False)\n",
"\n",
" axs[i].set_axis_off()\n",
"\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"scores_genes_ttest = {}\n",
"for gene in adata_source.var_names:\n",
" res = ttest_rel(\n",
" a=adata_preds[adata_preds.obs[\"status_control\"] == \"Infected\", gene].X,\n",
" b=adata_preds[adata_preds.obs[\"status_control\"] == \"Control\", gene].X,\n",
" )\n",
"\n",
" scores_genes_ttest[gene] = {\"statistic\": res.statistic[0], \"pvalue\": res.pvalue[0]}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"df_pvalue = pd.DataFrame.from_dict(scores_genes_ttest).T\n",
"df_pvalue.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 16,
Expand Down

0 comments on commit a40e7f8

Please sign in to comment.