Skip to content

Commit 1a19cfa

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent ec894ba commit 1a19cfa

File tree

12 files changed

+41
-64
lines changed

12 files changed

+41
-64
lines changed

docs/.ipynb_checkpoints/index-checkpoint.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Tools <api/tools.md>
1111
Plotting <api/plotting.md>
1212
1313
```
14+
1415
```{toctree}
1516
:maxdepth: 1
1617
:caption: Tutorials
@@ -26,4 +27,4 @@ changelog.md
2627
contributing.md
2728
references.md
2829
29-
```
30+
```

docs/api/.ipynb_checkpoints/plotting-checkpoint.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
.. autosummary::
1010
:toctree: generated/basic_plots
11-
11+
1212
crosstab
1313
histogram
1414
pie
@@ -23,7 +23,7 @@
2323
```{eval-rst}
2424
.. autosummary::
2525
:toctree: generated/quantification
26-
26+
2727
gene_metric_heatmap
2828
logfoldratio_over_noise
2929
metric_scatter
@@ -33,18 +33,15 @@
3333
moranI_histogram
3434
diffusion_results
3535
spatial_inout_expression
36-
37-
```
38-
39-
4036
37+
```
4138

4239
## Source, target and communication
4340

4441
```{eval-rst}
4542
.. autosummary::
4643
:toctree: generated/communication
47-
44+
4845
celltype_communication
4946
gene_communication
5047
global_distribution_from_source
@@ -54,25 +51,24 @@
5451
target_score_by_celltype
5552
interactions_with_arrows
5653
spatial_interactions
57-
54+
5855
```
5956

6057
## Factor analysis
6158

6259
```{eval-rst}
6360
.. autosummary::
6461
:toctree: generated/factor_analysis
65-
62+
6663
factors_in_cells
6764
rank_factor_genes_loadings
6865
rank_factor_genes_loadings_matrixplot
6966
nmf_factors_exrna_cells_W
7067
nmf_gene_contributions
7168
paired_nmf_factors
7269
apply_exrnaH_to_cellular_to_create_cellularW
73-
74-
```
7570
71+
```
7672

7773
## Colormaps & palettes
7874

@@ -83,6 +79,3 @@
8379
get_colormap
8480
get_palette
8581
```
86-
87-
88-

docs/api/.ipynb_checkpoints/preprocessing-checkpoint.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
pp.define_urna
1616
pp.filter_urna
1717
pp.format_adata
18+
```

docs/api/.ipynb_checkpoints/tools-checkpoint.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
tl.calculate_target_cells
3636
tl.compute_target_score
3737
tl.define_target_by_celltype
38-
tl.cluster_distribution_from_source
38+
tl.cluster_distribution_from_source
3939
tl.get_gene_interaction_strength
4040
tl.communication_strength
4141
tl.gene_specific_interactions
@@ -46,7 +46,7 @@
4646
```{eval-rst}
4747
.. autosummary::
4848
:toctree: generated/cell_scores
49-
49+
5050
tl.compute_contribution_score
5151
```
5252

@@ -55,7 +55,7 @@
5555
```{eval-rst}
5656
.. autosummary::
5757
:toctree: generated/factors
58-
58+
5959
tl.factors_to_cells
6060
tl.latent_factor
6161
```
@@ -68,15 +68,14 @@
6868
6969
tl.assess_diffusion
7070
tl.compute_js_divergence
71-
71+
7272
```
7373

7474
## Multimodal quantication
7575

7676
```{eval-rst}
7777
.. autosummary::
7878
:toctree: generated/multimodal
79-
79+
8080
tl.image_intensities_per_transcript
8181
```
82-

docs/api/plotting.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
.. autosummary::
1010
:toctree: generated/basic_plots
11-
11+
1212
crosstab
1313
histogram
1414
pie
@@ -23,7 +23,7 @@
2323
```{eval-rst}
2424
.. autosummary::
2525
:toctree: generated/quantification
26-
26+
2727
gene_metric_heatmap
2828
logfoldratio_over_noise
2929
metric_scatter
@@ -33,18 +33,15 @@
3333
moranI_histogram
3434
diffusion_results
3535
spatial_inout_expression
36-
37-
```
38-
39-
4036
37+
```
4138

4239
## Source, target and communication
4340

4441
```{eval-rst}
4542
.. autosummary::
4643
:toctree: generated/communication
47-
44+
4845
celltype_communication
4946
gene_communication
5047
global_distribution_from_source
@@ -54,25 +51,24 @@
5451
target_score_by_celltype
5552
interactions_with_arrows
5653
spatial_interactions
57-
54+
5855
```
5956

6057
## Factor analysis
6158

6259
```{eval-rst}
6360
.. autosummary::
6461
:toctree: generated/factor_analysis
65-
62+
6663
factors_in_cells
6764
rank_factor_genes_loadings
6865
rank_factor_genes_loadings_matrixplot
6966
nmf_factors_exrna_cells_W
7067
nmf_gene_contributions
7168
paired_nmf_factors
7269
apply_exrnaH_to_cellular_to_create_cellularW
73-
74-
```
7570
71+
```
7672

7773
## Colormaps & palettes
7874

@@ -83,6 +79,3 @@
8379
get_colormap
8480
get_palette
8581
```
86-
87-
88-

docs/api/preprocessing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
pp.define_urna
1616
pp.filter_urna
1717
pp.format_adata
18+
```

docs/api/tools.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
tl.calculate_target_cells
3636
tl.compute_target_score
3737
tl.define_target_by_celltype
38-
tl.cluster_distribution_from_source
38+
tl.cluster_distribution_from_source
3939
tl.get_gene_interaction_strength
4040
tl.communication_strength
4141
tl.gene_specific_interactions
@@ -46,7 +46,7 @@
4646
```{eval-rst}
4747
.. autosummary::
4848
:toctree: generated/cell_scores
49-
49+
5050
tl.compute_contribution_score
5151
```
5252

@@ -55,7 +55,7 @@
5555
```{eval-rst}
5656
.. autosummary::
5757
:toctree: generated/factors
58-
58+
5959
tl.factors_to_cells
6060
tl.latent_factor
6161
```
@@ -68,15 +68,14 @@
6868
6969
tl.assess_diffusion
7070
tl.compute_js_divergence
71-
71+
7272
```
7373

7474
## Multimodal quantication
7575

7676
```{eval-rst}
7777
.. autosummary::
7878
:toctree: generated/multimodal
79-
79+
8080
tl.image_intensities_per_transcript
8181
```
82-

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Tools <api/tools.md>
1111
Plotting <api/plotting.md>
1212
1313
```
14+
1415
```{toctree}
1516
:maxdepth: 1
1617
:caption: Tutorials
@@ -26,4 +27,4 @@ changelog.md
2627
contributing.md
2728
references.md
2829
29-
```
30+
```

src/troutpy/tl/.ipynb_checkpoints/quantify_urna-checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def spatial_variability(
5151
-------
5252
sdata: spatialdata.SpatialData
5353
Sdata containing Moran's I values for each gene, indexed by gene names.
54-
54+
5555
"""
5656
if coord_keys is None:
5757
coord_keys = ["x", "y"]

src/troutpy/tl/factor_analysis.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
import warnings
2+
3+
import anndata as ad
14
import numpy as np
25
import pandas as pd
36
from sklearn.decomposition import NMF, LatentDirichletAllocation
47
from spatialdata import SpatialData
58

69

7-
import numpy as np
8-
import scanpy as sc
9-
import anndata as ad
10-
from sklearn.decomposition import NMF, LatentDirichletAllocation
11-
import warnings
12-
1310
def latent_factor(
1411
sdata: SpatialData,
1512
method: str = "NMF",
@@ -55,7 +52,6 @@ def latent_factor(
5552
sdata : SpatialData or None
5653
Modified SpatialData object or None if copy=False.
5754
"""
58-
5955
adata = sdata[layer]
6056
counts = adata.X.copy()
6157

@@ -74,15 +70,12 @@ def latent_factor(
7470
try:
7571
from drvi.model import DRVI
7672
from drvi.utils.tools import (
77-
traverse_latent,
7873
calculate_differential_vars,
7974
set_latent_dimension_stats,
75+
traverse_latent,
8076
)
8177
except ImportError:
82-
raise ImportError(
83-
"The 'drvi' package is required for method='DRVI'. "
84-
"Please install it with: pip install drvi"
85-
)
78+
raise ImportError("The 'drvi' package is required for method='DRVI'. Please install it with: pip install drvi")
8679

8780
# DRVI-specific parameters
8881
encoder_dims = kwargs.pop("encoder_dims", [128, 128])
@@ -145,6 +138,7 @@ def latent_factor(
145138
sdata[layer] = adata
146139
return sdata if copy else None
147140

141+
148142
def combine_loadings_arrays(gene_loadings_pos: np.ndarray, gene_loadings_neg: np.ndarray) -> np.ndarray:
149143
if gene_loadings_pos.shape != gene_loadings_neg.shape:
150144
raise ValueError("Input arrays must have the same shape.")
@@ -157,8 +151,7 @@ def combine_loadings_arrays(gene_loadings_pos: np.ndarray, gene_loadings_neg: np
157151
# Raise warning if conflicts found
158152
if np.any(conflict_mask):
159153
conflict_indices = np.argwhere(conflict_mask)
160-
warnings.warn(f"Conflicts found at {len(conflict_indices)} locations. "
161-
f"Example: {conflict_indices[:5].tolist()}")
154+
warnings.warn(f"Conflicts found at {len(conflict_indices)} locations. Example: {conflict_indices[:5].tolist()}")
162155

163156
# Initialize combined output
164157
combined = np.zeros_like(gene_loadings_pos)
@@ -168,7 +161,6 @@ def combine_loadings_arrays(gene_loadings_pos: np.ndarray, gene_loadings_neg: np
168161
return combined
169162

170163

171-
172164
def factors_to_cells(
173165
sdata: SpatialData, extracellular_layer: str = "segmentation_free_table", cellular_layer: str = "table", copy: bool | None = None
174166
) -> SpatialData:

0 commit comments

Comments
 (0)