Skip to content

Commit ea776b4

Browse files
authored
Merge pull request #182 from AlexandrovLab/spa-sep25-cleanup
Merge spa-sep25-cleanup into main for v1.0.0 update
2 parents 0cc72cd + b16e586 commit ea776b4

File tree

10 files changed

+365
-375
lines changed

10 files changed

+365
-375
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
## [1.0.0] - 2025-10-07
10+
11+
### Added
12+
- Parallel execution of SPA runs for improved performance on multi-core systems.
13+
- `cpu` parameter to control the number of processor cores used during assignment. Defaults to `-1` to use all available cores.
14+
15+
### Documentation
16+
- Updated README to document the new `cpu` parameter.
17+
918
## [0.2.6] - 2025-09-17
1019

1120
### Added

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ Analyze.cosmic_fit(samples, output, input_type="matrix", context_type="96",
7474
| make_plots | Boolean | Toggle on and off for making and saving plots. The default value is True. |
7575
| sample_reconstruction_plots | String | Select the output format for sample reconstruction plots. Valid inputs are {'pdf', 'png', 'both', 'none'}. The default value is 'none'. If set to 'png' or 'both', the external binary `poppler` must be installed. Install via `conda install -c conda-forge poppler` or `brew install poppler` on macOS. |
7676
| verbose | Boolean | Prints detailed statements. The default value is False. |
77+
| cpu | Integer | Number of processor cores to use during assignment. The default value is -1, which uses all available cores. |
7778
| volume | String | Path to SigProfilerAssignment volumes. Used for Docker/Singularity. Environmental variable "SIGPROFILERASSIGNMENT_VOLUME" takes precedence. Default value is None. |
7879

7980

8081

82+
8183
### <a name="subgroups"></a> Signature Subgroups
8284

8385
When using COSMIC reference signatures, some subgroups of signatures can be removed to improve the refitting analysis. To use this feature, the `exclude_signature_subgroups` parameter should be added, following the sintax below:

SigProfilerAssignment/Analyzer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def decompose_fit(
2424
export_probabilities=True,
2525
export_probabilities_per_mutation=False,
2626
volume=None,
27+
cpu=-1,
2728
):
2829
decomp.spa_analyze(
2930
samples=samples,
@@ -51,6 +52,7 @@ def decompose_fit(
5152
export_probabilities=export_probabilities,
5253
export_probabilities_per_mutation=export_probabilities_per_mutation,
5354
volume=volume,
55+
cpu=cpu,
5456
)
5557

5658

@@ -76,6 +78,7 @@ def denovo_fit(
7678
export_probabilities=True,
7779
export_probabilities_per_mutation=False,
7880
volume=None,
81+
cpu=-1,
7982
):
8083
decomp.spa_analyze(
8184
samples=samples,
@@ -102,6 +105,7 @@ def denovo_fit(
102105
export_probabilities=export_probabilities,
103106
export_probabilities_per_mutation=export_probabilities_per_mutation,
104107
volume=volume,
108+
cpu=cpu,
105109
)
106110

107111

@@ -128,6 +132,7 @@ def cosmic_fit(
128132
export_probabilities_per_mutation=False,
129133
sample_reconstruction_plots=False,
130134
volume=None,
135+
cpu=-1,
131136
):
132137
decomp.spa_analyze(
133138
samples=samples,
@@ -155,4 +160,5 @@ def cosmic_fit(
155160
export_probabilities_per_mutation=export_probabilities_per_mutation,
156161
sample_reconstruction_plots=sample_reconstruction_plots,
157162
volume=volume,
163+
cpu=cpu,
158164
)

SigProfilerAssignment/DecompositionPlots/PlotDecomposition.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,22 @@ def calculate_similarities(denovo, denovo_name, est_denovo):
281281
if denovo.shape[0] == 1536:
282282
denovo["IndexKey"] = denovo.iloc[:, 0].astype(str)
283283
denovo["GroupKey"] = denovo["IndexKey"].str[1:8]
284-
denovo_grouped = denovo.groupby("GroupKey", as_index=False).sum(numeric_only=True)
284+
denovo_grouped = denovo.groupby("GroupKey", as_index=False).sum(
285+
numeric_only=True
286+
)
285287
denovo_grouped.rename(columns={"GroupKey": "MutationType"}, inplace=True)
286288
denovo = denovo_grouped.reset_index(drop=True)
287289

288290
elif denovo.shape[0] == 288:
289291
denovo["MutationType"] = denovo["MutationType"].astype(str) # Ensure strings
290-
denovo["GroupKey"] = denovo["MutationType"].str[2:9] # Extract substring for grouping
291-
denovo_grouped = denovo.groupby("GroupKey", as_index=False).sum(numeric_only=True)
292+
denovo["GroupKey"] = denovo["MutationType"].str[
293+
2:9
294+
] # Extract substring for grouping
295+
denovo_grouped = denovo.groupby("GroupKey", as_index=False).sum(
296+
numeric_only=True
297+
)
292298
denovo_grouped.rename(columns={"GroupKey": "MutationType"}, inplace=True)
293-
denovo = denovo_grouped.reset_index(drop=True) # updated pandas 2.0.0
299+
denovo = denovo_grouped.reset_index(drop=True) # updated pandas 2.0.0
294300
sample_names = [denovo_name]
295301

296302
if sample_names is False:

SigProfilerAssignment/DecompositionPlots/PlotDecomposition_SV32.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
PLOT_NAME = 0
129129
CONTRIBUTION = 1
130130

131+
131132
# Helper functions for plotting the layout of a graph with 1-5 basis signatures
132133
# Parameters:
133134
# bases - (List of Strings) The list of basis names

SigProfilerAssignment/controllers/cli_controller.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def parse_arguments_common(args: List[str], description: str) -> argparse.Namesp
8585
default=False,
8686
help="Verbose output (default: False).",
8787
)
88+
parser.add_argument(
89+
"--cpu",
90+
type=int,
91+
default=-1,
92+
help="Number of processor cores to use during assignment (default: -1 = all cores).",
93+
)
8894
parser.add_argument(
8995
"--new_signature_thresh_hold",
9096
type=float,
@@ -146,8 +152,9 @@ def parse_arguments_common(args: List[str], description: str) -> argparse.Namesp
146152
"'pdf' (generate only PDF), "
147153
"'both' (PDF + PNG), or "
148154
"'png' (PNG only, PDF removed)."
149-
)
155+
),
150156
)
157+
151158

152159
return parser.parse_args(args)
153160

@@ -170,6 +177,7 @@ def dispatch_decompose_fit(self, user_args: List[str]) -> None:
170177
make_plots=parsed_args.make_plots,
171178
collapse_to_SBS96=parsed_args.collapse_to_SBS96,
172179
connected_sigs=parsed_args.connected_sigs,
180+
cpu=parsed_args.cpu,
173181
verbose=parsed_args.verbose,
174182
decompose_fit_option=True,
175183
denovo_refit_option=False,
@@ -202,6 +210,7 @@ def dispatch_denovo_fit(self, user_args: List[str]) -> None:
202210
collapse_to_SBS96=parsed_args.collapse_to_SBS96,
203211
connected_sigs=parsed_args.connected_sigs,
204212
verbose=parsed_args.verbose,
213+
cpu=parsed_args.cpu,
205214
decompose_fit_option=False,
206215
denovo_refit_option=True,
207216
cosmic_fit_option=False,
@@ -230,6 +239,7 @@ def dispatch_cosmic_fit(self, user_args: List[str]) -> None:
230239
collapse_to_SBS96=parsed_args.collapse_to_SBS96,
231240
connected_sigs=parsed_args.connected_sigs,
232241
verbose=parsed_args.verbose,
242+
cpu=parsed_args.cpu,
233243
decompose_fit_option=False,
234244
denovo_refit_option=False,
235245
cosmic_fit_option=True,

0 commit comments

Comments
 (0)