Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 7, 2024
1 parent 97d2f43 commit fb79563
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions docs/how-to/ChIP_seq_genomic_ranges_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
"outputs": [],
"source": [
"# Core scverse libraries\n",
"import scanpy as sc\n",
"import numpy as np\n",
"import pandas as pd\n",
"import genomic_features as gf\n",
"\n",
"# Data retrieval\n",
"import pooch\n",
"import bioframe\n",
"import seaborn\n",
"import matplotlib.pyplot as plt"
Expand Down Expand Up @@ -268,7 +265,7 @@
"source": [
"ctcf_peak = bioframe.read_table(\n",
" \"https://www.encodeproject.org/files/ENCFF417KHZ/@@download/ENCFF417KHZ.bed.gz\",\n",
" schema=\"narrowPeak\"\n",
" schema=\"narrowPeak\",\n",
")\n",
"\n",
"ctcf_peak"
Expand Down Expand Up @@ -615,7 +612,7 @@
}
],
"source": [
"genes = ensdb.genes( \n",
"genes = ensdb.genes(\n",
" filter=gf.filters.GeneBioTypeFilter(\"protein_coding\"),\n",
")\n",
"\n",
Expand Down Expand Up @@ -1313,10 +1310,7 @@
],
"source": [
"gene_ov = bioframe.overlap(\n",
" ctcf_peak,\n",
" genes,\n",
" cols2=[\"seq_name\", \"gene_seq_start\", \"gene_seq_end\"],\n",
" how='inner'\n",
" ctcf_peak, genes, cols2=[\"seq_name\", \"gene_seq_start\", \"gene_seq_end\"], how=\"inner\"\n",
")\n",
"\n",
"gene_ov"
Expand Down Expand Up @@ -1494,8 +1488,7 @@
}
],
"source": [
"exons = ensdb.exons(\n",
" filter=gf.filters.GeneIDFilter(gene_ov[\"gene_id_\"]))\n",
"exons = ensdb.exons(filter=gf.filters.GeneIDFilter(gene_ov[\"gene_id_\"]))\n",
"\n",
"exons[\"seq_name\"] = exons[\"seq_name\"].map(hg38.alias_dict)\n",
"\n",
Expand Down Expand Up @@ -2337,11 +2330,11 @@
],
"source": [
"# Create a histogram\n",
"palette = seaborn.color_palette(\"ch:s=.25,rot=-.25\", \n",
" len(exon_ov[\"gene_feature\"].unique()))\n",
"palette = seaborn.color_palette(\n",
" \"ch:s=.25,rot=-.25\", len(exon_ov[\"gene_feature\"].unique())\n",
")\n",
"\n",
"ax = seaborn.histplot(exon_ov[\"gene_feature\"], \n",
" stat=\"percent\")\n",
"ax = seaborn.histplot(exon_ov[\"gene_feature\"], stat=\"percent\")\n",
"\n",
"# Set ylim\n",
"plt.ylim(0, 100)\n",
Expand All @@ -2352,14 +2345,16 @@
"\n",
"# Add values on top of the bars\n",
"for p in ax.patches:\n",
" ax.annotate(f'{p.get_height():.2f}%', \n",
" (p.get_x() + p.get_width() / 2., p.get_height()), \n",
" ha='center', \n",
" va='center',\n",
" fontsize=10, \n",
" color='black', \n",
" xytext=(0, 5), \n",
" textcoords='offset points')\n",
" ax.annotate(\n",
" f\"{p.get_height():.2f}%\",\n",
" (p.get_x() + p.get_width() / 2.0, p.get_height()),\n",
" ha=\"center\",\n",
" va=\"center\",\n",
" fontsize=10,\n",
" color=\"black\",\n",
" xytext=(0, 5),\n",
" textcoords=\"offset points\",\n",
" )\n",
"\n",
"# Show the plot\n",
"plt.show()"
Expand Down Expand Up @@ -2774,7 +2769,9 @@
" ignore_downstream=True,\n",
" k=1,\n",
")\n",
"out[out[\"distance\"] < 2000] #filter for peaks 2000kb upstream or closer to promoter region\n",
"out[\n",
" out[\"distance\"] < 2000\n",
"] # filter for peaks 2000kb upstream or closer to promoter region\n",
"out"
]
}
Expand Down

0 comments on commit fb79563

Please sign in to comment.