Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bigWig_visu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LBMC
ReGArDS
Projects_Analyzes
bigWig_visu
Commits
c296fc19
"git@gitbio.ens-lyon.fr:xgrand/ChIPster.git" did not exist on "893fbb6ebb0f5282217266042937dee62579d379"
Commit
c296fc19
authored
3 years ago
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/bed_handler/select_regulated_near_ctcf_exons.py: add filter_expressed function
parent
b2bc05e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bed_handler/select_regulated_near_ctcf_exons.py
+14
-0
14 additions, 0 deletions
src/bed_handler/select_regulated_near_ctcf_exons.py
with
14 additions
and
0 deletions
src/bed_handler/select_regulated_near_ctcf_exons.py
+
14
−
0
View file @
c296fc19
...
@@ -15,6 +15,7 @@ import warnings
...
@@ -15,6 +15,7 @@ import warnings
from
.get_other_exon_in_same_gene
import
create_gene_bed4norm
from
.get_other_exon_in_same_gene
import
create_gene_bed4norm
from
pathlib
import
Path
from
pathlib
import
Path
import
lazyparser
as
lp
import
lazyparser
as
lp
from
typing
import
List
def
filter_ctcf_distance_table
(
df
:
pd
.
DataFrame
,
reg
:
str
,
threshold
:
int
,
def
filter_ctcf_distance_table
(
df
:
pd
.
DataFrame
,
reg
:
str
,
threshold
:
int
,
...
@@ -126,6 +127,17 @@ def filter_ctcf_distance_table(df: pd.DataFrame, reg: str, threshold: int,
...
@@ -126,6 +127,17 @@ def filter_ctcf_distance_table(df: pd.DataFrame, reg: str, threshold: int,
return
df
return
df
def
filter_expressed
(
exon_list
:
List
[
str
])
->
List
[
str
]:
"""
Filter only expressed exons.
:param exon_list: A list of exons
:return: The list of expressed exons
"""
egenes
=
BedConfig
.
expressed_genes
.
open
(
'
r
'
).
read
().
splitlines
()
return
[
exon
for
exon
in
exon_list
if
exon
.
split
(
"
_
"
)[
0
]
in
egenes
]
def
create_bed_ctcf_exon
(
reg
:
str
,
threshold
:
int
,
def
create_bed_ctcf_exon
(
reg
:
str
,
threshold
:
int
,
location
:
str
,
include0
:
bool
=
False
,
location
:
str
,
include0
:
bool
=
False
,
near_ctcf
:
bool
=
True
)
->
None
:
near_ctcf
:
bool
=
True
)
->
None
:
...
@@ -169,6 +181,7 @@ def create_bed_ctcf_exon(reg: str, threshold: int,
...
@@ -169,6 +181,7 @@ def create_bed_ctcf_exon(reg: str, threshold: int,
bad_id
=
df
[
'
id
'
].
to_list
()
if
include0
\
bad_id
=
df
[
'
id
'
].
to_list
()
if
include0
\
else
df
[
'
id
'
].
to_list
()
+
df
.
loc
[
df
[
'
dist
'
]
==
0
,
'
id
'
].
to_list
()
else
df
[
'
id
'
].
to_list
()
+
df
.
loc
[
df
[
'
dist
'
]
==
0
,
'
id
'
].
to_list
()
list_exons
=
[
e
for
e
in
tmp_exons
if
e
not
in
bad_id
]
list_exons
=
[
e
for
e
in
tmp_exons
if
e
not
in
bad_id
]
list_exons
=
filter_expressed
(
list_exons
)
list_genes
=
[
int
(
exon
.
split
(
'
_
'
)[
0
])
for
exon
in
list_exons
]
list_genes
=
[
int
(
exon
.
split
(
'
_
'
)[
0
])
for
exon
in
list_exons
]
df_exon
=
filter_bed
(
BedConfig
.
exon_bed
,
list_exons
)
df_exon
=
filter_bed
(
BedConfig
.
exon_bed
,
list_exons
)
df_gene
=
filter_bed
(
BedConfig
.
gene_bed
,
list_genes
)
df_gene
=
filter_bed
(
BedConfig
.
gene_bed
,
list_genes
)
...
@@ -239,6 +252,7 @@ def get_bed_ctcf_exon(exon_bed: str, threshold: int,
...
@@ -239,6 +252,7 @@ def get_bed_ctcf_exon(exon_bed: str, threshold: int,
bad_id
=
df
[
'
id
'
].
to_list
()
if
include0
\
bad_id
=
df
[
'
id
'
].
to_list
()
if
include0
\
else
df
[
'
id
'
].
to_list
()
+
df
.
loc
[
df
[
'
dist
'
]
==
0
,
'
id
'
].
to_list
()
else
df
[
'
id
'
].
to_list
()
+
df
.
loc
[
df
[
'
dist
'
]
==
0
,
'
id
'
].
to_list
()
list_exons
=
[
e
for
e
in
tmp_exons
if
e
not
in
bad_id
]
list_exons
=
[
e
for
e
in
tmp_exons
if
e
not
in
bad_id
]
list_exons
=
filter_expressed
(
list_exons
)
list_genes
=
[
int
(
exon
.
split
(
'
_
'
)[
0
])
for
exon
in
list_exons
]
list_genes
=
[
int
(
exon
.
split
(
'
_
'
)[
0
])
for
exon
in
list_exons
]
df_exon
=
filter_bed
(
BedConfig
.
exon_bed
,
list_exons
)
df_exon
=
filter_bed
(
BedConfig
.
exon_bed
,
list_exons
)
df_gene
=
filter_bed
(
BedConfig
.
gene_bed
,
list_genes
)
df_gene
=
filter_bed
(
BedConfig
.
gene_bed
,
list_genes
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment