Skip to content

Commit 32e8871

Browse files
danielsfmorriscb
authored andcommitted
add warning message if get_gene_data grabs too many genes
1 parent c9c49ef commit 32e8871

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/abc_atlas_access/abc_atlas_cache/anndata_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pandas as pd
44
import numpy as np
55
import anndata
6+
import warnings
67
from abc_atlas_access.abc_atlas_cache.abc_project_cache import AbcProjectCache
78

89

@@ -50,6 +51,14 @@ def get_gene_data(
5051
# Create a mask for the requested genes.
5152
gene_mask = np.isin(all_genes.gene_symbol, selected_genes)
5253
gene_filtered = all_genes[gene_mask]
54+
if len(gene_filtered) > len(selected_genes):
55+
msg = (
56+
f"You asked for {len(selected_genes)} genes, but "
57+
f"get_gene_data is selecting {len(gene_filtered)}; "
58+
"probably some of the gene symbols you specified are "
59+
"associated with more than one gene"
60+
)
61+
warnings.warn(msg)
5362

5463
# wait to create output dataframe until we have read in the
5564
# first chunk and know the dtype we need

0 commit comments

Comments
 (0)