Skip to content

Commit f939c99

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

File tree

66 files changed

+437
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+437
-714
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## \[Unreleased\]
8+
## [Unreleased]
99

1010
## Notes
1111

1212
Format:
1313

14-
- Title: \[version\] - YYYY-MM-DD
14+
- Title: [version] - YYYY-MM-DD
1515
- Subtitle: tags (see below)
1616
- Items: Description of the change with link to issue/pr if available
1717

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

README.md

Lines changed: 44 additions & 45 deletions
Large diffs are not rendered by default.

dance/data/base.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,8 @@ def copy(self):
302302
def set_split_idx(self, split_name: str, split_idx: Sequence[int]):
303303
"""Set cell indices for a particular split.
304304
305-
Parameters
306-
----------
307-
split_name
308-
Name of the split to set.
309-
split_idx
310-
Indices to be used in this split.
305+
Parameters ---------- split_name Name of the split to set. split_idx
306+
Indices to be used in this split.
311307
312308
"""
313309
self._split_idx_dict[split_name] = split_idx
@@ -339,12 +335,8 @@ def get_split_idx(self, split_name: str, error_on_miss: bool = False):
339335
def get_split_mask(self, split_name: str, return_type: FeatType = "numpy") -> Union[np.ndarray, torch.Tensor]:
340336
"""Obtain mask representation of a particular split.
341337
342-
Parameters
343-
----------
344-
split_name
345-
Name of the split to retrieve.
346-
return_type
347-
Return numpy array if set to 'numpy', or torch Tensor if set to 'torch'.
338+
Parameters ---------- split_name Name of the split to retrieve. return_type
339+
Return numpy array if set to 'numpy', or torch Tensor if set to 'torch'.
348340
349341
"""
350342
split_idx = self.get_split_idx(split_name, error_on_miss=True)
@@ -360,10 +352,7 @@ def get_split_mask(self, split_name: str, return_type: FeatType = "numpy") -> Un
360352
def get_split_data(self, split_name: str) -> Union[anndata.AnnData, mudata.MuData]:
361353
"""Obtain the underlying data of a particular split.
362354
363-
Parameters
364-
----------
365-
split_name
366-
Name of the split to retrieve.
355+
Parameters ---------- split_name Name of the split to retrieve.
367356
368357
"""
369358
split_idx = self.get_split_idx(split_name, error_on_miss=True)
@@ -627,13 +616,10 @@ def get_data(
627616
) -> Tuple[Any, Any]:
628617
"""Retrieve cell features and labels from a particular split.
629618
630-
Parameters
631-
----------
632-
split_name
633-
Name of the split to retrieve. If not set, return all.
634-
return_type
635-
How should the features be returned. **numpy**: return as a numpy array; **torch**: return as a torch
636-
tensor; **anndata**: return as an anndata object.
619+
Parameters ---------- split_name Name of the split to retrieve. If not set,
620+
return all. return_type How should the features be returned. **numpy**:
621+
return as a numpy array; **torch**: return as a torch tensor; **anndata**:
622+
return as an anndata object.
637623
638624
"""
639625
x = self.get_x(split_name, return_type, **x_kwargs)

dance/datasets/singlemodality.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,10 @@ def _load_dfs(paths: List[str], *, index_col: Optional[int] = 0, transpose: bool
305305
def get_map_dict(map_file_path: str, tissue: str) -> Dict[str, Set[str]]:
306306
"""Load cell-type mappings.
307307
308-
Parameters
309-
----------
310-
map_file_path
311-
Path to the mapping file.
312-
tissue
313-
Tissue of interest.
308+
Parameters ---------- map_file_path Path to the mapping file. tissue
309+
Tissue of interest.
314310
315-
Notes
316-
-----
317-
Merge mapping across all test sets for the required tissue.
311+
Notes ----- Merge mapping across all test sets for the required tissue.
318312
319313
"""
320314
map_df = pd.read_excel(osp.join(map_file_path, "map.xlsx"))
@@ -329,12 +323,9 @@ def get_map_dict(map_file_path: str, tissue: str) -> Dict[str, Set[str]]:
329323
class ClusteringDataset(BaseDataset):
330324
"""Data downloading and loading for clustering.
331325
332-
Parameters
333-
----------
334-
data_dir
335-
Path to store datasets.
336-
dataset
337-
Choice of dataset. Available options are '10X_PBMC', 'mouse_bladder_cell', 'mouse_ES_cell', 'worm_neuron_cell'.
326+
Parameters ---------- data_dir Path to store datasets. dataset Choice of
327+
dataset. Available options are '10X_PBMC', 'mouse_bladder_cell', 'mouse_ES_cell',
328+
'worm_neuron_cell'.
338329
339330
"""
340331

dance/datasets/spatial.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,9 @@ def _raw_to_dance(self, raw_data):
161161
class CellTypeDeconvoDataset(BaseDataset):
162162
"""Load raw data.
163163
164-
Parameters
165-
----------
166-
subset_common_celltypes
167-
If set to True, then subset both the reference and the real data to contain only cell types that are
168-
present in both reference and real.
164+
Parameters ---------- subset_common_celltypes If set to True, then subset both
165+
the reference and the real data to contain only cell types that are present in
166+
both reference and real.
169167
170168
"""
171169

dance/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class DevError(Exception):
22
"""Raised when action needed by dev to fix unexpected behavior."""
3+

dance/models/nn/mlp.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,9 @@
1010
class VanillaMLP(nn.Module):
1111
"""Vanilla multilayer perceptron with ReLU activation.
1212
13-
Parameters
14-
----------
15-
input_dim
16-
Input feature dimension.
17-
output_dim
18-
Output dimension.
19-
hidden_dims
20-
Hidden layer dimensions.
21-
device
22-
Computation device.
23-
random_seed
24-
Random seed controlling the model weights initialization.
13+
Parameters ---------- input_dim Input feature dimension. output_dim Output
14+
dimension. hidden_dims Hidden layer dimensions. device Computation device.
15+
random_seed Random seed controlling the model weights initialization.
2516
2617
"""
2718

dance/modules/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ def fit_score(self, x, y, *, score_func: Optional[Union[str, Mapping[Any, float]
6262
return_pred: bool = False, **fit_kwargs) -> Union[float, Tuple[float, Any]]:
6363
"""Shortcut for fitting data using the input feature and return eval.
6464
65-
Note
66-
----
67-
Only work for models where the fitting does not require labeled data, i.e. unsupervised methods.
65+
Note ---- Only work for models where the fitting does not require labeled data,
66+
i.e. unsupervised methods.
6867
6968
"""
7069
self.fit(x, **fit_kwargs)

dance/modules/multi_modality/joint_embedding/dcca.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ def fit(self, train_loader, test_loader, total_loader, first="RNA"):
748748
None.
749749
750750
"""
751-
752751
used_cycle = 0
753752

754753
if self.ground_truth1 is not None:
@@ -844,7 +843,6 @@ def score(self, dataloader, metric='clustering'):
844843
Metric eval score for VAE2.
845844
846845
"""
847-
848846
if metric == 'clustering':
849847
self.model1.eval()
850848
self.model2.eval()
@@ -915,7 +913,6 @@ def _encodeBatch(self, total_loader):
915913
Reconstruction result of modality 2.
916914
917915
"""
918-
919916
# processing large-scale datasets
920917
latent_z1 = []
921918
latent_z2 = []
@@ -953,30 +950,30 @@ def _encodeBatch(self, total_loader):
953950
return latent_z1, latent_z2, norm_x1, recon_x1, norm_x2, recon_x2
954951

955952
def forward(self, total_loader):
956-
"""Forward function for torch.nn.Module. An alias of encode_Batch function.
957-
958-
Parameters
959-
----------
960-
total_loader : torch.utils.data.DataLoader
961-
Dataloader for dataset.
962-
963-
Returns
964-
-------
965-
latent_z1 : numpy.ndarray
966-
Latent representation of modality 1.
967-
latent_z2 : numpy.ndarray
968-
Latent representation of modality 2.
969-
norm_x1 : numpy.ndarray
970-
Normalized representation of modality 1.
971-
recon_x1 : numpy.ndarray
972-
Reconstruction result of modality 1.
973-
norm_x2 : numpy.ndarray
974-
Normalized representation of modality 2.
975-
recon_x2 : numpy.ndarray
976-
Reconstruction result of modality 2.
953+
"""Forward function for torch.nn.Module.
954+
955+
An alias of encode_Batch function.
956+
Parameters
957+
----------
958+
total_loader : torch.utils.data.DataLoader
959+
Dataloader for dataset.
960+
961+
Returns
962+
-------
963+
latent_z1 : numpy.ndarray
964+
Latent representation of modality 1.
965+
latent_z2 : numpy.ndarray
966+
Latent representation of modality 2.
967+
norm_x1 : numpy.ndarray
968+
Normalized representation of modality 1.
969+
recon_x1 : numpy.ndarray
970+
Reconstruction result of modality 1.
971+
norm_x2 : numpy.ndarray
972+
Normalized representation of modality 2.
973+
recon_x2 : numpy.ndarray
974+
Reconstruction result of modality 2.
977975
978976
"""
979-
980977
latent_z1, latent_z2, norm_x1, recon_x1, norm_x2, recon_x2 = self._encodeBatch(total_loader)
981978

982979
return latent_z1, latent_z2, norm_x1, recon_x1, norm_x2, recon_x2

0 commit comments

Comments
 (0)