Skip to content

Commit

Permalink
Fix variance_explained_grouped
Browse files Browse the repository at this point in the history
  • Loading branch information
arberqoku committed Jun 6, 2024
1 parent ec67cac commit 6eb1064
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions muvi/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,13 @@ def variance_explained(
"""Heatmap of variance explained, see `muvi.tl.variance_explained`."""

model_cache = _get_model_cache(model)
r2_fac = model_cache.factor_metadata
r2_cov = model_cache.cov_metadata
r2_fac = None
if model_cache.factor_metadata is not None:
r2_fac = model_cache.factor_metadata.copy()
r2_cov = None
if model_cache.cov_metadata is not None:
r2_cov = model_cache.cov_metadata.copy()

if r2_fac is None and r2_cov is None:
raise ValueError(
"No scores found in model cache, rerun `muvi.tl.variance_explained`."
Expand Down
4 changes: 3 additions & 1 deletion muvi/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ def variance_explained_grouped(model, groupby, factor_idx: Index = "all", **kwar
model,
sample_idx=group_df.index,
factor_idx=factor_idx,
cache=False,
sort=False,
**kwargs,
)[1]
)[1].copy()
)
.reset_index()
)
Expand Down

0 comments on commit 6eb1064

Please sign in to comment.