Getting started
First, if you haven't already, make sure to install Swan. After installing, you'll be able to run Swan from Python.
Then, download the data and the reference transcriptome annotation from here. The bash commands to do so are given below.
The main workflow to get started with Swan consists of:
Adding a transcriptome for your samples
Other sections:
This page can also be read from top to bottom, just know that you may be running things more than once!
For information on the file formats needed to use Swan, please read the file format specifications FAQ.
Download example data
This data is the data used in the Swan publication
Run this block in your bash terminal
Starting up Swan and initializing your SwanGraph
The rest of the code in this tutorial should be run in using Python
Initialize an empty SwanGraph and add the transcriptome annotation to the SwanGraph.
Note: to initialize a SwanGraph in single-cell mode (which will avoid calculating percent isoform use [pi] numbers for each cell), use the following code:
Adding a reference transcriptome
Adding transcript models from a GTF
Add all filtered transcript models to the SwanGraph.
Adding abundance information
Adding abundance from a TSV
You can use an abundance matrix with columns for each desired dataset to add datasets to the SwanGraph. The file format is specified here.
Adding abundance from an AnnData
If you have abundance information and metadata information in AnnData format, you can use this as direct input into Swan. This will help circumvent the dense matrix representation of the TSV in the case of very large datasets or single-cell data.
By adding abundance information from either an AnnData or TSV file, Swan will also automatically calculate the counts and TPM for each TSS, TES, and intron or exon. If you had previously used add_transcriptome()
to add a GTF that was generated by Cerberus or uses Cerberus-style transcript IDs (ie. <gene_id>[1,1,1]), Swan will also calculate intron chain counts and TPM automatically.
Adding gene-level abundance
You can also store gene expression in the SwanGraph. This can either be done from a TALON abundance TSV that contains transcript-level counts where the counts for each transcript will be summed up across the gene. Alternatively, supply this function a gene-level counts matrix where the first column is the gene ID rather than the transcript ID, but otherwise follows the input abundance TSV format.
Saving and loading your SwanGraph
Following this, you can save your SwanGraph so you can easily work with it again without re-adding all the data.
And you can reload the graph again.
Adding transcript models from a TALON DB
Swan is also directly compatible with TALON databases and can pull transcript models directly from them. You can also optionally pass in a list of isoforms from talon_filter_transcripts
to filter your input transcript models.
Adding metadata
Swan provides functionality to perform tests and plotting on the basis of metadata categories. Add metadata by calling the SwanGraph.add_metadata()
function, or use the SwanGraph.add_adata()
function to add both expression information and metadata at the same time.
index
hepg2_1
hepg2
1
hepg2_1
499647.0
liver
hepg2_2
hepg2
2
hepg2_2
848447.0
liver
hffc6_1
hffc6
1
hffc6_1
761493.0
fibroblast
hffc6_2
hffc6
2
hffc6_2
787967.0
fibroblast
hffc6_3
hffc6
3
hffc6_3
614921.0
fibroblast
Behavior with Cerberus
When you use a Cerberus GTF in SwanGraph.add_annotation()
or SwanGraph.add_transcriptome()
, keep in mind the following:
Swan will use the TSS / TES assignments as dictated by Cerberus to define unique entries in
SwanGraph.tss_adata
andSwanGraph.tes_adata
. For instance, if the same vertex is used in more than one gene, they will still be treated as separate vertices in the TSS / TES AnnDatas.Swan will automatically pull intron chain information from the transcript triplet in Cerberus and use it to generate an AnnData tracking the expression of intron chains separately from the transcripts they come from in
SwanGraph.ic_adata
. This can also be used to perform isoform switching tests.Currently, Swan does not parse Cerberus novelty categories. We are hoping to support this in a future release.
ic_id
ENSMUSG00000118369_2
ENSMUSG00000118369
Gm30541
Gm30541_2
14
ENSMUSG00000118380_3
ENSMUSG00000118380
Gm36037
Gm36037_3
1
ENSMUSG00000118382_1
ENSMUSG00000118382
Gm8373
Gm8373_1
2
ENSMUSG00000118383_1
ENSMUSG00000118383
Gm50321
Gm50321_1
14
ENSMUSG00000118390_1
ENSMUSG00000118390
Gm50102
Gm50102_1
1
Last updated