Something like this.
def tidy_table(
de_test,
adata,
cells,
ids: list,
qval_thresh=0.9,
group_bys: list = ["treatment"],
cols=["gene", "pval", "qval", "log2fc"],
):
res = de_test.summary().sort_values(by=["qval"], ascending=True)
res = res[res.qval < qval_thresh].loc[:, cols].copy()
for pair in list(zip(ids, group_bys)):
res = sct.calc.add_percentages(adata[cells], res, ids=pair[0], group_by=pair[1])
return res
Since we are now using lists for ids and group_bys this should be properly documented with an example call like:
res = tidy_table(
de_test,
adata,
cells=adata_raw.obs_names,
ids=[["uninfected", "infected"], ["AT2"], adata.obs.identifier.cat.categories.tolist()],
group_bys=["grouping", "cell_type", "identifier"],
qval_thresh=0.05,
)
Something like this.
Since we are now using lists for ids and group_bys this should be properly documented with an example call like:
res = tidy_table(
de_test,
adata,
cells=adata_raw.obs_names,
ids=[["uninfected", "infected"], ["AT2"], adata.obs.identifier.cat.categories.tolist()],
group_bys=["grouping", "cell_type", "identifier"],
qval_thresh=0.05,
)