Commit b8ffb7b9 authored by Blaise Li's avatar Blaise Li
Browse files

Installing ipython and numpy in the container.

numpy is to try to force numpy support in pyBedTools.
parent ce07c988
...@@ -1194,7 +1194,7 @@ rule merge_bigwig_reps: ...@@ -1194,7 +1194,7 @@ rule merge_bigwig_reps:
warn(f"The bigwig files without {chrom} will be skipped.\n") warn(f"The bigwig files without {chrom} will be skipped.\n")
to_use = [bw for bw in bws if chrom in bw.chroms()] to_use = [bw for bw in bws if chrom in bw.chroms()]
if to_use: if to_use:
means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len) for bw in to_use]), axis=0) means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len, numpy=True) for bw in to_use]), axis=0)
else: else:
means = np.zeros(chrom_len) means = np.zeros(chrom_len)
# bin size is 10 # bin size is 10
......
...@@ -1510,7 +1510,7 @@ rule merge_bigwig_reps: ...@@ -1510,7 +1510,7 @@ rule merge_bigwig_reps:
warn(f"The bigwig files without {chrom} will be skipped.\n") warn(f"The bigwig files without {chrom} will be skipped.\n")
to_use = [bw for bw in bws if chrom in bw.chroms()] to_use = [bw for bw in bws if chrom in bw.chroms()]
if to_use: if to_use:
means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len) for bw in to_use]), axis=0) means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len, numpy=True) for bw in to_use]), axis=0)
else: else:
means = np.zeros(chrom_len) means = np.zeros(chrom_len)
# bin size is 10 # bin size is 10
......
...@@ -1871,7 +1871,7 @@ rule merge_bigwig_reps: ...@@ -1871,7 +1871,7 @@ rule merge_bigwig_reps:
warn(f"The bigwig files without {chrom} will be skipped.\n") warn(f"The bigwig files without {chrom} will be skipped.\n")
to_use = [bw for bw in bws if chrom in bw.chroms()] to_use = [bw for bw in bws if chrom in bw.chroms()]
if to_use: if to_use:
means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len) for bw in to_use]), axis=0) means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len, numpy=True) for bw in to_use]), axis=0)
else: else:
means = np.zeros(chrom_len) means = np.zeros(chrom_len)
# bin size is 10 # bin size is 10
...@@ -1909,7 +1909,7 @@ rule make_bigwig_ratios: ...@@ -1909,7 +1909,7 @@ rule make_bigwig_ratios:
for (chrom, chrom_len) in bw_out.chroms().items(): for (chrom, chrom_len) in bw_out.chroms().items():
assert cond_bw.chroms()[chrom] == chrom_len assert cond_bw.chroms()[chrom] == chrom_len
#ratios = np.divide(cond_bw.values(chrom, 0, chrom_len), ref_bw.values(chrom, 0, chrom_len)) #ratios = np.divide(cond_bw.values(chrom, 0, chrom_len), ref_bw.values(chrom, 0, chrom_len))
ratios = np.log2(np.divide(cond_bw.values(chrom, 0, chrom_len), ref_bw.values(chrom, 0, chrom_len))) ratios = np.log2(np.divide(cond_bw.values(chrom, 0, chrom_len, numpy=True), ref_bw.values(chrom, 0, chrom_len, numpy=True)))
# bin size is 10 # bin size is 10
bw_out.addEntries(chrom, 0, values=np.nan_to_num(ratios[0::10]), span=10, step=10) bw_out.addEntries(chrom, 0, values=np.nan_to_num(ratios[0::10]), span=10, step=10)
bw_out.close() bw_out.close()
......
...@@ -17,6 +17,7 @@ install: run_pipeline run_pipeline.sh workflows_shell.sh ...@@ -17,6 +17,7 @@ install: run_pipeline run_pipeline.sh workflows_shell.sh
done done
ln -sfn $(PREFIX)_$(VERSION) $(PREFIX) ln -sfn $(PREFIX)_$(VERSION) $(PREFIX)
# TODO: Bind home on temporary directory at build time in order to decrease "pollution" risks?
# Should depend on the rest of the repository. # Should depend on the rest of the repository.
run_pipeline: run_pipeline.def run_pipeline: run_pipeline.def
nohup sh -c "yes | sudo singularity build run_pipeline run_pipeline.def > build.err 2>&1" & nohup sh -c "yes | sudo singularity build run_pipeline run_pipeline.def > build.err 2>&1" &
...@@ -83,6 +83,10 @@ From:python:3.7-buster ...@@ -83,6 +83,10 @@ From:python:3.7-buster
# (that will be mounted during singularity build) # (that will be mounted during singularity build)
export PYTHONNOUSERSITE=1 export PYTHONNOUSERSITE=1
python3.7 -m pip install --upgrade pip python3.7 -m pip install --upgrade pip
# Useful for experimenting in shell mode
python3.7 -m pip install ipython
# Should be installed before pyBedTools for the latter to have numpy support
python3.7 -m pip install numpy
# Needs to install before custom pybedtools # Needs to install before custom pybedtools
# python3.7 -m pip install pysam # python3.7 -m pip install pysam
# To get scipy properly built as requirement: # To get scipy properly built as requirement:
......
...@@ -2841,7 +2841,7 @@ rule merge_bigwig_reps: ...@@ -2841,7 +2841,7 @@ rule merge_bigwig_reps:
raise raise
to_use = [bw for bw in bws if chrom in bw.chroms()] to_use = [bw for bw in bws if chrom in bw.chroms()]
if to_use: if to_use:
means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len) for bw in to_use]), axis=0) means = np.nanmean(np.vstack([bw.values(chrom, 0, chrom_len, numpy=True) for bw in to_use]), axis=0)
else: else:
means = np.zeros(chrom_len) means = np.zeros(chrom_len)
# bin size is 10 # bin size is 10
...@@ -2882,7 +2882,7 @@ rule make_bigwig_ratios: ...@@ -2882,7 +2882,7 @@ rule make_bigwig_ratios:
for (chrom, chrom_len) in bw_out.chroms().items(): for (chrom, chrom_len) in bw_out.chroms().items():
assert cond_bw.chroms()[chrom] == chrom_len assert cond_bw.chroms()[chrom] == chrom_len
#ratios = np.divide(cond_bw.values(chrom, 0, chrom_len), ref_bw.values(chrom, 0, chrom_len)) #ratios = np.divide(cond_bw.values(chrom, 0, chrom_len), ref_bw.values(chrom, 0, chrom_len))
ratios = np.log2(np.divide(cond_bw.values(chrom, 0, chrom_len), ref_bw.values(chrom, 0, chrom_len))) ratios = np.log2(np.divide(cond_bw.values(chrom, 0, chrom_len, numpy=True), ref_bw.values(chrom, 0, chrom_len, numpy=True)))
# bin size is 10 # bin size is 10
bw_out.addEntries(chrom, 0, values=np.nan_to_num(ratios[0::10]), span=10, step=10) bw_out.addEntries(chrom, 0, values=np.nan_to_num(ratios[0::10]), span=10, step=10)
bw_out.close() bw_out.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment