Skip to content

Commit

Permalink
Merge pull request #251 from paulsengroup/fix/weights
Browse files Browse the repository at this point in the history
Various improvements to balancing::Weights
  • Loading branch information
robomics committed Sep 15, 2024
2 parents f90cadb + 8bbd1ea commit 365f138
Show file tree
Hide file tree
Showing 40 changed files with 1,648 additions and 385 deletions.
2 changes: 1 addition & 1 deletion benchmark/fetch_and_sum/fetch_and_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ template <typename PixelIt>
}

void fetch_and_sum(const Config &c, cooler::File &&clr) {
auto weights = clr.normalization(c.weights);
auto weights = clr.normalization_ptr(c.weights);

std::string line;
while (std::getline(std::cin, line)) {
Expand Down
2 changes: 1 addition & 1 deletion src/hictk/balance/balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void write_weights_cooler(std::string_view uri, const BalanceConfig& c,
}

cooler::Dataset dset(cooler::RootGroup{clr.getGroup(grp)}, path, 0.0);
dset.append(weights(weights.type()));
dset.append(weights.begin(), weights.end());

dset.write_attribute("cis_only", c.mode == "cis");
dset.write_attribute("divisive_weights", weights.type() == balancing::Weights::Type::DIVISIVE);
Expand Down
2 changes: 1 addition & 1 deletion src/hictk/convert/cool_to_hic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void copy_normalization_vector(hic::internal::HiCFileWriter& w, const coo
}

try {
const auto& weights = *clr.normalization(norm);
const auto& weights = clr.normalization(norm);

const auto norm_name = norm.to_string() == "weight" ? "ICE" : norm.to_string();
SPDLOG_INFO(FMT_STRING("[{}] adding {} normalization vector"), resolution, norm_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ inline SCALE::SCALE(const File& f, Type type, const Params& params) {

template <typename PixelIt>
inline SCALE::SCALE(PixelIt first, PixelIt last, const hictk::BinTable& bins, const Params& params)
: _biases(VC{first, last, bins}.get_weights()(balancing::Weights::Type::DIVISIVE)),
: _biases(VC{first, last, bins}.get_weights().to_vector(balancing::Weights::Type::DIVISIVE)),
_convergence_stats(ConvergenceStats{false, false, 1000, 0, 10.0 * (1.0 + params.tol)}),
_tpool(params.threads > 1 ? std::make_unique<BS::thread_pool>(params.threads) : nullptr) {
if (bins.type() == BinTable::Type::variable) {
Expand Down Expand Up @@ -268,7 +268,7 @@ inline auto SCALE::compute_trans(const File& f, const Params& params) -> Result

return {{0, f.bins().size()},
scale.get_scale(),
scale.get_weights(false)(balancing::Weights::Type::DIVISIVE)};
scale.get_weights(false).to_vector(balancing::Weights::Type::DIVISIVE)};
}

template <typename File>
Expand All @@ -278,7 +278,7 @@ inline auto SCALE::compute_gw(const File& f, const Params& params) -> Result {

return {{0, f.bins().size()},
scale.get_scale(),
scale.get_weights(false)(balancing::Weights::Type::DIVISIVE)};
scale.get_weights(false).to_vector(balancing::Weights::Type::DIVISIVE)};
}

template <typename Matrix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ inline auto VC::compute_trans(const File& f) -> Result {

return {{0, f.bins().size()},
vc.get_scale(),
vc.get_weights(false)(balancing::Weights::Type::DIVISIVE)};
vc.get_weights(false).to_vector(balancing::Weights::Type::DIVISIVE)};
}

template <typename File>
Expand All @@ -167,7 +167,7 @@ inline auto VC::compute_gw(const File& f) -> Result {

return {{0, f.bins().size()},
vc.get_scale(),
vc.get_weights(false)(balancing::Weights::Type::DIVISIVE)};
vc.get_weights(false).to_vector(balancing::Weights::Type::DIVISIVE)};
}

} // namespace hictk::balancing
Loading

0 comments on commit 365f138

Please sign in to comment.