Skip to content

Commit

Permalink
add scRNA data (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarmey authored Jun 20, 2024
2 parents 3be767a + 753edba commit 4dcee75
Show file tree
Hide file tree
Showing 17 changed files with 96,941 additions and 413 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Code Quality

on: [push]

jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: poetry install --no-interaction
- name: Run ruff check
run: poetry run ruff check .
- name: Run ruff format check
run: poetry run ruff format --check .
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: poetry install --no-root
run: poetry install --no-interaction
- name: Test with pytest
run: make coverage.xml
- name: Upload coverage to Codecov
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ dmypy.json
.idea/

.DS_Store

.ruff_cache

poetry.lock
360 changes: 0 additions & 360 deletions poetry.lock

This file was deleted.

32 changes: 26 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,35 @@ authors = ["Cyrillus Tan <cyztan@gmail.com>"]
license = "MIT"

[tool.poetry.dependencies]
python = ">=3.11,<3.13"
numpy = "^1.23"
pandas = "^1.5.0"
xarray = "^2022.3.0"
python = "^3.12"
pandas = "^2.0.0"
xarray = "^2024.6.0"
anndata = "^0.10.7"
numpy = "^1.26"

[tool.poetry.dev-dependencies]
pytest = "^6.2"
pytest-cov = "^3.0.0"
pytest = "^8.2"
pytest-cov = "^5.0.0"
ruff = "^0.4.9"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
# Unused arguments
"ARG",
]
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

setup(name='tensordata',
version='0.0.7',
description='A common repository for tensor structured datasets.',
url='https://github.com/meyer-lab/tensordata',
license='MIT',
packages=find_packages(exclude=['doc']),
install_requires=['numpy', 'tensorly'])
setup(
name="tensordata",
version="0.0.7",
description="A common repository for tensor structured datasets.",
url="https://github.com/meyer-lab/tensordata",
license="MIT",
packages=find_packages(exclude=["doc"]),
install_requires=["numpy", "tensorly"],
)
20 changes: 11 additions & 9 deletions tensordata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__version__ = '0.0.7'
__version__ = "0.0.7"


class Bunch(dict):
""" A Bunch, exposing dict keys as a keys() method.
Definition from scikit-learn. """
"""A Bunch, exposing dict keys as a keys() method.
Definition from scikit-learn."""

def __init__(self, **kwargs):
super().__init__(kwargs)
Expand All @@ -16,18 +17,19 @@ def __dir__(self):
def __getattr__(self, key):
try:
return self[key]
except KeyError:
raise AttributeError(key)
except KeyError as e:
raise AttributeError(key) from e

def __setstate__(self, state):
pass


def xr_to_bunch(data):
import xarray as xr

assert isinstance(data, xr.DataArray)
return Bunch(
tensor = data.to_numpy(),
mode = list(data.coords.dims),
axes = [data.coords[dim].values for dim in data.coords.dims],
)
tensor=data.to_numpy(),
mode=list(data.coords.dims),
axes=[data.coords[dim].values for dim in data.coords.dims],
)
11 changes: 5 additions & 6 deletions tensordata/jones.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@


def process_RA_Tensor():
"""Structures all Rheumatoid Arthritis Synovial Fibroblast data into a usable tensor"""
"""Structures all Rheumatoid Arthritis Synovial Fibroblast data into a
usable tensor"""
RA_df = pd.DataFrame()
donor_list = ["1869", "1931", "2159", "2586", "2645", "2708", "2759"]
rep_list = [1, 2]
Expand Down Expand Up @@ -59,9 +60,9 @@ def process_RA_Tensor():
# Background (Spike and Otherwise) Subtraction
for stimulant in stimulants:
if stimulant in avg_data.columns:
avg_data.loc[(avg_data["Stimulant"] == stimulant)][
avg_data.loc[(avg_data["Stimulant"] == stimulant), stimulant][
stimulant
] == np.nan
] = np.nan
spike_row = (
avg_data.loc[
(avg_data["Stimulant"] == stimulant)
Expand Down Expand Up @@ -94,9 +95,7 @@ def process_RA_Tensor():
(avg_data["Stimulant"] == stimulant)
& (avg_data["Inhibitor"] == inh),
cytokines,
] = (
basal_spike_df.max().to_frame().transpose().values
)
] = basal_spike_df.max().to_frame().transpose().values
avg_data[cytokines] = np.log(avg_data[cytokines].values)
avg_data[cytokines] -= avg_data.loc[
avg_data.Stimulant == "Buffer", cytokines
Expand Down
2 changes: 1 addition & 1 deletion tensordata/kaplonekVaccineSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def data():
antigens = list(dict.fromkeys(antigens))

luminex_da = xr.DataArray(
np.full((len(df), len(antigens), len(detections)), np.NaN),
np.full((len(df), len(antigens), len(detections)), np.nan),
coords={
"Subject": df.index,
"Antigen": antigens,
Expand Down
1 change: 1 addition & 0 deletions tensordata/scRNA/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from tensordata.scRNA.main import * # noqa
Loading

0 comments on commit 4dcee75

Please sign in to comment.