swan_vis.SwanGraph()

swan.Swangraph()

SwanGraph(sc=False, edge_adata=True, end_adata=True, ic_adata=True) : A graph class to represent a transcriptome and perform plotting and analysis from it

Attributes
----------
datasets (list of str):
        Names of datasets in the Graph
gene_datasets (list of str):
        Names of datasets w/ gene expression in the Graph
annotation (bool):
        Whether an annotation transcriptome has been added.
abundance (bool):
        Whether abundance data has been added to the SwanGraph
gene_abundance (bool):
        Whether gene abundance data has been added to the SwanGraph
loc_df (pandas DataFrame):
        DataFrame of all unique observed genomic
        coordinates in the transcriptome
edge_df (pandas DataFrame):
        DataFrame of all unique observed exonic or intronic
        combinations of splice sites in the transcriptome
t_df (pandas DataFrame):
        DataFrame of all unique transcripts found
        in the transcriptome
adata (anndata AnnData):
        Annotated data object to hold transcript expression values
        and metadata
gene_adata (anndata AnnData):
        Annotated data object to hold gene expression values / metadata
ic_adata (anndata AnnData):
        Annotated data object to hold intron chain expression values / metadata
tss_adata (anndata AnnData):
        Annotated data object to hold TSS expression values and metadata
tes_adata (anndata AnnData):
        Annotated data object to hold TES expression values and metadata

Parameters:
        sc (bool): Whether this is coming from single cell data
        edge_adata (bool): Whether to create the edge_adata table
        end_adata (bool): Whether to create the tss/tes_adata tables
        ic_adata (bool): Whether to create the ic_adata table

Methods

add_abundance(self, counts_file, how='iso') : Adds abundance from a counts matrix to the SwanGraph. Transcripts in the SwanGraph but not in the counts matrix will be assigned 0 counts. Transcripts in the abundance matrix but not in the SwanGraph will not have expression added.

add_adata(self, adata_file, how='iso') : Adds abundance / metadata information from an AnnData object into the SwanGraph. Transcripts in the SwanGraph but not in the AnnData will be assigned 0 counts. Transcripts in the abundance matrix but not in the SwanGraph will not have expression added.

add_annotation(self, fname, verbose=False) : Adds an annotation from input fname to the SwanGraph.

add_metadata(self, fname, overwrite=False) : Adds metadata to the SwanGraph from a tsv.

add_multi_groupby(self, groupby) : Adds a groupby column that is comprised of multiple other columns. For instance, if 'sex' and 'age' are already in the obs table, add an additional column that's comprised of sex and age.

add_transcriptome(self, fname, pass_list=None, include_isms=False, verbose=False) : Adds a whole transcriptome from a set of samples.

die_gene_test(self, kind='iso', obs_col='dataset', obs_conditions=None, rc_thresh=10, verbose=False) : Finds genes with differential isoform expression between two conditions that are in the obs table. If there are more than 2 unique values in obs_col, the specific categories must be specified in obs_conditions

find_es_genes(self, verbose=False) : Finds all unique genes containing novel exon skipping events. Requires that an annotation has been added to the SwanGraph.

find_ir_genes(self, verbose=False) : Finds all unique genes containing novel intron retention events. Requires that an annotation has been added to the SwanGraph.

gen_report(self, gid, prefix, datasets=None, groupby=None, metadata_cols=None, novelty=False, layer='tpm', cmap='Spectral_r', include_unexpressed=False, indicate_novel=False, display_numbers=False, transcript_col='tid', browser=False, order='expression') : Generates a PDF report for a given gene or list of genes according to the user's input.

get_die_genes(self, kind='iso', obs_col='dataset', obs_conditions=None, p=0.05, dpi=10) : Filters differential isoform expression test results based on adj. p-value and change in percent isoform usage (dpi).

get_edge_abundance(self, prefix=None, kind='counts') : Gets edge expression from the current SwanGraph in a DataFrame complete information about where edge is.

get_tes_abundance(self, prefix=None, kind='counts') : Gets TES expression from the current SwanGraph in a DataFrame complete information about where TES is.

get_tpm(self, kind='iso') : Retrieve TPM per dataset.

get_tss_abundance(self, prefix=None, kind='counts') : Gets TSS expression from the current SwanGraph in a DataFrame with complete information about where TSS is.

plot_browser(self, tid, **kwargs) : Plot browser representation for a given transcript

plot_each_transcript(self, tids, prefix, indicate_dataset=False, indicate_novel=False, browser=False) : Plot each input transcript and automatically save figures

plot_each_transcript_in_gene(self, gid, prefix, indicate_dataset=False, indicate_novel=False, browser=False) : Plot each transcript in a given gene and automatically save figures

plot_graph(self, gid, indicate_dataset=False, indicate_novel=False, prefix=None) : Plots a gene summary SwanGraph for an input gene. Does not automatically save the figure by default!

plot_transcript_path(self, tid, indicate_dataset=False, indicate_novel=False, browser=False, prefix=None) : Plots a path of a single transcript isoform through a gene summary SwanGraph.

save_graph(self, prefix) : Saves the current SwanGraph in pickle format with the .p extension

set_metadata_colors(self, obs_col, cmap) : Set plotting colors for datasets based on a column in the metadata table.

set_plotting_colors(self, cmap=None, default=False) : Set plotting colors for SwanGraph and browser models.

Last updated

Was this helpful?