Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chipseq_analysis
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Astrocyte
Workflows
BICF
chipseq_analysis
Commits
8dac2f27
Commit
8dac2f27
authored
5 years ago
by
Jeremy Mathews
Browse files
Options
Downloads
Plain Diff
Merge branch '58-single-rep'
parents
4a7bba6b
2d5cbb2e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
workflow/scripts/pool_and_psuedoreplicate.py
+43
-42
43 additions, 42 deletions
workflow/scripts/pool_and_psuedoreplicate.py
with
43 additions
and
42 deletions
workflow/scripts/pool_and_psuedoreplicate.py
+
43
−
42
View file @
8dac2f27
...
...
@@ -301,55 +301,56 @@ def main():
# if so replace with pool_control
# unless single control was used
if
not
single_control
:
path_to_pool_control
=
cwd
+
'
/
'
+
pool_control
if
control_df
.
values
.
max
()
>
cutoff_ratio
:
logger
.
info
(
"
Number of reads in controls differ by
"
+
"
> factor of %f. Using pooled controls.
"
%
(
cutoff_ratio
))
design_new_df
[
'
control_tag_align
'
]
=
path_to_pool_control
else
:
for
index
,
row
in
design_new_df
.
iterrows
():
exp_no_reads
=
utils
.
count_lines
(
row
[
'
tag_align
'
])
con_no_reads
=
utils
.
count_lines
(
row
[
'
control_tag_align
'
])
if
con_no_reads
<
exp_no_reads
:
logger
.
info
(
"
Fewer reads in control than experiment.
"
+
"
Using pooled controls for replicate %s.
"
%
row
[
'
replicate
'
])
design_new_df
.
loc
[
index
,
'
control_tag_align
'
]
=
\
path_to_pool_control
else
:
if
paired
:
control
=
row
[
'
control_tag_align
'
]
control_basename
=
os
.
path
.
basename
(
utils
.
strip_extensions
(
control
,
STRIP_EXTENSIONS
))
control_tmp
=
bedpe_to_tagalign
(
control
,
control_basename
)
path_to_control
=
cwd
+
'
/
'
+
control_tmp
design_new_df
.
loc
[
index
,
'
control_tag_align
'
]
=
\
path_to_control
else
:
path_to_pool_control
=
cwd
+
'
/
'
+
pool_control
if
not
single_control
:
path_to_pool_control
=
cwd
+
'
/
'
+
pool_control
if
control_df
.
values
.
max
()
>
cutoff_ratio
:
logger
.
info
(
"
Number of reads in controls differ by
"
+
"
> factor of %f. Using pooled controls.
"
%
(
cutoff_ratio
))
design_new_df
[
'
control_tag_align
'
]
=
path_to_pool_control
else
:
for
index
,
row
in
design_new_df
.
iterrows
():
exp_no_reads
=
utils
.
count_lines
(
row
[
'
tag_align
'
])
con_no_reads
=
utils
.
count_lines
(
row
[
'
control_tag_align
'
])
if
con_no_reads
<
exp_no_reads
:
logger
.
info
(
"
Fewer reads in control than experiment.
"
+
"
Using pooled controls for replicate %s.
"
%
row
[
'
replicate
'
])
design_new_df
.
loc
[
index
,
'
control_tag_align
'
]
=
\
path_to_pool_control
else
:
if
paired
:
control
=
row
[
'
control_tag_align
'
]
control_basename
=
os
.
path
.
basename
(
utils
.
strip_extensions
(
control
,
STRIP_EXTENSIONS
))
control_tmp
=
bedpe_to_tagalign
(
control
,
control_basename
)
path_to_control
=
cwd
+
'
/
'
+
control_tmp
design_new_df
.
loc
[
index
,
'
control_tag_align
'
]
=
\
path_to_control
# Add in pseudo replicates
tmp_metadata
=
design_new_df
.
loc
[
0
].
copy
()
tmp_metadata
[
'
control_tag_align
'
]
=
path_to_pool_control
for
rep
,
pseudorep_file
in
pool_pseudoreplicates_dict
.
items
():
tmp_metadata
[
'
sample_id
'
]
=
experiment_id
+
'
_pr
'
+
str
(
rep
)
tmp_metadata
[
'
replicate
'
]
=
str
(
rep
)
+
'
_pr
'
tmp_metadata
[
'
xcor
'
]
=
'
Calculate
'
path_to_file
=
cwd
+
'
/
'
+
pseudorep_file
tmp_metadata
[
'
tag_align
'
]
=
path_to_file
design_new_df
=
design_new_df
.
append
(
tmp_metadata
)
# Add in pool experiment
tmp_metadata
[
'
sample_id
'
]
=
experiment_id
+
'
_pooled
'
tmp_metadata
[
'
replicate
'
]
=
'
pooled
'
else
:
path_to_pool_control
=
cwd
+
'
/
'
+
pool_control
design_new_df
[
'
control_tag_align
'
]
=
path_to_pool_control
# Add in pseudo replicates
tmp_metadata
=
design_new_df
.
loc
[
0
].
copy
()
tmp_metadata
[
'
control_tag_align
'
]
=
path_to_pool_control
for
rep
,
pseudorep_file
in
pool_pseudoreplicates_dict
.
items
():
tmp_metadata
[
'
sample_id
'
]
=
experiment_id
+
'
_pr
'
+
str
(
rep
)
tmp_metadata
[
'
replicate
'
]
=
str
(
rep
)
+
'
_pr
'
tmp_metadata
[
'
xcor
'
]
=
'
Calculate
'
path_to_file
=
cwd
+
'
/
'
+
p
ool_experiment_s
e
path_to_file
=
cwd
+
'
/
'
+
p
seudorep_fil
e
tmp_metadata
[
'
tag_align
'
]
=
path_to_file
design_new_df
=
design_new_df
.
append
(
tmp_metadata
)
# Add in pool experiment
tmp_metadata
[
'
sample_id
'
]
=
experiment_id
+
'
_pooled
'
tmp_metadata
[
'
replicate
'
]
=
'
pooled
'
tmp_metadata
[
'
xcor
'
]
=
'
Calculate
'
path_to_file
=
cwd
+
'
/
'
+
pool_experiment_se
tmp_metadata
[
'
tag_align
'
]
=
path_to_file
design_new_df
=
design_new_df
.
append
(
tmp_metadata
)
# Write out new dataframe
design_new_df
.
to_csv
(
experiment_id
+
'
_ppr.tsv
'
,
header
=
True
,
sep
=
'
\t
'
,
index
=
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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