Skip to content

Commit

Permalink
Fix up indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
sminot committed Feb 6, 2024
1 parent 98ff79c commit 51955a6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bin/bin_metagenomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def from_read_alignments(
self.calc_bin_silhouette_score()
self.est_genome_abund()
self.calc_rel_abund()
del self.data.uns["filtered_out"]

return self

Expand Down Expand Up @@ -464,7 +465,7 @@ def est_genome_abund(self):
genome_abund
.T
.reindex(
index=self.data.obs_names,
index=self.filtered_samples,
columns=group_profile.columns.values
)
),
Expand All @@ -475,7 +476,7 @@ def est_genome_abund(self):
)
)
.reindex(
index=self.data.obs_names
index=self.filtered_samples
)
),
var=(
Expand Down Expand Up @@ -527,7 +528,12 @@ def calc_rel_abund(self, mods=None, prefix="Relative to "):
assert kw in self.data.mod["genes"].obs
new_kw = f"{prefix}{label}"
logger.info(f"Computing {mod} {new_kw}")
rel_abund = (abund.T / self.data.mod["genes"].obs[kw]).T
rel_abund = (
abund.T /
self.data.mod["genes"].obs[kw].reindex(
index=abund.index.values
)
).T
self.data.mod[mod].layers[new_kw] = rel_abund

def compare_groups(self, category, mods=None):
Expand Down Expand Up @@ -1138,7 +1144,11 @@ def box(
hue_df
.reset_index()
.melt(
id_vars=[hue_df.index.name],
id_vars=[(
"index"
if hue_df.index.name is None
else hue_df.index.name
)],
var_name="variable"
)
)
Expand Down

0 comments on commit 51955a6

Please sign in to comment.