Skip to content

Commit

Permalink
sphinx problem fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH0066 committed Jul 3, 2024
1 parent e972920 commit 5c5d23d
Show file tree
Hide file tree
Showing 29 changed files with 636 additions and 512 deletions.
45 changes: 27 additions & 18 deletions docs/analysis_guide/TAD_calling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
],
"source": [
"resolution = 10000\n",
"coolfile=f'./HFF_MicroC.mcool::resolutions/{resolution}'\n",
"clr=cooler.Cooler(coolfile)\n",
"windows = [3*resolution, 5*resolution, 10*resolution, 25*resolution]\n",
"coolfile = f\"./HFF_MicroC.mcool::resolutions/{resolution}\"\n",
"clr = cooler.Cooler(coolfile)\n",
"windows = [3 * resolution, 5 * resolution, 10 * resolution, 25 * resolution]\n",
"insulation_table = insulation(clr, windows, verbose=True)"
]
},
Expand Down Expand Up @@ -296,11 +296,17 @@
"metadata": {},
"outputs": [],
"source": [
"df = insulation_table[['chrom', 'start', 'end', \n",
" 'log2_insulation_score_30000', \n",
" 'log2_insulation_score_50000', \n",
" 'log2_insulation_score_100000', \n",
" 'log2_insulation_score_250000']]"
"df = insulation_table[\n",
" [\n",
" \"chrom\",\n",
" \"start\",\n",
" \"end\",\n",
" \"log2_insulation_score_30000\",\n",
" \"log2_insulation_score_50000\",\n",
" \"log2_insulation_score_100000\",\n",
" \"log2_insulation_score_250000\",\n",
" ]\n",
"]"
]
},
{
Expand Down Expand Up @@ -355,18 +361,21 @@
"ten.add(pos=\"bottom\", height=1.5, hspace=0.05)\n",
"ten.add(pos=\"bottom\", height=1, hspace=0.07)\n",
"\n",
"tc.pl.mapC(\n",
" ax=ten.axs(0),\n",
" mat=HFF,\n",
" label=\"HFF\",\n",
" map_type=\"rec\",\n",
" height=150\n",
")\n",
"tc.pl.mapC(ax=ten.axs(0), mat=HFF, label=\"HFF\", map_type=\"rec\", height=150)\n",
"\n",
"tc.pl.bdgmat_track(ax=ten.axs(1), bed=df, regions=regions, style='line', label='insulation score')\n",
"tc.pl.scale_track(ax=ten.axs(1), region=regions, scale_adjust=\"Mb\", tick_pos=\"bottom\", ratio2ax=1, space=0)\n",
"tc.pl.bdgmat_track(\n",
" ax=ten.axs(1), bed=df, regions=regions, style=\"line\", label=\"insulation score\"\n",
")\n",
"tc.pl.scale_track(\n",
" ax=ten.axs(1),\n",
" region=regions,\n",
" scale_adjust=\"Mb\",\n",
" tick_pos=\"bottom\",\n",
" ratio2ax=1,\n",
" space=0,\n",
")\n",
"\n",
"#tc.savefig('outfile.pdf')"
"# tc.savefig('outfile.pdf')"
]
}
],
Expand Down
74 changes: 35 additions & 39 deletions docs/analysis_guide/compartment_calling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
],
"source": [
"import cooler\n",
"import pandas as pd\n",
"import cooltools\n",
"import pandas as pd\n",
"\n",
"resolution = 100000\n",
"coolfile=f'/Users/yuanzan/Downloads/HFF_MicroC.mcool::resolutions/{resolution}'\n",
"clr=cooler.Cooler(coolfile)"
"coolfile = f\"/Users/yuanzan/Downloads/HFF_MicroC.mcool::resolutions/{resolution}\"\n",
"clr = cooler.Cooler(coolfile)"
]
},
{
Expand Down Expand Up @@ -197,15 +197,16 @@
"source": [
"## fasta sequence is required for calculating binned profile of GC conent\n",
"import bioframe\n",
"\n",
"bins = clr.bins()[:]\n",
"### Unified chromosome Naming\n",
"bins['chrom'] = bins['chrom'].str.lstrip('chr')\n",
"bins[\"chrom\"] = bins[\"chrom\"].str.lstrip(\"chr\")\n",
"\n",
"hg38_genome = bioframe.load_fasta('/Users/yuanzan/Documents/ref/GRCh38.105.fa');\n",
"hg38_genome = bioframe.load_fasta(\"/Users/yuanzan/Documents/ref/GRCh38.105.fa\")\n",
"## note the next command may require installing pysam\n",
"gc_cov = bioframe.frac_gc(bins[['chrom', 'start', 'end']], hg38_genome)\n",
"gc_cov['chrom'] = 'chr' + gc_cov['chrom'].astype(str)\n",
"gc_cov.to_csv('hg38_gc_cov_100kb.tsv',index=False,sep='\\t')\n",
"gc_cov = bioframe.frac_gc(bins[[\"chrom\", \"start\", \"end\"]], hg38_genome)\n",
"gc_cov[\"chrom\"] = \"chr\" + gc_cov[\"chrom\"].astype(str)\n",
"gc_cov.to_csv(\"hg38_gc_cov_100kb.tsv\", index=False, sep=\"\\t\")\n",
"display(gc_cov)"
]
},
Expand Down Expand Up @@ -271,11 +272,14 @@
}
],
"source": [
"view_df = pd.DataFrame({'chrom': clr.chromnames,\n",
" 'start': 0,\n",
" 'end': clr.chromsizes.values,\n",
" 'name': clr.chromnames}\n",
" )\n",
"view_df = pd.DataFrame(\n",
" {\n",
" \"chrom\": clr.chromnames,\n",
" \"start\": 0,\n",
" \"end\": clr.chromsizes.values,\n",
" \"name\": clr.chromnames,\n",
" }\n",
")\n",
"display(view_df)"
]
},
Expand Down Expand Up @@ -360,14 +364,14 @@
"source": [
"# obtain first 3 eigenvectors\n",
"cis_eigs = cooltools.eigs_cis(\n",
" clr,\n",
" gc_cov,\n",
" view_df=view_df,\n",
" n_eigs=3,\n",
" )\n",
" clr,\n",
" gc_cov,\n",
" view_df=view_df,\n",
" n_eigs=3,\n",
")\n",
"# cis_eigs[0] returns eigenvalues, here we focus on eigenvectors\n",
"display(cis_eigs[0])\n",
"eigenvector_track = cis_eigs[1][['chrom','start','end','E1']]"
"eigenvector_track = cis_eigs[1][[\"chrom\", \"start\", \"end\", \"E1\"]]"
]
},
{
Expand All @@ -376,7 +380,7 @@
"metadata": {},
"outputs": [],
"source": [
"eigenvector_track.to_csv('eigenvector_track.bdg', sep=\"\\t\", index=False, header=False)"
"eigenvector_track.to_csv(\"eigenvector_track.bdg\", sep=\"\\t\", index=False, header=False)"
]
},
{
Expand Down Expand Up @@ -432,34 +436,26 @@
"ten.add(pos=\"bottom\", height=0.4, hspace=0.09)\n",
"\n",
"\n",
"tc.pl.mapC(\n",
" ax=ten.axs(0),\n",
" mat=HFF,\n",
" label=\"HFF\",\n",
" map_type=\"tri\",\n",
" ax_on=False\n",
")\n",
"tc.pl.mapC(ax=ten.axs(0), mat=HFF, label=\"HFF\", map_type=\"tri\", ax_on=False)\n",
"\n",
"tc.pl.bed_track(\n",
" ax=ten.axs(1),\n",
" bed=eigenvector_track,\n",
" regions=regions,\n",
" style=\"bar\",\n",
" label=\"Eign1\"\n",
" ax=ten.axs(1), bed=eigenvector_track, regions=regions, style=\"bar\", label=\"Eign1\"\n",
")\n",
"\n",
"\n",
"tc.pl.bed_track(\n",
" ax=ten.axs(2),\n",
" bed=gc_cov,\n",
" regions=regions,\n",
" style=\"rec\",\n",
" label=\"GC\",\n",
" cmap='Blues'\n",
" ax=ten.axs(2), bed=gc_cov, regions=regions, style=\"rec\", label=\"GC\", cmap=\"Blues\"\n",
")\n",
"\n",
"\n",
"tc.pl.scale_track(ax=ten.axs(2), region=regions, scale_adjust=\"Mb\", tick_pos=\"bottom\", ratio2ax=2, space=0)\n"
"tc.pl.scale_track(\n",
" ax=ten.axs(2),\n",
" region=regions,\n",
" scale_adjust=\"Mb\",\n",
" tick_pos=\"bottom\",\n",
" ratio2ax=2,\n",
" space=0,\n",
")"
]
}
],
Expand Down
14 changes: 8 additions & 6 deletions docs/cli/cli-4C.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@
"outputs": [],
"source": [
"import pandas as pd\n",
"import trackc as tc\n",
"import pyBigWig"
"import pyBigWig\n",
"\n",
"import trackc as tc"
]
},
{
Expand All @@ -109,7 +110,9 @@
"regions = [\"chr8:127000000-129200000\", \"chr14:96500000-99300000\"]\n",
"MYC_TSS = \"chr8:127735434-127735435\"\n",
"\n",
"AML_1360_H3K27ac = pyBigWig.open(\"../../../trackc_data/tutorials/4C/GSM4604189_H3K27ac.bw\")"
"AML_1360_H3K27ac = pyBigWig.open(\n",
" \"../../../trackc_data/tutorials/4C/GSM4604189_H3K27ac.bw\"\n",
")"
]
},
{
Expand Down Expand Up @@ -210,8 +213,7 @@
],
"source": [
"gene_bed12 = pd.read_table(\n",
" \"../../../trackc_data/tutorials/4C/Homo_sapiens.GRCh38.105.chr.bed13\", \n",
" header=None\n",
" \"../../../trackc_data/tutorials/4C/Homo_sapiens.GRCh38.105.chr.bed13\", header=None\n",
")\n",
"gene_bed12 = gene_bed12[gene_bed12[12] == \"protein_coding\"]\n",
"gene_bed12[0] = \"chr\" + gene_bed12[0]\n",
Expand Down Expand Up @@ -258,7 +260,7 @@
"fruitpunch3 = LinearSegmentedColormap.from_list(\n",
" \"fruitpunch3\", [(0, \"white\"), (0.02, \"w\"), (0.25, \"r\"), (1, \"#0E3858\")], N=100\n",
")\n",
"#CF3F35\n",
"# CF3F35\n",
"\n",
"aml = tc.tl.extractContactRegions(clr=AML_1360, row_regions=regions)\n",
"tc.pl.mapC(\n",
Expand Down
10 changes: 6 additions & 4 deletions docs/cli/heatmap-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
"outputs": [],
"source": [
"import cooler\n",
"import trackc as tc\n",
"\n",
"from matplotlib.colors import LinearSegmentedColormap, ListedColormap\n",
"\n",
"import trackc as tc\n",
"\n",
"fruitpunch3 = LinearSegmentedColormap.from_list(\n",
" \"fruitpunch3\", [(0, \"white\"), (0.2, \"r\"), (1, \"#0E3858\")], N=100\n",
")"
Expand Down Expand Up @@ -102,7 +102,9 @@
}
],
"source": [
"clr = cooler.Cooler(\"/Users/yuanzan/Documents/RD/GSM4417639_SK-N-DZ_C6BC81F2_b38d5.mcool::/resolutions/5120000\")\n",
"clr = cooler.Cooler(\n",
" \"/Users/yuanzan/Documents/RD/GSM4417639_SK-N-DZ_C6BC81F2_b38d5.mcool::/resolutions/5120000\"\n",
")\n",
"clr.chromsizes"
]
},
Expand Down Expand Up @@ -153,7 +155,7 @@
" tick_fontsize=10,\n",
")\n",
"\n",
"#tc.savefig('inter-chrom.pdf')"
"# tc.savefig('inter-chrom.pdf')"
]
}
],
Expand Down
26 changes: 12 additions & 14 deletions docs/cli/heatmap-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
],
"source": [
"import cooler\n",
"\n",
"import trackc as tc\n",
"\n",
"ten = tc.tenon(figsize=(4, 1))\n",
Expand All @@ -87,21 +88,18 @@
"\n",
"clr = \"./GSM4417639_SK-N-DZ_C6BC81F2_b38d5.mcool::/resolutions/5120000\"\n",
"\n",
"mat = tc.tl.extractContactRegions(\n",
" clr=clr,\n",
" row_regions=['chr6'],\n",
" col_regions=['chr8']\n",
")\n",
"mat = tc.tl.extractContactRegions(clr=clr, row_regions=[\"chr6\"], col_regions=[\"chr8\"])\n",
"\n",
"tc.pl.mapC(ax=ten.axs(0), \n",
" mat=mat.cmat, \n",
" map_type=\"squ\", \n",
" cmap='Blues', \n",
" symmetric=True,\n",
" maxrange= 1000,\n",
" aspect=1,\n",
" )\n",
"#tc.savefig('chr6_chr8_trans.pdf')"
"tc.pl.mapC(\n",
" ax=ten.axs(0),\n",
" mat=mat.cmat,\n",
" map_type=\"squ\",\n",
" cmap=\"Blues\",\n",
" symmetric=True,\n",
" maxrange=1000,\n",
" aspect=1,\n",
")\n",
"# tc.savefig('chr6_chr8_trans.pdf')"
]
}
],
Expand Down
33 changes: 13 additions & 20 deletions docs/cli/heatmap-3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,23 @@
"ten.add(pos=\"bottom\", height=2)\n",
"ten.add(pos=\"bottom\", height=0.6)\n",
"\n",
"regions = ['chr6:0-25600000', 'chr8:122880000-143360000']\n",
"clr = '/Users/yuanzan/Documents/RD/GSM4417639_SK-N-DZ_C6BC81F2_b38d5.mcool::/resolutions/5120000'\n",
"regions = [\"chr6:0-25600000\", \"chr8:122880000-143360000\"]\n",
"clr = \"/Users/yuanzan/Documents/RD/GSM4417639_SK-N-DZ_C6BC81F2_b38d5.mcool::/resolutions/5120000\"\n",
"\n",
"mat = tc.tl.extractContactRegions(\n",
" clr=clr,\n",
" row_regions=regions\n",
")\n",
"\n",
"tc.pl.mapC(ax=ten.axs(0), \n",
" mat=mat.cmat,\n",
" map_type=\"tri\",\n",
" ax_on=False,\n",
" cmap='PuBu',\n",
" maxrange=10000,\n",
" )\n",
"mat = tc.tl.extractContactRegions(clr=clr, row_regions=regions)\n",
"\n",
"tc.pl.multi_scale_track(\n",
" ax=ten.axs(1),\n",
" regions=regions,\n",
" scale_adjust= 'Mb',\n",
" intervals=2\n",
"tc.pl.mapC(\n",
" ax=ten.axs(0),\n",
" mat=mat.cmat,\n",
" map_type=\"tri\",\n",
" ax_on=False,\n",
" cmap=\"PuBu\",\n",
" maxrange=10000,\n",
")\n",
"\n",
"#tc.savefig('trans_interactions.pdf')"
"tc.pl.multi_scale_track(ax=ten.axs(1), regions=regions, scale_adjust=\"Mb\", intervals=2)\n",
"\n",
"# tc.savefig('trans_interactions.pdf')"
]
}
],
Expand Down
Loading

0 comments on commit 5c5d23d

Please sign in to comment.