Skip to content

Commit

Permalink
fixed an AnnData metadata bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Camillo authored and Lucas Camillo committed Dec 11, 2023
1 parent 1b7a2b7 commit 8c23821
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 147 deletions.
2 changes: 1 addition & 1 deletion pyaging/predict/_pred.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def predict_age(

# Add predicted ages to adata
add_pred_ages_adata(adata, predicted_ages, clock_name, logger, indent_level=2)

# Load all clocks metadata
all_clock_metadata = load_clock_metadata(dir, logger, indent_level=2)

Expand Down
5 changes: 3 additions & 2 deletions pyaging/predict/_pred_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@ def check_features_in_adata(
adata_empty = anndata.AnnData(
X=empty_data,
obs=adata.obs,
var=pd.DataFrame(index=missing_features),
uns=adata.uns,
var=pd.DataFrame(np.ones((num_missing_features, 1)), index=missing_features, columns=['percent_na']),
layers=dict(zip(adata.layers.keys(), [empty_data] * len(adata.layers)))
)

# Concatenate original adata with the empty adata
adata = anndata.concat([adata, adata_empty], axis=1, merge='same')
adata = anndata.concat([adata, adata_empty], axis=1, merge='same', uns_merge='unique')

logger.info(
f"Expanded adata with {num_missing_features} missing features.",
Expand Down
Loading

0 comments on commit 8c23821

Please sign in to comment.