Skip to content

Commit

Permalink
Merge pull request bedapub#273 from bedapub/cell_anno_fix
Browse files Browse the repository at this point in the history
Small fix in cell annotation workbook as per bedapub#271
  • Loading branch information
kohleman authored Feb 7, 2023
2 parents 2f1764d + 4d05797 commit e8237a3
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion workbooks/celltype_annotation_besca.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
" clusters = \"leiden_citeseq\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"adata.uns['log1p'] = {'base' : None} # Fix for bug related to scanpy version scverse/scanpy#2239"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -191,6 +200,24 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"### Export top marker genes per celltype to .tsv file to facilitate checking the annotation\n",
"top5s=list()\n",
"for myc in DEgenes.keys():\n",
" top5s=top5s+list(DEgenes[myc].sort_values(\"Log2FC\", ascending=False).iloc[0:5,:]['Name'])\n",
" DEgenes[myc].sort_values(\"Log2FC\", ascending=False).iloc[0:50,:].to_csv(results_folder + \"/figures/TopMarkergenes-\" + clusters + \"_\"+ myc + \"_top50_wilcox.csv\", sep=\"\\t\",index=False)\n",
"\n",
"### Generate plots of the top marker genes \n",
"sc.pl.dotplot(adata, var_names=top5s, groupby=clusters, dot_max=0.8,vmax=3, dendrogram=True,save=\"TopMarkerplots-\"+clusters+\".svg\")\n",
"\n",
"sc.pl.matrixplot(adata, var_names=top5s, groupby=clusters, standard_scale='var', dendrogram=True, save=\"TopMarkerplots-\"+clusters+\".svg\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1332,12 +1359,32 @@
"metadata": {},
"outputs": [],
"source": [
"labeloi=\"celltype3\"\n",
"\n",
"### Perform DE cells of each celltype3 vs. all other cells\n",
"DEgenes = bc.tl.dge.get_de(\n",
" adata, \"celltype3\", demethod=\"wilcoxon\", topnr=5000, logfc=1, padj=0.05\n",
" adata, labeloi, demethod=\"wilcoxon\", topnr=5000, logfc=1, padj=0.05\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"### Export top marker genes per celltype to .tsv file to facilitate checking the annotation\n",
"top5s=list()\n",
"for myc in DEgenes.keys():\n",
" top5s=top5s+list(DEgenes[myc].sort_values(\"Log2FC\", ascending=False).iloc[0:5,:]['Name'])\n",
" DEgenes[myc].sort_values(\"Log2FC\", ascending=False).iloc[0:50,:].to_csv(results_folder + \"/figures/TopMarkergenes-\" + labeloi + \"_\"+ myc + \"_top50_wilcox.csv\", sep=\"\\t\",index=False)\n",
"\n",
"### Generate plots of the top marker genes \n",
"sc.pl.dotplot(adata, var_names=top5s, groupby=labeloi, dot_max=0.8,vmax=3, dendrogram=True, save=\"TopMarkerplots-\"+labeloi+\".svg\")\n",
"\n",
"sc.pl.matrixplot(adata, var_names=top5s, groupby=labeloi, standard_scale='var', dendrogram=True, save=\"TopMarkerplots-\"+labeloi+\".svg\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit e8237a3

Please sign in to comment.