Skip to content

Commit 901ba1c

Browse files
authored
Merge pull request #2 from mmolari/feat/improve-clips
Feat/improve clips
2 parents 178ad7c + 12ad531 commit 901ba1c

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

nextflow.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ profiles {
4343
withLabel: 'q6h_1core' {
4444
time = '06:00:00'
4545
cpus = 1
46-
memory = '16G'
46+
memory = '32G'
4747
clusterOptions = '--qos=6hours'
4848
}
4949

scripts/plot_clips.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ def plot_joint_distr(df):
128128
bins = np.arange(max([f.max(), r.max()]) + 2) - 0.5
129129
norm = mpl.colors.LogNorm()
130130
m = ax.hist2d(f, r, bins=bins, norm=norm)
131-
ax.set_xlabel("n. insertions forward")
132-
ax.set_ylabel("n. insertions reverse")
131+
ax.set_xlabel("n. clips forward")
132+
ax.set_ylabel("n. clips reverse")
133133
plt.colorbar(m[3], ax=ax, label="n. sites")
134134

135135
ax = axs[1]
136136
f, r = df["Ff"], df["Fr"]
137137
bins = np.linspace(0, 1, 25)
138138
norm = mpl.colors.LogNorm()
139139
m = ax.hist2d(f, r, bins=bins, norm=norm)
140-
ax.set_xlabel("freq insertions forward")
141-
ax.set_ylabel("freq insertions reverse")
140+
ax.set_xlabel("freq clips forward")
141+
ax.set_ylabel("freq clips reverse")
142142
plt.colorbar(m[3], ax=ax, label="n. sites")
143143

144144
ax = axs[2]
@@ -148,8 +148,8 @@ def plot_joint_distr(df):
148148
bins = np.logspace(np.log10(m) - 0.1, np.log10(M) + 0.1, 25)
149149
norm = mpl.colors.LogNorm()
150150
m = ax.hist2d(f, r, bins=bins, norm=norm)
151-
ax.set_xlabel("avg. insertion length forward")
152-
ax.set_ylabel("avg. insertion length reverse")
151+
ax.set_xlabel("avg. clip length forward")
152+
ax.set_ylabel("avg. clip length reverse")
153153
ax.set_xscale("log")
154154
ax.set_yscale("log")
155155
plt.colorbar(m[3], ax=ax, label="n. sites")
@@ -179,7 +179,7 @@ def plot_n_clips_genome(dfs, step=5000):
179179
ax.legend()
180180
ax.set_xlim(bins[0] - step * 5, bins[-1] + step * 5)
181181
ax.set_xlabel("genome position (bp)")
182-
ax.set_ylabel(f"n. insertions per {step//1000} kbp")
182+
ax.set_ylabel(f"n. clips per {step//1000} kbp")
183183
ax.grid(alpha=0.3)
184184
ax.set_title(f"t = {t}")
185185
ytl = [int(y) for y in ax.get_yticks()]
@@ -260,7 +260,7 @@ def plot_trajectories(sel_df, Ts, threshold=5, Nx=3):
260260

261261
# get vial number
262262
vial = re.search("vial_(\d+)/?$", str(data_path)).groups()[0]
263-
print(f"preparing insertion plots for vial {vial}")
263+
print(f"preparing clip plots for vial {vial}")
264264

265265
# load clips and consensus frequency
266266
clips, clip_seqs = load_clips(data_path)

scripts/plot_insertions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def L_tot(x):
3939
dfs = {}
4040
for t in Ts:
4141

42-
ins = insertions[str(t)]
42+
ins = insertions[t]
4343
pos = np.array(sorted(ins.keys()))
4444
df = {}
4545

scripts/plot_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def load_time_dict(data_path, filename):
4949
dicts = {}
5050
for tpf in timepoint_fld:
5151
time_id = m.search(str(tpf)).groups()[0]
52+
time_id = int(time_id)
5253
tp_file = tpf / "pileup" / filename
5354
with gzip.open(tp_file, "r") as f:
5455
dicts[time_id] = pkl.load(f)
@@ -138,7 +139,9 @@ def color_dict(timepoints):
138139
def dict_histograms(items_dict, ax, colors, plotmeans=False, **kwargs):
139140
"""plot the histogram of a dictionary of items"""
140141
means = {tp: arr.mean() for tp, arr in items_dict.items()}
141-
for tp, arr in items_dict.items():
142+
ordered_Ts = sorted(items_dict.keys())
143+
for tp in ordered_Ts:
144+
arr = items_dict[tp]
142145
ax.hist(arr, label=tp, histtype="step", color=colors[tp], **kwargs)
143146
if plotmeans:
144147
ax.axvline(means[tp], ls=":", color=colors[tp])

0 commit comments

Comments
 (0)