Skip to content

Commit b11b5d3

Browse files
authored
Marker gene validation (#81)
* check genes lost from mapping * marker genes id like check * Update extraction.py * bracket * Update validation.py * Update extraction.py
1 parent 7dbb3c5 commit b11b5d3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

cytetype/preprocessing/extraction.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,26 @@ def extract_marker_genes(
7878
gene_ids_to_name[gene] for gene in top_genes if gene in gene_ids_to_name
7979
]
8080

81+
lost_genes = len(top_genes) - len(markers[cluster_id])
82+
if lost_genes > 0:
83+
logger.warning(
84+
f"Number of lost genes ({lost_genes}) for group '{group_name}' (cluster '{cluster_id}'). \n"
85+
f"This could indicate inconsistencies with the marker genes and the genes in adata.var."
86+
)
87+
8188
if not any_genes_found:
8289
raise ValueError(
8390
"No marker genes found for any group. This could indicate issues with the "
8491
"rank_genes_groups analysis or that all groups have insufficient marker genes."
8592
)
8693

94+
if not any(markers.values()):
95+
raise ValueError(
96+
"All marker gene lists are empty. Gene names in rank_genes_groups "
97+
"could not be matched to adata.var_names. This typically happens "
98+
"when var_names were changed after rank_genes_groups was run."
99+
)
100+
87101
return markers
88102

89103

0 commit comments

Comments
 (0)