Skip to content

Commit 0283d28

Browse files
committed
better selection of relevant enhancers
1 parent a97ab31 commit 0283d28

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

scepia/sc.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,22 @@ def infer_motifs(
468468
enhancer_df = enhancer_df.loc[var_enhancers, adata.uns["scepia"]["cell_types"]]
469469
enhancer_df = enhancer_df.groupby(enhancer_df.columns, axis=1).mean()
470470
enhancer_df.loc[:, :] = scale(enhancer_df)
471-
# Select top most variable enhancers
471+
472+
main_cell_types = pd.concat(
473+
(
474+
adata.obs["cluster_annotation"].astype(str),
475+
adata.obs["cell_annotation"].astype(str),
476+
)
477+
)
478+
main_cell_types = [x for x in main_cell_types.unique() if x != "other"]
479+
480+
# Select top most variable enhancers of the most important annotated cell types
472481
enhancer_df = enhancer_df.loc[
473-
enhancer_df.var(1).sort_values().tail(num_enhancers).index
482+
enhancer_df[main_cell_types].var(1).sort_values().tail(num_enhancers).index
474483
]
475484
# Center by mean of the most import cell types
476485
# Here we chose the majority cell type per cluster
477-
cluster_cell_types = adata.obs["cluster_annotation"].unique()
478-
mean_value = enhancer_df[cluster_cell_types].mean(1)
486+
mean_value = enhancer_df[main_cell_types].mean(1)
479487
enhancer_df = enhancer_df.sub(mean_value, axis=0)
480488
fname = NamedTemporaryFile(delete=False).name
481489
enhancer_df.to_csv(fname, sep="\t")

0 commit comments

Comments
 (0)