Skip to content

Commit

Permalink
update GCoverage from BED
Browse files Browse the repository at this point in the history
  • Loading branch information
chaochungkuo committed Mar 2, 2024
1 parent cfd8751 commit 2560ac7
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 18 deletions.
2 changes: 1 addition & 1 deletion genomkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
from .variants.gvariant import GVariant
from .variants.gvariants import GVariants

__version__ = "0.2.5"
__version__ = "0.2.6"
11 changes: 7 additions & 4 deletions genomkit/coverages/gcoverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,25 @@ def calculate_coverage_GRegions(self, regions, scores,
:type regions: GRegions
:param scores: Provide the scores for calculating the coverage
:type scores: GRegions
:param strandness: Make this operation strandness specific, defaults to False
:param strandness: Make this operation strandness specific, defaults
to False
:type strandness: bool, optional
"""
from genomkit import GRegions
assert isinstance(regions, GRegions)
assert isinstance(scores, GRegions)
filtered_scores = scores.intersect(target=regions,
mode="ORIGIN")
mode="ORIGINAL")
for region in tqdm(regions, desc="Calculating coverage",
total=len(regions)):
self.coverage[region] = np.zeros(shape=len(region) //
self.bin_size)
for target in filtered_scores:
if region.overlap(target, strandness=strandness):
start_ind = (target.start - region.start) // self.bin_size
end_ind = (target.end - region.end) // self.bin_size
start_ind = (max(0, target.start - region.start))
start_ind = start_ind // self.bin_size
end_ind = (min(len(region), target.end - region.start))
end_ind = end_ind // self.bin_size
for i in range(start_ind, end_ind):
self.coverage[region][i] += target.score

Expand Down
12 changes: 9 additions & 3 deletions genomkit/regions/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# IO functions
###########################################################################
def load_BED(filename: str):
def get_score(score):
if score == ".":
score = 0
else:
score = float(score)
return score
from genomkit import GRegion, GRegions
if not os.path.exists(filename):
raise FileNotFoundError(f"The file '{filename}' does not exist.")
Expand All @@ -28,20 +34,20 @@ def load_BED(filename: str):
start=int(infos[1]),
end=int(infos[2]),
name=infos[3],
score=infos[4]))
score=get_score(infos[4])))
elif len(infos) == 6:
res.add(GRegion(sequence=infos[0],
start=int(infos[1]),
end=int(infos[2]),
name=infos[3],
score=infos[4],
score=get_score(infos[4]),
orientation=infos[5]))
elif len(infos) > 6:
res.add(GRegion(sequence=infos[0],
start=int(infos[1]),
end=int(infos[2]),
name=infos[3],
score=infos[4],
score=get_score(infos[4]),
orientation=infos[5],
data=infos[6:]))
return res
94 changes: 88 additions & 6 deletions tests/local_test/examples_bed.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,35 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating coverage: 100%|██████████| 500/500 [00:00<00:00, 250226.94it/s]\n"
"Calculating coverage: 100%|██████████| 48709/48709 [00:49<00:00, 977.10it/s] \n"
]
},
{
"data": {
"text/plain": [
"<Axes: >"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeoAAAGFCAYAAAAyz7C1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAWWElEQVR4nO3dbYxddb0v8N+eSnentN1tYVqgpUBbYyNauClYix4d4gOnOUHJOT68MEo9hCOmkqvjjc7cRAkvuNvGvtAoabgHoX0hiYoCSg5PASkxFUWkR/C2eAtiD9PnZ2jaPTCz7otzmMvuE3vatbvXn/X5JCvprNn7v9YiId/5/f7/tVYly7IsAIBC6ur0CQAAxyeoAaDABDUAFJigBoACE9QAUGCCGgAKTFADQIEJagAosHe0+sF9hwbbeR4AvI1M7Z7V9mMsuP68XMbZ+K9bchmnXVTUAFBgLVfUAFAklZKUmoIagCR1dVU6fQqnRUn+HgGANKmoAUhSpRwFtaAGIE1dJekJl+QyASB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1AAkqSwVtaAGIEnmqAGgwMpSUZujBoACU1EDkCRPJgOAAivLHLXWNwAUmIoagCSVZTGZoAYgSWUJaq1vAGijRqMRl156aVQqlVi/fv2Yvy+oAUjSSJblsrXbN77xjTjvvPNO+vuCGoAkjWQjuWzt9MADD8TDDz8cK1euPOkxzFEDUGqNRiMajUbTvmq1GtVq9ZTG3b59e1x//fVx7733xsSJE096HBU1AEkazkZy2er1etRqtaatXq+f0rllWRbLli2LG264IS677LJTGktFDUCS8mpbDwwMRF9fX9O+41XT/f39sWLFihOOt2HDhnj44YfjlVdeiYGBgVM+v0qWtTaTvu/Q4CkfDIBymNo9q+3HuKP72lzG+edDa1r+7M6dO2P37t0n/MzcuXPjM5/5TPzqV7+KSqUyun94eDjGjRsXn/vc52LNmtaPKagByN3bNahbtXnz5jhw4MDoz1u2bImrrroq7r777li8eHHMnj275bG0vgFIUpEfeDJnzpymnydNmhQREfPmzRtTSEcIagASVeSgzpOgBoA2u/DCC6PFmeajCGoAklSW11wKagCSNFyS1rcHngBAgamoAUiSxWQAUGBlmaPW+gaAAlNRA5CksrS+W36EKABw+ml9A0CBCWoAKDBBDQAFJqgBoMAENQAUmKAGgAIT1ABQYIIaAApMUANAgf0//K9pNXor/twAAAAASUVORK5CYII=",
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
Expand All @@ -149,16 +169,60 @@
"# Generate a heatmap from two BED files: one BED file is used as windows and the other used as the signal\n",
"DMLs = GRegions(name=\"DMLs\", load=\"DML.bed\")\n",
"DMLs.sort()\n",
"DMLs.extend(upstream=5, downstream=5, inplace=True)\n",
"TSSs = GRegions(name=\"genes\", load=\"/Users/ckuo/rgtdata/mm10/genes_Gencode_mm10.bed\")\n",
"TSSs.resize(extend_upstream=500, extend_downstream=500,\n",
"TSSs.resize(extend_upstream=1000, extend_downstream=1000,\n",
" center=\"5prime\", inplace=True)\n",
"TSSs.sampling(size=10000)\n",
"# TSSs.filter_by_names(names=, inplace=True)\n",
"cov = GCoverages(bin_size=1)\n",
"cov.calculate_coverage_GRegions(regions=promoters, scores=DMLs)\n",
"cov.calculate_coverage_GRegions(regions=TSSs, scores=DMLs)\n",
"cov.flip_negative_regions()\n",
"df = cov.get_dataframe()\n",
"\n",
"sns.heatmap(df, xticklabels=False, yticklabels=False, cmap=\"PiYG\")\n",
"# sns.heatmap(df, annot=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-0.661197579563083"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"DMLs.elements[1].score"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.338802420436917"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"float('-0.661197579563083') + 1"
]
},
{
"cell_type": "code",
"execution_count": 5,
Expand All @@ -185,8 +249,26 @@
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sns.heatmap(df, xticklabels=False, yticklabels=False, cmap=\"PiYG\")"
"df.sum().sum()"
]
}
],
Expand Down
8 changes: 4 additions & 4 deletions tests/test_files/bed/example2.bed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
chr1 500 1500 Feature1 0 +
chr1 3500 4500 Feature2 0 +
chr2 4500 5500 Feature3 0 +
chr2 7500 8500 Feature4 0 +
chr1 500 1500 Feature1 10 +
chr1 3500 4500 Feature2 20 +
chr2 4500 5500 Feature3 30 +
chr2 7500 8500 Feature4 40 +
12 changes: 12 additions & 0 deletions tests/test_gcoverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ def test_calculate_coverage_from_bam(self):
# ['1']
self.assertEqual(len(cov.coverage.keys()), 1)

def test_calculate_coverage_GRegions(self):
regions = GRegions(name="test",
load=os.path.join(script_path,
"test_files/bed/example2.bed"))
cov = GCoverages()
cov.calculate_coverage_GRegions(regions=regions, scores=regions)
self.assertEqual(len(cov.coverage.keys()), 4)
self.assertEqual(cov.coverage[regions[0]][0], 10)
self.assertEqual(cov.coverage[regions[1]][0], 20)
self.assertEqual(cov.coverage[regions[2]][0], 30)
self.assertEqual(cov.coverage[regions[3]][0], 40)

def test_get_coverage(self):
cov = GCoverages()
cov.load_coverage_from_bigwig(
Expand Down

0 comments on commit 2560ac7

Please sign in to comment.