Mercurial > repos > ebi-gxa > decoupler_pseudobulk
comparison decoupler_pseudobulk.py @ 11:70a5c6f2408d 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:24 +0000 |
| parents | f6040492b499 |
| children | a559be56720c |
comparison
equal
deleted
inserted
replaced
| 10:f6040492b499 | 11:70a5c6f2408d |
|---|---|
| 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 |
