Mercurial > repos > ebi-gxa > score_genes_aucell
comparison decoupler_pseudobulk.py @ 8:3c18dda2ea3f draft
planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/ commit f6c6b8e014c99101232dc75aa972a12fc640a4de
author | ebi-gxa |
---|---|
date | Fri, 25 Oct 2024 15:12:14 +0000 |
parents | 617e50767215 |
children | 8a9c173645d2 |
comparison
equal
deleted
inserted
replaced
7:617e50767215 | 8:3c18dda2ea3f |
---|---|
501 # of the contrast to have the genes expressed above | 501 # of the contrast to have the genes expressed above |
502 # the threshold of % of cells to be of interest. | 502 # the threshold of % of cells to be of interest. |
503 for condition in conditions: | 503 for condition in conditions: |
504 # remove any starting or trailing whitespaces from condition | 504 # remove any starting or trailing whitespaces from condition |
505 condition = condition.strip() | 505 condition = condition.strip() |
506 if condition not in adata.obs[obs_field].unique(): | |
507 raise ValueError( | |
508 f"Condition '{condition}' from contrast {contrast}" | |
509 f" is not present in the " | |
510 f"obs_field '{obs_field}' from the AnnData object." | |
511 f"Possible values are: " | |
512 f"{', '.join(adata.obs[obs_field].unique())}." | |
513 ) | |
506 # check the percentage of cells that express each gene | 514 # check the percentage of cells that express each gene |
507 # Filter the AnnData object based on the obs_field value | 515 # Filter the AnnData object based on the obs_field value |
508 adata_filtered = adata[adata.obs[obs_field] == condition] | 516 adata_filtered = adata[adata.obs[obs_field] == condition] |
509 # Calculate the percentage of cells expressing each gene | 517 # Calculate the percentage of cells expressing each gene |
510 gene_expression = (adata_filtered.X > 0).mean(axis=0) * 100 | 518 gene_expression = (adata_filtered.X > 0).mean(axis=0) * 100 |