Skip to content

Commit

Permalink
resolving merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
caterer-z-t committed Oct 11, 2024
2 parents 7f47875 + 1af68c5 commit 3be6e6d
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ env.yaml
requirements.txt
dist/
*.DS_Store
myvenv/
myvenv/
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@

<img height="200" align="right" src="https://github.com/fanzhanglab/pyCellPhenoX/blob/163014ba1b31243a1aac4c27e0611a34c1495efe/logo/https://github.com/fanzhanglab/pyCellPhenoX/blob/main-clone/logo/cellphenoX_logo_banner.png>
<p>
<img height="270" align="centre" src="https://github.com/fanzhanglab/pyCellPhenoX/blob/main/logo/cellphenoX_logo_banner.png">
</p>

![PyPI](https://img.shields.io/pypi/v/pyCellPhenoX.svg)
![Python Version](https://img.shields.io/pypi/pyversions/pyCellPhenoX)
[![License](https://img.shields.io/pypi/l/pyCellPhenoX)][license]
![Read the documentation at https://pyXcell.readthedocs.io/](https://img.shields.io/readthedocs/pyXcell/latest.svg?label=Read%20the%20Docs)
![Codecov](https://codecov.io/gh/fanzhanglab/pyCellPhenoX/branch/main/graph/badge.svg)

![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)
![Black](https://img.shields.io/badge/code%20style-black-000000.svg)

[![PyPI](https://img.shields.io/pypi/v/pyXcell.svg)][pypi]
[![Status](https://img.shields.io/pypi/status/pyXcell.svg)][status]
[![Python Version](https://img.shields.io/pypi/pyversions/pyXcell)][python version]
[![License](https://img.shields.io/pypi/l/pyXcell)][license]

We introduce pyCellPhenoX.

Expand Down Expand Up @@ -34,7 +41,7 @@ git clone [email protected]:fanzhanglab/pyCellPhenoX.git
### Dependencies/ Requirements
When using pyCellPhenoX please ensure you are using the following dependency versions or requirements
``` python
python = "^3.12"
python = "^3.9"
pandas = "^2.2.3"
numpy = "^2.1.1"
xgboost = "^2.0"
Expand Down Expand Up @@ -97,21 +104,7 @@ To create a virtual environment using **PIP** follow these steps:
```bash
pip install -r requirements.txt
```
#### Poetry

1. **Create a new project:**
``` bash
poetry new {my_project_name}
cd {my_project_name}
```
2. **Install dependencies:**
``` bash
poertry install
```
3. **Activate the environment:**
``` bash
poetry shell
```

## Tutorials
Please see the [Command-line Reference] for details. Additonally, please see [Walkthroughs] on the documentation page.
Expand Down
408 changes: 244 additions & 164 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions pyCellPhenoX/CellPhenoX.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,18 @@ def model_training_shap_val(self, outpath):
# TODO: could probably save the explainer for this modeltrain object
# Use SHAP to explain predictions using best estimator
# sv_start = time.time()

explainer = shap.TreeExplainer(result.best_estimator_)
shap_values = explainer.shap_values(X_test_outer)

# Extract SHAP information per fold per sample
print(shap_values.shape)
for k, test_index in enumerate(test_outer_ix):
test_index = self.X.index[test_index]
# TODO: here, I am selecting the second (1) shap array for a binary classification problem.
# TODO: we need a way to generalize this so that we select the array that corresponds to the
# TODO: positive class (disease).
self.shap_values_per_cv[test_index][CV_repeat] = shap_values[1][k]
self.shap_values_per_cv[test_index][CV_repeat] = shap_values[k]
sv_end = time.time()
# sv.append(sv_end - sv_start)
# self.CV_repeat_cumulative_times[4] += (sv_end - sv_start)
Expand Down Expand Up @@ -382,9 +384,10 @@ def get_shap_values(self, outpath):
average_shap_values = []
for i in range(0, len(self.X)): # len(NAM)
id = self.X.index[i] # NAM.index[i]
# print(id)
#print(id)
#print(self.shap_values_per_cv)
df_per_obs = pd.DataFrame.from_dict(
self.shap_values_per_cv[id]
self.shap_values_per_cv[id][0]
) # Get all SHAP values for sample number i
# Get relevant statistics for every sample
average_shap_values.append(df_per_obs.mean(axis=1).values)
Expand Down
4 changes: 2 additions & 2 deletions pyCellPhenoX/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__project__ = "pyCellPhenoX"
# These version placeholders are updated during build by poetry-dynamic-versioning
__version__ = "0.2.0"
__version_tuple__ = (0, 2, 0)
__version__ = "0.3.0"
__version_tuple__ = (0, 3, 0)
__license__ = "MIT License"
__author__ = "pyCellPhenoX Contributors"

Expand Down
4 changes: 2 additions & 2 deletions pyCellPhenoX/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__project__ = "pyCellPhenoX"
# These version placeholders are updated during build by poetry-dynamic-versioning
__version__ = "0.2.0"
__version_tuple__ = (0, 2, 0)
__version__ = "0.3.0"
__version_tuple__ = (0, 3, 0)
__license__ = "MIT License"
__author__ = "pyCellPhenoX Contributors"
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyCellPhenoX"
version = "0.2.0"
version = "0.3.0"
description = "An eXplainable Cell-specific machine learning method to predict clinical Phenotypes using single-cell multi-omics"
authors = [
"Fan Zhang",
Expand All @@ -20,7 +20,7 @@ packages = [
]

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.9"
pandas = "^2.2.3"
numpy = "^2.0"
xgboost = "^2.1.1"
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ cycler==0.12.1
dunamai==1.22.0
fonttools==4.54.1
iniconfig==2.0.0
isort==5.13.2
jedi==0.19.1
Jinja2==3.1.4
joblib==1.4.2
kiwisolver==1.4.7
llvmlite==0.43.0
Expand Down
4 changes: 2 additions & 2 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__project__ = "pyCellPhenoX"
# These version placeholders are updated during build by poetry-dynamic-versioning
__version__ = "0.2.0"
__version_tuple__ = (0, 2, 0)
__version__ = "0.3.0"
__version_tuple__ = (0, 3, 0)
__license__ = "MIT License"
__author__ = "pyCellPhenoX Contributors"

0 comments on commit 3be6e6d

Please sign in to comment.