swan_vis.utils

Functions

calc_pi(adata, t_df, obs_col='dataset') : Calculate the percent isoform per gene per condition given by obs_col. Default column to use is adata.obs index column, dataset.

Parameters:
        adata (anndata AnnData): Annotated data object from the SwanGraph
        t_df (pandas DataFrame): Pandas Dataframe that has index to
                gene id mapping
        obs_col (str): Column name from adata.obs table to group on.
                Default: 'dataset'

Returns:
        df (pandas DataFrame): Pandas DataFrame where rows are the different
                conditions from `obs_col` and the columns are transcript ids in the
                SwanGraph, and values represent the percent isoform usage per gene
                per condition.
        sums (pandas DataFrame): Pandas DataFrame where rows are the different
                conditions from `obs_col` and the columns are transcript ids in the
                SwanGraph, and values represent the cumulative counts per isoform
                per condition.

calc_total_counts(adata, obs_col='dataset', layer='counts') : Calculate cumulative expression per adata entry based on condition given by obs_col. Default column to use is adata.obs index column, dataset.

calc_tpm(adata, obs_col='dataset', how='mean', recalc=False) : Calculate the TPM per condition given by obs_col. Default column to use is adata.obs index column, dataset.

make_uns_key(kind, obs_col, obs_conditions, die_kind='iso') : Make a key name to reference die, det, or deg results in the .uns part of SwanGraph.adata.

read(file) : Read a SwanGraph from a saved pickle file.

save_fig(oname) : Save the current figure as a png with a given file prefix.

validate_gtf(fname) : Validates that the input GTF is valid input to Swan.

Last updated

Was this helpful?