Skip to content

Commit 64ac759

Browse files
authored
BUG: make tsv 7 number summary tabluate base positions starting from 1 (#167)
Previously the graph started counting sequence positions at 1 while the tsv started counting the same positions at 0. Fixes #110.
1 parent 0162ce9 commit 64ac759

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

q2_demux/_summarize/_visualizer.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ def _subsample(fastq_map):
6363
def _compute_stats_of_df(df):
6464
df_stats = df.describe(
6565
percentiles=[0.02, 0.09, 0.25, 0.5, 0.75, 0.91, 0.98])
66-
drop_cols = df_stats.index.isin(['std', 'mean', 'min', 'max'])
67-
df_stats = df_stats[~drop_cols]
66+
drop_rows = df_stats.index.isin(['std', 'mean', 'min', 'max'])
67+
df_stats = df_stats[~drop_rows]
68+
6869
return df_stats
6970

7071

@@ -189,10 +190,16 @@ def summarize(output_dir: str, data: _PlotQualView, n: int = 10000) -> None:
189190
scores = pd.DataFrame(quality_scores)
190191
if not scores.empty:
191192
stats = _compute_stats_of_df(scores)
192-
stats.to_csv(
193+
194+
# ensure base positions begin from 1
195+
stats_output = stats.copy()
196+
stats_output.columns = range(1, len(stats_output.columns) + 1)
197+
198+
stats_output.to_csv(
193199
os.path.join(output_dir,
194200
'%s-seven-number-summaries.tsv' % (direction,)),
195201
header=True, index=True, sep='\t')
202+
196203
length_table = _build_seq_len_table(scores)
197204
qual_stats[direction] = stats
198205

0 commit comments

Comments
 (0)