Skip to content

Commit

Permalink
Merge pull request #19 from redst4r/level_order
Browse files Browse the repository at this point in the history
Added 'level_order' for custom ordering in stacked_barplot
  • Loading branch information
Johannes Ostner authored Feb 12, 2021
2 parents cc3e688 + 1936d9c commit aff2ebc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# scCODA - Single-cell differential composition analysis
scCODA allows for identification of compositional changes in high-throughput sequencing count data, especially cell compositions from scRNA-seq.
It also provides a framework for integration of results directly from *scanpy* and other sources.
It also provides a framework for integration of results directly from [scanpy](https://scanpy.readthedocs.io/en/stable/) and other sources.

![scCODA](.github/Figures/Fig1_v10.png)

The statistical methodology and benchmarking performance are described in:

Büttner, Ostner *et al.* (2020). **scCODA: A Bayesian model for compositional single-cell data analysis**
Büttner, Ostner *et al* (2020). **scCODA: A Bayesian model for compositional single-cell data analysis**


[Link](https://www.biorxiv.org/content/10.1101/2020.12.14.422688v1) to article on *BioRxiv*.
Expand All @@ -18,9 +18,9 @@ For further information, please refer to the

## Installation

A functioning python environment (>=3.7) is necessary to run this package.
Running the package requires a working Python environment (>=3.7).

This package uses the tensorflow (==2.3.2) and tensorflow-probability (==0.11.0) packages.
This package uses the `tensorflow` (`==2.3.2`) and `tensorflow-probability` (`==0.11.0`) packages.
The GPU versions of these packages have not been tested with scCODA and are thus not recommended.

**To install scCODA via pip, call**:
Expand All @@ -42,6 +42,10 @@ The GPU versions of these packages have not been tested with scCODA and are thus

`pip install -r requirements.txt`

- Install the package:

`python setup.py install`

**Import scCODA in a Python session via**:

import sccoda
10 changes: 9 additions & 1 deletion sccoda/util/data_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def stacked_barplot(
dpi: Optional[int] = 100,
cmap: Optional[ListedColormap] = cm.tab20,
plot_legend: Optional[bool] = True,
level_order: List[str] = None
) -> plt.Subplot:

"""
Expand Down Expand Up @@ -130,6 +131,9 @@ def stacked_barplot(

# option to plot one stacked barplot per sample
if feature_name == "samples":
if level_order:
assert set(level_order) == set(data.obs.index), "level order is inconsistent with levels"
data = data[level_order]
g = stackbar(
data.X,
type_names=data.var.index,
Expand All @@ -141,7 +145,11 @@ def stacked_barplot(
plot_legend=plot_legend,
)
else:
levels = pd.unique(data.obs[feature_name])
if level_order:
assert set(level_order) == set(data.obs[feature_name]), "level order is inconsistent with levels"
levels = level_order
else:
levels = pd.unique(data.obs[feature_name])
n_levels = len(levels)
feature_totals = np.zeros([n_levels, data.X.shape[1]])

Expand Down

0 comments on commit aff2ebc

Please sign in to comment.