Skip to content

Commit

Permalink
Renamed x_label and y_label to xlabel and ylabel
Browse files Browse the repository at this point in the history
  • Loading branch information
earmingol committed Oct 7, 2024
1 parent 62b047c commit b5e8399
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions sccellfie/plotting/differential_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_volcano_plot(de_results, effect_threshold=0.75, padj_threshold=0.05,


def create_comparative_violin(adata, significant_features, group1, group2, condition_key,
celltype, cell_type_key, x_label='Feature', y_label='Metabolic Activity',
celltype, cell_type_key, xlabel='Feature', ylabel='Metabolic Activity',
title=None, figsize=(16, 7), fontsize=10,
palette=['coral', 'lightsteelblue'], filename=None, dpi=300):
"""
Expand Down Expand Up @@ -134,10 +134,10 @@ def create_comparative_violin(adata, significant_features, group1, group2, condi
cell_type_key : str
The column name in adata.obs containing the cell type information.
x_label : str, optional (default: 'Feature')
xlabel : str, optional (default: 'Feature')
The label for the x-axis.
y_label : str, optional (default: 'Metabolic Activity')
ylabel : str, optional (default: 'Metabolic Activity')
The label for the y-axis.
title : str, optional (default: None)
Expand Down Expand Up @@ -180,7 +180,7 @@ def create_comparative_violin(adata, significant_features, group1, group2, condi
series2 = adata[cells_group2].to_df()[feature]
df = pd.concat([series1, series2], axis=0)
df = df.reset_index(level=0)
df = df.rename(columns={feature: y_label})
df = df.rename(columns={feature: ylabel})
df['Feature'] = feature
df['Group'] = pd.Series([group1] * len(series1) + [group2] * len(series2))
feature_dfs.append(df)
Expand All @@ -189,12 +189,12 @@ def create_comparative_violin(adata, significant_features, group1, group2, condi

# Create the violin plot
fig, ax = plt.subplots(figsize=figsize)
sns.violinplot(data=feature_df, x='Feature', y=y_label, hue='Group',
sns.violinplot(data=feature_df, x='Feature', y=ylabel, hue='Group',
split=True, inner="quart", linewidth=0.5, density_norm="width",
palette=palette, order=feature_names, ax=ax)

ax.set_xlabel(x_label, fontsize=fontsize)
ax.set_ylabel(y_label, fontsize=fontsize)
ax.set_xlabel(xlabel, fontsize=fontsize)
ax.set_ylabel(ylabel, fontsize=fontsize)
ax.set_xticklabels(labels=ax.get_xticklabels(), rotation=90, rotation_mode='anchor', ha='right', va='center',
fontsize=fontsize - 4)
ax.tick_params(axis='both', which='major', labelsize=fontsize - 4)
Expand Down
6 changes: 3 additions & 3 deletions sccellfie/plotting/tests/test_differential_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def test_compare_adata_features(tmp_path):
condition_key='group',
celltype='A',
cell_type_key='cell_type', # We're using 'group' as both condition and cell type for this test
x_label='Genes',
y_label='Expression',
xlabel='Genes',
ylabel='Expression',
title='Test Plot',
figsize=(10, 5),
fontsize=8,
palette=['red', 'blue'],
filename=str(tmp_path / "test_plot.png"),
dpi=100
)
)

# Check that the function returns the expected objects
assert isinstance(fig, Figure)
Expand Down

0 comments on commit b5e8399

Please sign in to comment.