Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Heumos <[email protected]>
  • Loading branch information
Zethson committed Feb 21, 2025
1 parent 8931d52 commit 6a1a04b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pertpy/preprocessing/_guide_rna.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class GuideAssignment:
"""Offers Simple guide assigment based on count thresholds."""
"""Assign cells to guide RNAs."""

def assign_by_threshold(
self,
Expand Down
10 changes: 5 additions & 5 deletions pertpy/tools/_dialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def _get_pseudobulks(

return pseudobulk

def _pseudobulk_feature(
self, adata: AnnData, groupby: str, n_components: int = 50, feature_key: str = "X_pca"
def _pseudobulk_feature_space(
self, adata: AnnData, groupby: str, n_components: int = 50, feature_space_key: str = "X_pca"
) -> pd.DataFrame:
"""Return Cell-averaged components from a custom feature space.
"""Return Cell-averaged components from a passed feature space.
TODO: consider merging with `get_pseudobulks`
TODO: DIALOGUE recommends running PCA on each cell type separately before running PMD - this should be implemented as an option here.
Expand All @@ -101,7 +101,7 @@ def _pseudobulk_feature(
aggr = {}
for category in adata.obs.loc[:, groupby].cat.categories:
temp = adata.obs.loc[:, groupby] == category
aggr[category] = adata[temp].obsm[feature_key][:, :n_components].mean(axis=0)
aggr[category] = adata[temp].obsm[feature_space_key][:, :n_components].mean(axis=0)
aggr = pd.DataFrame(aggr)
return aggr

Expand Down Expand Up @@ -575,7 +575,7 @@ def _load(
A celltype_label:array dictionary.
"""
ct_subs = {ct: adata[adata.obs[self.celltype_key] == ct].copy() for ct in ct_order}
fn = self._pseudobulk_feature if agg_feature else self._get_pseudobulks
fn = self._pseudobulk_feature_space if agg_feature else self._get_pseudobulks
ct_aggr = {ct: fn(ad, self.sample_id) for ct, ad in ct_subs.items()} # type: ignore

# TODO: implement check (as in https://github.com/livnatje/DIALOGUE/blob/55da9be0a9bf2fcd360d9e11f63e30d041ec4318/R/DIALOGUE.main.R#L114-L119)
Expand Down

0 comments on commit 6a1a04b

Please sign in to comment.