Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #68 from schillerlab/feature/pseudobulk
Browse files Browse the repository at this point in the history
Add calc pseudobulk
  • Loading branch information
Zethson authored Jun 8, 2021
2 parents 6e8b54e + 0cd35ff commit dccba1c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .cookietemple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ email: [email protected]
project_name: sc-toolbox
project_short_description: A collection of project templates and useful code snippets
for single-cell data analysis with Scanpy.
version: 0.8.0
version: 0.9.0
license: MIT
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: "0.8.0 🌈" # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.8.0 # <<COOKIETEMPLE_FORCE_BUMP>>
name-template: "0.9.0 🌈" # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.9.0 # <<COOKIETEMPLE_FORCE_BUMP>>
categories:
- title: "🚀 Features"
labels:
Expand Down
2 changes: 1 addition & 1 deletion cookietemple.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.0
current_version = 0.9.0

[bumpversion_files_whitelisted]
init_file = sc_toolbox/__init__.py
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
# the built documents.
#
# The short X.Y version.
version = "0.8.0"
version = "0.9.0"
# The full version, including alpha/beta/rc tags.
release = "0.8.0"
release = "0.9.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sc-toolbox"
version = "0.8.0" # <<COOKIETEMPLE_FORCE_BUMP>>
version = "0.9.0" # <<COOKIETEMPLE_FORCE_BUMP>>
description = "A collection of project templates and useful code snippets for single-cell data analysis with Scanpy."
authors = ["Lukas Heumos <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion sc_toolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = "Lukas Heumos"
__email__ = "[email protected]"
__version__ = "0.8.0"
__version__ = "0.9.0"

from sc_toolbox.api import calc, plot, util
29 changes: 29 additions & 0 deletions sc_toolbox/api/calc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,35 @@ def extended_marker_table(
return all_markers_df


def generate_pseudobulk(adata: AnnData, group_key: str = "identifier", sep="\t", save: str = None) -> pd.DataFrame:
"""
Generates a pseudobulk for a given key of groups in the AnnData object.
Looks like:
Genes group_member_1 group_member_2
1 gene_1 value_1 value_2
2 gene_2 value_3 value_4
Args:
adata: AnnData object
group_key: The key to group by. E.g. by mice, by condition, ... (default: 'identifier')
sep: Separator to use when saving the pseudobulk table (default: '\t')
save: Path to save the pseudobulk table to (default: None)
Returns:
A Pandas DataFrame containing the pseudobulk table
"""
pseudobulk = pd.DataFrame(data=adata.var_names.values, columns=["Genes"])

for i in adata.obs.loc[:, group_key].cat.categories:
temp = adata.obs.loc[:, group_key] == i
pseudobulk[i] = adata[temp].X.sum(0, dtype=int) # column sums (genes)

if save:
pseudobulk.to_csv(save, sep=sep, index=False)

return pseudobulk


def automated_marker_annotation(
adata: AnnData,
organism: str,
Expand Down

0 comments on commit dccba1c

Please sign in to comment.