gene_expr_split¶
- besca.pl.gene_expr_split(adata, genes, split_variable=None, label_split_variable=None, use_raw=True, ax=None, figsize=(15, 8))[source]¶
visualize gene expression of two groups as a split violin plot
This function generates split violin plots to compare the gene expression levels of a subset of genes between two groups.
If a split_variable is provided it first subsets the provided adata object according to this variable and generates an individual plot for each of the subsets. In the default run configuration, this function generates split violin plots where the x-axis contains the genes of interest, the y-axis the expression values and the hue of the violin plot represents the two groups that are being compared. If plot_genes = True, then this function returns an individual plot for each gene. Here if a split_variable is used to subset the data the x-axis then contains all the different datasubsets.
If using this function to subset data based on the split_variable the generated figures must be written to an output directory. The same applies for generating one plot per gene.
If only looking at one data subset, the figure can also be returned as an object if outdir = None.
- Parameters:
adata (
AnnData
) – The annotated data matrix used as inputgenes (list) – List of gene ids for which the gene expression levels should be compared
split_variable (str) – string identfying the column which contains the annotation which cell belongs to which group (should only contain 2 different groups!!) If you have more than 2 groups you will need to look into other visualization techniques.
use_raw (bool (default = True)) – boolian indicator if adata.raw data should be used as input for gene expression levels
plot_genes (bool | default = False) – boolian indicator if one individual plot should be generated per gene or if all the genes should be on the same plot
outdir (str) – filepath indicating where the generated figures should be saved
figsize ((width, height) or None | default = (15,8)) – optional parameter to define the figure size of the plot that is to be generated
dpi (int) – dpi resolution of figures that are saved to file
name (str (default = ‘compare_gene_expression’)) – name of generated plots and prefix to exported files
- Returns:
writes figures to file specified in outdir.
- Return type:
None