Skip to content

Commit

Permalink
Merge pull request #210 from AlexandrovLab/pandas2-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbarnesUCSD authored Feb 12, 2025
2 parents a284f1f + 3d177fb commit 1064fd1
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# Hidden files and directories
*.DS_Store
.vscode/

# pypi build folder
/build/
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dist: xenial
dist: focal
language: python

python:
- '3.8'
- '3.9'
- '3.12'

before_install:
- pip install --upgrade pip setuptools packaging
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [1.3.0] - 2025-02-11

### Changed
- Updated dependencies: Now requires **Pandas >= 2.0.0**, **NumPy >= 2.0.0**, and **Python >= 3.9**.
- Dropped support for **Python 3.8**

## [1.2.31] - 2024-11-6

### Fixed
Expand Down
8 changes: 6 additions & 2 deletions SigProfilerMatrixGenerator/controllers/cli_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ def dispatch_install(self, user_args: List[str]) -> None:

def dispatch_test(self, user_args: List[str]) -> None:
parsed_args = parse_arguments_test(user_args)
test_helpers.install_genomes(parsed_args.download_genomes)
test_helpers.test_genomes(parsed_args.test_genome, parsed_args.volume)

if parsed_args.download_genomes:
test_helpers.install_genomes(parsed_args.download_genomes)
if parsed_args.test_genome:
test_helpers.test_genomes(parsed_args.test_genome, parsed_args.volume)


def dispatch_matrix_generator(self, user_args: List[str]) -> None:
parsed_args = parse_arguments_matrix_generator(user_args)
Expand Down
30 changes: 12 additions & 18 deletions SigProfilerMatrixGenerator/scripts/MutationMatrixGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3108,11 +3108,10 @@ def matrix_generator(
nontrans = mut_count_all["6144"][mut_count_all["6144"].index.str.contains("N:")]
a = bitrans // 2
b = bitrans % 2
trans = trans.append(a)
trans = trans.append(b)
trans = pd.concat([trans, a, b])
trans = trans.groupby(trans.index.str[2:]).sum()
trans = trans.rename(index=lambda s: "T:" + s)
untrans = untrans.append(a)
untrans = pd.concat([untrans, a])
untrans = untrans.groupby(untrans.index.str[2:]).sum()
untrans = untrans.rename(index=lambda s: "U:" + s)
mut_count_all["4608"] = pd.concat([trans, untrans, nontrans])
Expand All @@ -3127,11 +3126,10 @@ def matrix_generator(
nontrans = mut_count_all["384"][mut_count_all["384"].index.str.contains("N:")]
a = bitrans // 2
b = bitrans % 2
trans = trans.append(a)
trans = trans.append(b)
trans = pd.concat([trans, a, b])
trans = trans.groupby(trans.index.str[2:]).sum()
trans = trans.rename(index=lambda s: "T:" + s)
untrans = untrans.append(a)
untrans = pd.concat([untrans, a])
untrans = untrans.groupby(untrans.index.str[2:]).sum()
untrans = untrans.rename(index=lambda s: "U:" + s)
mut_count_all["288"] = pd.concat([trans, untrans, nontrans])
Expand All @@ -3143,11 +3141,10 @@ def matrix_generator(
nontrans = mut_count_all["24"][mut_count_all["24"].index.str.contains("N:")]
a = bitrans // 2
b = bitrans % 2
trans = trans.append(a)
trans = trans.append(b)
trans = pd.concat([trans, a, b])
trans = trans.groupby(trans.index.str[2:]).sum()
trans = trans.rename(index=lambda s: "T:" + s)
untrans = untrans.append(a)
untrans = pd.concat([untrans, a])
untrans = untrans.groupby(untrans.index.str[2:]).sum()
untrans = untrans.rename(index=lambda s: "U:" + s)
mut_count_all["18"] = pd.concat([trans, untrans, nontrans])
Expand Down Expand Up @@ -3739,11 +3736,10 @@ def matrix_generator_INDEL(
questionable = indel_tsb_dict[indel_tsb_dict.index.str.contains("Q:")]
a = bitrans // 2
b = bitrans % 2
trans = trans.append(a)
trans = trans.append(b)
trans = pd.concat([trans, a, b])
trans = trans.groupby(trans.index.str[2:]).sum()
trans = trans.rename(index=lambda s: "T:" + s)
untrans = untrans.append(a)
untrans = pd.concat([untrans, a])
untrans = untrans.groupby(untrans.index.str[2:]).sum()
untrans = untrans.rename(index=lambda s: "U:" + s)
indel_tsb_dict_abbrev = pd.concat([trans, untrans, nontrans, questionable])
Expand Down Expand Up @@ -3954,11 +3950,10 @@ def matrix_generator_DINUC(
questionable = mut_count_all["186"][mut_count_all["186"].index.str.contains("Q:")]
a = bitrans // 2
b = bitrans % 2
trans = trans.append(a)
trans = trans.append(b)
trans = pd.concat([trans, a, b])
trans = trans.groupby(trans.index.str[2:]).sum()
trans = trans.rename(index=lambda s: "T:" + s)
untrans = untrans.append(a)
untrans = pd.concat([untrans, a])
untrans = untrans.groupby(untrans.index.str[2:]).sum()
untrans = untrans.rename(index=lambda s: "U:" + s)
mut_count_all["150"] = pd.concat([trans, untrans, nontrans, questionable])
Expand All @@ -3971,11 +3966,10 @@ def matrix_generator_DINUC(
questionable = mut_4992[mut_4992.index.str.contains("Q:")]
a = bitrans // 2
b = bitrans % 2
trans = trans.append(a)
trans = trans.append(b)
trans = pd.concat([trans, a, b])
trans = trans.groupby(trans.index.str[2:]).sum()
trans = trans.rename(index=lambda s: "T:" + s)
untrans = untrans.append(a)
untrans = pd.concat([untrans, a])
untrans = untrans.groupby(untrans.index.str[2:]).sum()
untrans = untrans.rename(index=lambda s: "U:" + s)
mut_count_all["2400"] = pd.concat([trans, untrans, nontrans, questionable])
Expand Down
12 changes: 1 addition & 11 deletions SigProfilerMatrixGenerator/scripts/ref_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from importlib import resources
from typing import Optional, Union

import pkg_resources

import SigProfilerMatrixGenerator


Expand Down Expand Up @@ -58,12 +56,4 @@ def get_chromosomes_dir(self) -> pathlib.Path:
return result

def _get_package_installation_folder(self):
try:
# python >= 3.9
result = resources.files(SigProfilerMatrixGenerator)
except AttributeError:
# python 3.8, deprecated
result = pathlib.Path(
pkg_resources.resource_filename(SigProfilerMatrixGenerator.__name__, "")
)
return result
return resources.files(SigProfilerMatrixGenerator)
5 changes: 0 additions & 5 deletions SigProfilerMatrixGenerator/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

def load_and_compare(matrices, solution_dir, exome=False, bed_file=True):
for key in matrices:
# Only process keys that start with "SBS"
if not key.startswith("SBS"):
continue # Skip non-SBS matrices

# Determine the solution file path based on the exome flag
if exome:
solution_file = os.path.join(
Expand Down Expand Up @@ -101,7 +97,6 @@ def test_one_genome(genome, volume, exome=False, bed_file=True):
# load the results from the solution directory and compare them to the dataframes in matrices
if exome:
solution_dir = os.path.join(TEST_INPUT_DIR, f"WES/solutions/{genome}/")
print("solution_dir", solution_dir)
elif bed_file:
solution_dir = os.path.join(TEST_INPUT_DIR, f"bed_file/solutions/{genome}/")
else:
Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import setup

VERSION = "1.2.31"
VERSION = "1.3.0"

# remove the dist folder first if exists
if os.path.exists("dist"):
Expand All @@ -23,7 +23,7 @@ def write_version_py(filename="SigProfilerMatrixGenerator/version.py"):
# THIS FILE IS GENERATED FROM SIGPROFILEMATRIXGENERATOR SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
Update = 'v1.2.31: Resolve issue of ID and DBS matrices not being returned in the output matrices when chrom_based is set to True.'
Update = 'v1.3.0: Require Pandas and Numpy >= 2.0.0 and Python >= 3.9'
"""
fh = open(filename, "w")
Expand All @@ -49,15 +49,14 @@ def write_version_py(filename="SigProfilerMatrixGenerator/version.py"):
author_email="[email protected]",
license="UCSD",
packages=["SigProfilerMatrixGenerator"],
python_requires=">=3.8",
python_requires=">=3.9",
install_requires=[
"matplotlib>=2.2.2",
"sigProfilerPlotting>=1.3.24",
"sigProfilerPlotting>=1.4.0",
"statsmodels>=0.9.0",
"numpy>=1.18.5,<2.0.0",
"pandas>=0.23.4,<2.0.0",
"scipy>=1.12.0; python_version>='3.9'",
"scipy>=1.1.0, <1.12.0; python_version=='3.8'",
"numpy>=2.0.0",
"pandas>=2.0.0",
"scipy>=1.12.0",
],
entry_points={
"console_scripts": [
Expand Down

0 comments on commit 1064fd1

Please sign in to comment.