Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lastplot/data_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def replace_zero_values(row, data):
& (data["Regions"] == row["Regions"])
& (data["Genotype"] == row["Genotype"])
& (data["Values"] != 0)
]
]
if not group_df.empty:
min_value = group_df["Values"].min()
if min_value != 0:
Expand All @@ -119,9 +119,9 @@ def replace_zero_values(row, data):
os.makedirs(output_path + "/output")

try:
with pd.ExcelWriter(
output_path + "/output/Output file.xlsx", engine="openpyxl", mode="a"
) as writer:
with pd.ExcelWriter(output_path + "/output/Output file.xlsx") as writer:
df_eliminated.to_excel(writer, sheet_name="Eliminated Lipids")
print("Saving data to new Excel file")
except PermissionError:
print("Close the Excel file and try again.")

Expand Down
7 changes: 4 additions & 3 deletions lastplot/graph_constructor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy as np
from matplotlib.axes import Axes

MIN_BAR_GAP = 0.005


def mpl_calc_series(
n_groups, n_bars, group_width, bar_width, bar_gap, min_bar_gap=0.01
n_groups, n_bars, group_width, bar_width, bar_gap, min_bar_gap=MIN_BAR_GAP
):
# IMPORTANT: This algorithm only produces correct bar widths when the
# figure's width is determined exclusively by the n_groups given.
Expand Down Expand Up @@ -42,7 +44,7 @@ def mpl_calc_bar_width(n_bars, group_width, gap):


def mpl_debug_series(
n_groups, n_bars, group_width, bar_width, bar_gap, ax: Axes, min_bar_gap=0.03
n_groups, n_bars, group_width, bar_width, bar_gap, ax: Axes, min_bar_gap=MIN_BAR_GAP
):
debug = f"Input: w{bar_width:.2f}, g{bar_gap:.2f};"
bar_gap *= n_groups
Expand All @@ -62,7 +64,6 @@ def mpl_debug_series(
else:
algorithm = "gapped"
debug += f" Calc: w{bar_width:.2f}, g{bar_gap:.2f}, {algorithm};"
mpl_calc_series(n_groups, n_bars, group_width, bar_width, bar_gap)
ax.axhline(0, linestyle="--", color="k")
for x in range(n_groups):
ax.axvline(x, color="gray", linewidth=0.5)
Expand Down
64 changes: 32 additions & 32 deletions lastplot/log10_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

# Graphs by log10 values
def log_values_graph_lipid(
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
):
"""
The `log_values_graph_lipid` function generates boxplots and statistical annotations to visualize the distribution of log 10 transformed values of single lipids across regions. It performs the following tasks:
Expand Down Expand Up @@ -198,16 +198,16 @@ def log_values_graph_lipid(


def log_values_graph_lipid_class(
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
):
"""
The `log_values_graph_lipid_class` function generates boxplots to visualize the distribution of log 10 transformed values across different lipid classes within each region. It performs the following tasks:
Expand Down Expand Up @@ -277,12 +277,12 @@ def log_values_graph_lipid_class(
for g, genotype in enumerate(genotype_labels):
values = data[
(data["Lipids"] == lipid) & (data["Genotype"] == genotype)
]["Log10 Values"]
]["Log10 Values"]

bp = ax.boxplot(
values,
positions=[positions[j][g]],
widths=bar_width,
widths=width,
patch_artist=True,
boxprops=dict(facecolor=palette[g], color="k"),
medianprops=dict(color="k"),
Expand Down Expand Up @@ -334,16 +334,16 @@ def log_values_graph_lipid_class(


def log_values_graph_class_average(
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
):
"""
The `log_values_graph_class_average average` function generates boxplots and statistical annotations for visualizing average log 10 values of lipids classes
Expand Down
64 changes: 32 additions & 32 deletions lastplot/zscores_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

# Graphs by Z scores
def zscore_graph_lipid(
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
):
"""
The `zscore_graph_lipid` function generates boxplots and statistical annotations for visualizing Z scores of lipids
Expand Down Expand Up @@ -200,16 +200,16 @@ def zscore_graph_lipid(


def zscore_graph_lipid_class(
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
):
"""
The `zscore_graph_lipid_class` function generates boxplots to visualize the distribution of Z scores across different lipid classes within each region. It performs the following tasks:
Expand Down Expand Up @@ -278,12 +278,12 @@ def zscore_graph_lipid_class(
for g, genotype in enumerate(genotype_data):
experimental_values = data[
(data["Lipids"] == lipid) & (data["Genotype"] == genotype)
]["Z Scores"]
]["Z Scores"]

bp = ax.boxplot(
experimental_values,
positions=[positions[j][g]],
widths=bar_width,
widths=width,
patch_artist=True,
boxprops=dict(facecolor=palette[g], color="k"),
medianprops=dict(color="k"),
Expand Down Expand Up @@ -333,16 +333,16 @@ def zscore_graph_lipid_class(


def zscore_graph_class_average(
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
df_final,
control_name,
experimental_name,
output_path,
palette,
xlabel=None,
ylabel=None,
title=None,
show=True,
debug=False,
):
"""
The `zscore_graph_class average` function generates boxplots and statistical annotations for visualizing average Z scores of lipids classes
Expand Down