Skip to content

Commit

Permalink
Add Cathedral plot name field
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed May 8, 2024
1 parent 50190bf commit 721104a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/genesis/population/function/fst_cathedral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ std::vector<FstCathedralPlotRecord> prepare_fst_cathedral_records_for_chromosome
record.title = "Fst (" + fst_name + ")";
if( !record.sample_name_1.empty() && !record.sample_name_2.empty() ) {
record.title += " " + record.sample_name_1 + " vs " + record.sample_name_2;
record.plot_name = record.sample_name_1 + "." + record.sample_name_2;
} else {
record.plot_name = "plot";
}
if( !record.chromosome_name.empty() ) {
record.title += ", chromosome: " + record.chromosome_name;
Expand Down
2 changes: 2 additions & 0 deletions lib/genesis/population/plotting/cathedral_plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ genesis::utils::JsonDocument cathedral_plot_record_to_json_document(
// Now fill the object with our data.
auto& obj = document.get_object();
obj["title"] = JsonDocument::string( record.title );
obj["plotName"] = JsonDocument::string( record.plot_name );
obj["chromosomeName"] = JsonDocument::string( record.chromosome_name );
obj["chromosomeLength"] = JsonDocument::number_unsigned( record.chromosome_length );
obj["windowWidths"] = JsonDocument( record.window_widths );
Expand Down Expand Up @@ -303,6 +304,7 @@ CathedralPlotRecord load_cathedral_plot_record_from_files(
// Might need amendment if we make use of other fields as well, such as the window widths vec.
CathedralPlotRecord result;
result.title = json[ "title" ].get_string();
result.plot_name = json[ "plotName" ].get_string();
result.chromosome_name = json[ "chromosomeName" ].get_string();
result.chromosome_length = json[ "chromosomeLength" ].get_number_unsigned();
result.parameters.width = json[ "width" ].get_number_unsigned();
Expand Down
1 change: 1 addition & 0 deletions lib/genesis/population/plotting/cathedral_plot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct CathedralPlotRecord

// Data-derived parameters from the initial input.
std::string title;
std::string plot_name;
std::string chromosome_name;
size_t chromosome_length = 0;

Expand Down

0 comments on commit 721104a

Please sign in to comment.