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

Fixed set_fdr for tascCODA models #411

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 1 addition & 5 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ Follow these steps to install pertpy on an Apple Silicon machine (tested on a Ma
$ pip install .
```

Now you're ready to use pertpy as usual within the environment (`import pertpy`).

```

```
Now you're ready to use pertpy as usual within the environment (`import pertpy`).

[github repo]: https://github.com/theislab/pertpy
[pip]: https://pip.pypa.io
Expand Down
10 changes: 9 additions & 1 deletion pertpy/tools/_coda/_base_coda.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,15 @@ def set_fdr(self, data: AnnData | MuData, est_fdr: float, modality_key: str = "c
if isinstance(data, AnnData):
sample_adata = data

intercept_df, effect_df = self.summary_prepare(sample_adata, est_fdr, *args, **kwargs) # type: ignore
if sample_adata.uns["scCODA_params"]["model_type"] == "classic":
intercept_df, effect_df = self.summary_prepare(sample_adata, est_fdr, *args, **kwargs) # type: ignore
elif sample_adata.uns["scCODA_params"]["model_type"] == "tree_agg":
intercept_df, effect_df, node_df = self.summary_prepare(sample_adata, est_fdr, *args, **kwargs) # type: ignore
# Save node df in `sample_adata.uns`
sample_adata.uns["scCODA_params"]["node_df"] = node_df
else:
raise ValueError("No valid model type!")

sample_adata.varm["intercept_df"] = intercept_df
for cov in effect_df.index.get_level_values("Covariate"):
sample_adata.varm[f"effect_df_{cov}"] = effect_df.loc[cov, :]
Expand Down
1 change: 0 additions & 1 deletion pertpy/tools/_coda/_tasccoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ def set_fdr(self, data: AnnData | MuData, est_fdr: float, modality_key: str = "c
>>> )
>>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
>>> tasccoda.set_fdr(mdata, est_fdr=0.4)
#TODO: Not working (throws error, because too many values to unpack -> Correct set_fdr first)
"""
return super().set_fdr(data, est_fdr, modality_key, *args, **kwargs)

Expand Down