Skip to content

Commit

Permalink
Merge pull request #23 from heringerp/ordered_labels
Browse files Browse the repository at this point in the history
Add fix to display sample names in case of ordered-histgrowth
  • Loading branch information
danydoerr committed Jun 6, 2024
2 parents 848653f + 968ad3e commit edf7ad9
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,35 @@ pub fn write_table<W: Write>(
Ok(())
}

pub fn write_ordered_table<W: Write>(
headers: &Vec<Vec<String>>,
columns: &Vec<Vec<f64>>,
index: &Vec<String>,
out: &mut BufWriter<W>,
) -> Result<(), std::io::Error> {
let n = headers.first().unwrap_or(&Vec::new()).len();

for i in 0..n {
for j in 0..headers.len() {
if j > 0 {
write!(out, "\t")?;
}
write!(out, "{:0}", headers[j][i])?;
}
writeln!(out, "")?;
}
let n = columns.first().unwrap_or(&Vec::new()).len();
for i in 1..n {
write!(out, "{}", index[i - 1])?;
for j in 0..columns.len() {
write!(out, "\t{:0}", columns[j][i].floor())?;
}
writeln!(out, "")?;
}

Ok(())
}

pub fn write_hist_table<W: Write>(
hists: &Vec<Hist>,
out: &mut BufWriter<W>,
Expand Down Expand Up @@ -1220,5 +1249,5 @@ pub fn write_ordered_histgrowth_table<W: Write>(
})
.collect::<Vec<Vec<String>>>(),
);
write_table(&header_cols, &output_columns, out)
write_ordered_table(&header_cols, &output_columns, &abacus_group.groups, out)
}

0 comments on commit edf7ad9

Please sign in to comment.