Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize GSEA function #305

Merged
merged 7 commits into from
Jun 11, 2024
Merged
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
4 changes: 2 additions & 2 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ Differential Expression and Gene Set Enrichment Analysis
de_analysis
markers
write_results_to_excel
fgsea
write_fgsea_results_to_excel
gsea
write_gsea_results_to_excel

Annotate clusters
-------------------
Expand Down
4 changes: 2 additions & 2 deletions pegasus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
clone_subset,
pseudobulk,
deseq2,
fgsea,
write_fgsea_results_to_excel,
gsea,
write_gsea_results_to_excel,
run_scvi,
train_scarches_scanvi,
predict_scarches_scanvi,
Expand Down
12 changes: 6 additions & 6 deletions pegasus/plotting/plot_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def compo_plot(
ax.set_xlabel("Percentage")
ax.set_ylabel(groupby_label)
ax.set_yticklabels(ax.get_yticklabels(), rotation=yticklabels_rotation, ha='center')
ax.legend(loc="center left", bbox_to_anchor=(1.05, 0.5))
ax.legend(loc="center left", bbox_to_anchor=(1.05, 0.5))

return fig if return_fig else None

Expand Down Expand Up @@ -2390,7 +2390,7 @@ def _make_one_gsea_plot(df, ax, color, size=10, fontsize=5):

def plot_gsea(
data: Union[MultimodalData, UnimodalData],
gsea_keyword: Optional[str] = "fgsea_out",
gsea_keyword: Optional[str] = "gsea_out",
alpha: Optional[float] = 0.1,
top_n: Optional[int] = 20,
panel_size: Optional[Tuple[float, float]] = (6, 4),
Expand All @@ -2406,8 +2406,8 @@ def plot_gsea(

data : ``UnimodalData`` or ``MultimodalData`` object
The main data object.
gsea_keyword: ``str``, optional, default: ``"fgsea_out"``
Keyword in data.uns that stores the fGSEA results in pandas data frame.
gsea_keyword: ``str``, optional, default: ``gsea_out``
Keyword in data.uns that stores the GSEA results in pandas data frame.
alpha: ``float``, optional, default: ``0.1``
False discovery rate threshold.
top_n: ``int``, optional, default: ``20``
Expand All @@ -2430,11 +2430,11 @@ def plot_gsea(

Examples
--------
>>> fig = pg.plot_gsea(data, 'fgsea_out', dpi = 500)
>>> fig = pg.plot_gsea(data, 'gsea_out', dpi = 500)
"""
df = data.uns[gsea_keyword]
df = df[df['padj'] <= alpha].copy()
df['Log Q'] = -np.log10(df['padj'])
df['Log Q'] = -np.log10(df['padj'].apply(lambda n: 1e-45 if n == 0 else n)) # Add 1e-45 to padj=0 to avoid log issue
df['NES Abs'] = np.abs(df['NES'])
df['pathway'] = df['pathway'].map(lambda x: ' '.join(x.split('_')))

Expand Down
2 changes: 1 addition & 1 deletion pegasus/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
from .doublet_detection import infer_doublets, mark_doublets
from .nmf import nmf, integrative_nmf, find_nmf_programs
from .pseudobulk import pseudobulk, deseq2
from .fgsea import fgsea, write_fgsea_results_to_excel
from .gsea import gsea, write_gsea_results_to_excel
from .scvitools import (
run_scvi,
train_scarches_scanvi,
Expand Down
188 changes: 0 additions & 188 deletions pegasus/tools/fgsea.py

This file was deleted.

Loading
Loading