Skip to content

Commit

Permalink
refactor: Get filename before contrast_df merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jvfe committed Oct 19, 2023
1 parent 80a8fdb commit 0f7ebf8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions microview/plotting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Dict, Optional

from pathlib import Path
from plotly import io
from plotly.express import bar, colors, line, scatter
from plotly.graph_objects import Figure
Expand Down Expand Up @@ -52,7 +52,6 @@ def plot_common_taxas(common_taxas_df, **kwargs):
"index": "Sample name",
"value": "% of reads",
"variable": "Taxon name",
"group": "Group",
},
template="plotly_white",
color_discrete_sequence=colors.qualitative.Alphabet,
Expand All @@ -70,7 +69,7 @@ def plot_abund_div(abund_div_df, **kwargs):
y="Shannon Diversity",
size="N Taxas",
hover_data=["index"],
labels={"group": "Group", "N Taxas": "# taxas"},
labels={"N Taxas": "# taxas"},
template="plotly_white",
color_discrete_sequence=colors.qualitative.Safe[3:],
**kwargs,
Expand All @@ -86,7 +85,7 @@ def plot_beta_pcoa(beta_pcoa, **kwargs):
x="PC1",
y="PC2",
hover_data=["sample"],
labels={"sample": "Sample name", "group": "Group"},
labels={"sample": "Sample name"},
template="plotly_white",
**kwargs,
)
Expand Down Expand Up @@ -157,6 +156,7 @@ def generate_taxo_plots(tax_data: Dict, contrast_df=None) -> Dict:

# TODO: Improve this check
if contrast_df is not None and "group" in contrast_df.columns:
contrast_df['sample'] = [str(Path(s).name) for s in contrast_df['sample'].to_list()]
merged_taxas_df = merge_with_contrasts(tax_data["common taxas"], contrast_df)

common_taxas = plot_common_taxas(merged_taxas_df, facet_col="group")
Expand Down

0 comments on commit 0f7ebf8

Please sign in to comment.