Skip to content

Commit

Permalink
bump up to v0.1.5 (corrected)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Camillo authored and Lucas Camillo committed Feb 8, 2024
1 parent 7102709 commit a1849ce
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 8,345 deletions.
772 changes: 0 additions & 772 deletions docs/source/tutorials/tutorial_atacseq.ipynb

This file was deleted.

633 changes: 0 additions & 633 deletions docs/source/tutorials/tutorial_bloodchemistry.ipynb

This file was deleted.

1,186 changes: 0 additions & 1,186 deletions docs/source/tutorials/tutorial_dnam_illumina_human_array.ipynb

This file was deleted.

1,616 changes: 0 additions & 1,616 deletions docs/source/tutorials/tutorial_dnam_illumina_mammalian_array.ipynb

This file was deleted.

1,656 changes: 0 additions & 1,656 deletions docs/source/tutorials/tutorial_dnam_rrbs.ipynb

This file was deleted.

682 changes: 0 additions & 682 deletions docs/source/tutorials/tutorial_histonemarkchipseq.ipynb

This file was deleted.

683 changes: 0 additions & 683 deletions docs/source/tutorials/tutorial_rnaseq.ipynb

This file was deleted.

522 changes: 0 additions & 522 deletions docs/source/tutorials/tutorial_utils.ipynb

This file was deleted.

368 changes: 186 additions & 182 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions pyaging/predict/_pred_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ def check_features_in_adata(
"""

# Preallocate the data matrix
X_model = np.empty((adata.n_obs, len(model.features)), order='F')
X_model = np.empty((adata.n_obs, len(model.features)), order="F")

# Find indices of matching features in adata.var_names
feature_indices = {feature: i for i, feature in enumerate(adata.var_names)}
model_feature_indices = np.array([feature_indices.get(feature, -1) for feature in model.features])
model_feature_indices = np.array(
[feature_indices.get(feature, -1) for feature in model.features]
)

# Identify missing features
missing_features_mask = model_feature_indices == -1
Expand All @@ -167,11 +169,15 @@ def check_features_in_adata(
# Assign values for existing features
existing_features_mask = ~missing_features_mask
existing_features_indices = model_feature_indices[existing_features_mask]
X_model[:, existing_features_mask] = np.asfortranarray(adata.X)[:, existing_features_indices]
X_model[:, existing_features_mask] = np.asfortranarray(adata.X)[
:, existing_features_indices
]

# Handle missing features
if model.reference_values is not None:
X_model[:, missing_features_mask] = np.array(model.reference_values)[missing_features_mask]
X_model[:, missing_features_mask] = np.array(model.reference_values)[
missing_features_mask
]
else:
X_model[:, missing_features_mask] = 0

Expand Down
6 changes: 4 additions & 2 deletions pyaging/preprocess/_preprocess_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ def impute_missing_values(
),
"knn": KNNImputer(),
}

# Select the appropriate imputer
imputer = imputers.get(strategy)
if not imputer:
raise ValueError(f"Invalid imputer strategy: {strategy}")
logger.info(f"Imputing missing values using {strategy} strategy", indent_level=2)
logger.info(
f"Imputing missing values using {strategy} strategy", indent_level=2
)
adata.X = imputer.fit_transform(adata.X)
adata.layers["X_imputed"] = adata.X

Expand Down
Loading

0 comments on commit a1849ce

Please sign in to comment.