Skip to content

Commit

Permalink
Fix growth always showing hist independent of -a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Heringer committed Oct 14, 2024
1 parent 263354f commit 8c8ac83
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 123 deletions.
198 changes: 101 additions & 97 deletions etc/hook_after.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,114 +79,118 @@ for (let i=0; i < hists.length; i++) {

//console.log(groups);

for (let i=0; i < groups.length; i++) {
var g = groups[i];
var ctx = document.getElementById('chart-group-' + g.count);
var myChart;
if (g.is_hist) {
myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: g.index,
datasets: [{
label: fname,
data: g.length,
borderWidth: 1,
backgroundColor: PCOLORS[0],
borderColor: '#FFFFFF'
}]
},
options: {
scales: {
y: {
title: {
display: true,
text: '#groups',
},
beginAtZero: true,
grid: {
color: '#FFFFFF',
}
},
x: {
title: {
display: true,
text: '#' + g.count + 's',
if (typeof groups != "undefined") {
for (let i=0; i < groups.length; i++) {
var g = groups[i];
var ctx = document.getElementById('chart-group-' + g.count);
var myChart;
if (g.is_hist) {
myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: g.index,
datasets: [{
label: fname,
data: g.length,
borderWidth: 1,
backgroundColor: PCOLORS[0],
borderColor: '#FFFFFF'
}]
},
options: {
scales: {
y: {
title: {
display: true,
text: '#groups',
},
beginAtZero: true,
grid: {
color: '#FFFFFF',
}
},
grid: {
color: '#FFFFFF',
x: {
title: {
display: true,
text: '#' + g.count + 's',
},
grid: {
color: '#FFFFFF',
},
ticks: {
maxRotation: 90,
minRotation: 65
}
},
ticks: {
maxRotation: 90,
minRotation: 65
}
},
},
plugins: {
customCanvasBackgroundColor: {
color: '#E5E4EE',
}
}
},
plugins: [pluginCanvasBackgroundColor],
});
buildPlotDownload(myChart, g, fname);
} else {
myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: g.index,
datasets: [{
label: fname,
data: g.length,
borderWidth: 1,
backgroundColor: PCOLORS[0],
borderColor: '#FFFFFF'
}]
},
options: {
scales: {
y: {
title: {
display: true,
text: '#' + g.count + 's',
},
beginAtZero: true,
grid: {
color: '#FFFFFF',
plugins: {
customCanvasBackgroundColor: {
color: '#E5E4EE',
}
},
x: {
title: {
display: true,
text: 'groups',
}
},
plugins: [pluginCanvasBackgroundColor],
});
buildPlotDownload(myChart, g, fname);
} else {
myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: g.index,
datasets: [{
label: fname,
data: g.length,
borderWidth: 1,
backgroundColor: PCOLORS[0],
borderColor: '#FFFFFF'
}]
},
options: {
scales: {
y: {
title: {
display: true,
text: '#' + g.count + 's',
},
beginAtZero: true,
grid: {
color: '#FFFFFF',
}
},
grid: {
color: '#FFFFFF',
x: {
title: {
display: true,
text: 'groups',
},
grid: {
color: '#FFFFFF',
},
ticks: {
maxRotation: 90,
minRotation: 65
}
},
ticks: {
maxRotation: 90,
minRotation: 65
}
},
},
plugins: {
customCanvasBackgroundColor: {
color: '#E5E4EE',
plugins: {
customCanvasBackgroundColor: {
color: '#E5E4EE',
}
}
}
},
plugins: [pluginCanvasBackgroundColor],
});
buildPlotDownload(myChart, g, fname);
},
plugins: [pluginCanvasBackgroundColor],
});
buildPlotDownload(myChart, g, fname);
}
buildLogToggle(myChart, g);
}
buildLogToggle(myChart, g);
}

buildInfoTableDownload(info, "graph", fname);
buildInfoTableDownload(info, "node", fname);
buildInfoTableDownload(info, "path", fname);
buildInfoTableDownload(info, "group", fname);
if (typeof info != "undefined" && info != "") {
buildInfoTableDownload(info, "graph", fname);
buildInfoTableDownload(info, "node", fname);
buildInfoTableDownload(info, "path", fname);
buildInfoTableDownload(info, "group", fname);
}

for (let i=0; i < growths.length; i++) {
var g = growths[i];
Expand Down
2 changes: 1 addition & 1 deletion etc/hook_after.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions scripts/panacus-visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ def plot_growth(df, axs, loc='lower left', estimate_growth=False):
axs[1].set_xlabel('samples')
axs[1].legend(loc=loc)

def count_comments(data):
for i, line in enumerate(data):
if not line.startswith('#'):
break
return i

def get_subplot_dim(df):

growths = [x for x in df.columns.levels[0] if x.endswith('growth')]
Expand Down Expand Up @@ -217,11 +211,7 @@ def save_split_figures(ax, f, format, prefix):

args = parser.parse_args()

with open(args.stats.name) as f:
skip_n = count_comments(f)

df = clean_multicolumn_labels(pd.read_csv(args.stats, sep='\t', header=list(range(skip_n, skip_n + N_HEADERS)), index_col=[0]))
print("test", df.columns[0][0], file=stderr)
df = clean_multicolumn_labels(pd.read_csv(args.stats, sep='\t', header=list(range(N_HEADERS)), index_col=[0], comment='#'))
if df.columns[0][0] not in ['hist', 'growth', 'ordered-growth']:
print('This script cannot visualize the content of this type of table, exiting.', file=stderr)
exit(1)
Expand Down
50 changes: 36 additions & 14 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,16 +718,13 @@ pub fn run<W: Write>(params: Params, out: &mut BufWriter<W>) -> Result<(), Error
Params::Growth {
ref hist_file,
output_format,
hist,
..
} => {
let hist_aux = HistAuxilliary::from_params(&params)?;
log::info!("loading coverage histogram from {}", hist_file);
let mut data = BufReader::new(fs::File::open(hist_file)?);
let (coverages, comments) = parse_hists(&mut data)?;
for c in comments {
out.write_all(&c[..])?;
out.write_all(b"\n")?;
}
let hists: Vec<Hist> = coverages
.into_iter()
.map(|(count, coverage)| Hist { count, coverage })
Expand All @@ -740,16 +737,41 @@ pub fn run<W: Write>(params: Params, out: &mut BufWriter<W>) -> Result<(), Error
.collect();
log::info!("reporting histgrowth table");
match output_format {
OutputFormat::Table => write_histgrowth_table(&hists, &growths, &hist_aux, out)?,
OutputFormat::Html => write_histgrowth_html(
&Some(hists),
&growths,
&hist_aux,
filename,
None,
None,
out,
)?,
OutputFormat::Table => {
for c in comments {
out.write_all(&c[..])?;
out.write_all(b"\n")?;
}
if hist {
write_histgrowth_table(&hists, &growths, &hist_aux, out)?
} else {
let hists = Vec::new();
write_histgrowth_table(&hists, &growths, &hist_aux, out)?
}
},
OutputFormat::Html => {
if hist {
write_histgrowth_html(
&Some(hists),
&growths,
&hist_aux,
filename,
None,
None,
out,
)?
} else {
write_histgrowth_html(
&None,
&growths,
&hist_aux,
filename,
None,
None,
out,
)?
}
},
};
}
Params::Info {
Expand Down

0 comments on commit 8c8ac83

Please sign in to comment.