<commit_before>=====================
Introduction & Demo
=====================

Concise overview
-----------------
**Current release**: |codename| (|version|)

The goals of Chanjo are quite simple:

1. Integrate seamlessly with ``sambamba depth region`` output
2. Break down coverage to intuitive levels of abstraction: exons, transcripts, and genes
3. Enable explorative coverage investigations across samples and genomic regions


Demo
-----
The rest of this document will guide you through a short demo that will cover how to use Chanjo from the command line.


Demo files
~~~~~~~~~~
First we need some files to work with. Chanjo comes with some pre-installed demo files we can use.

.. code-block:: console

    $ chanjo demo && cd chanjo-demo

This will create a new folder (``chanjo-demo``) in your current directory and fill it with the example files you need.

.. note::
    You can name the new folder anything you like but it *must not already exist*!


Setup and configuration
~~~~~~~~~~~~~~~~~~~~~~~~
The first task is to create a config file (``chanjo.yaml``) and prepare the database. Chanjo will walk you through setting it up by running:

.. code-block:: console

    $ chanjo init
    $ chanjo db setup

.. note::
    Chanjo uses project-level config files by default. This means that it will look for a ``chanjo.yaml`` file in the **current directory** where you execute your command. You can also point to a diffrent config file using the ``chanjo -c /path/to/chanjo.yaml`` option.


Defining interesting regions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One important thing to note is that Chanjo considers coverage across exonic regions of the genome. It's perfectly possible to compose your own list of intervals. Just make sure to follow the BED conventions (http://genome.ucsc.edu/FAQ/FAQformat.html#format1). You then add a couple of additional columns that define relationships between exons and transcripts and transcripts and genes:

.. code-block::

    #chrom  chromStart  chromEnd    name    score   strand  transcripts genes
    chr1    120032  120162  exon1   0   +   transcript1,transcript2 gene1,gene1

If an exon belongs to multiple transcripts you define a list of ids and an equal number of gene identifiers to match.


Linking exons/transcripts/genes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's tell Chanjo which exons belong to which transcripts and which transcripts belong to which genes. It's fine to use the output from Sambamba as long as the two columns after "strand" are present in the file.

.. code-block:: console

    $ chanjo link sample1.coverage.bed


Loading annotations
~~~~~~~~~~~~~~~~~~~~~
After running ``sambamba depth region`` you can take the output and load it into the database. Let's also add a group identifier to indicate that the sample is related to some other samples.

.. code-block:: console

    $ for file in *.coverage.bed; do echo "${file}"; chanjo load "${file}"; done


Extracting informtion
~~~~~~~~~~~~~~~~~~~~~~
We now have some information loaded for a few samples and we can now start exploring what coverage looks like! The output will be in the handy `JSON lines`_ format.

.. code-block:: console<commit_msg>Update introduction.rst<commit_after>=====================
Introduction & Demo
=====================

Concise overview
-----------------
**Current release**: |codename| (|version|)

The goals of Chanjo are quite simple:

1. Integrate seamlessly with ``sambamba depth region`` output
2. Break down coverage to intuitive levels of abstraction: exons, transcripts, and genes
3. Enable explorative coverage investigations across samples and genomic regions


Demo
-----
The rest of this document will guide you through a short demo that will cover how to use Chanjo from the command line.


Demo files
~~~~~~~~~~
First we need some files to work with. Chanjo comes with some pre-installed demo files we can use.

.. code-block:: console

    $ chanjo demo && cd chanjo-demo

This will create a new folder (``chanjo-demo``) in your current directory and fill it with the example files you need.

.. note::
    You can name the new folder anything you like but it *must not already exist*!


Setup and configuration
~~~~~~~~~~~~~~~~~~~~~~~~
The first task is to create a config file (``chanjo.yaml``) and prepare the database. Chanjo will walk you through setting it up by running:

.. code-block:: console

    $ chanjo init
    $ chanjo db setup

.. note::
    Chanjo uses project-level config files by default. This means that it will look for a ``chanjo.yaml`` file in the **current directory** where you execute your command. You can also point to a diffrent config file using the ``chanjo -c /path/to/chanjo.yaml`` option.


Defining interesting regions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One important thing to note is that Chanjo considers coverage across exonic regions of the genome. It's perfectly possible to compose your own list of intervals. Just make sure to follow the BED conventions (http://genome.ucsc.edu/FAQ/FAQformat.html#format1). You then add a couple of additional columns that define relationships between exons and transcripts and transcripts and genes:

.. code-block::

    #chrom  chromStart  chromEnd    name    score   strand  transcripts genes
    chr1    120032  120162  exon1   0   +   transcript1,transcript2 gene1,gene1

If an exon belongs to multiple transcripts you define a list of ids and an equal number of gene identifiers to match.


Linking exons/transcripts/genes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's tell Chanjo which exons belong to which transcripts and which transcripts belong to which genes. It's fine to use the output from Sambamba as long as the two columns after "strand" are present in the file.

.. code-block:: console

    $ chanjo link sample1.coverage.bed


Loading annotations
~~~~~~~~~~~~~~~~~~~~~
After running ``sambamba depth region`` you can take the output and load it into the database. Let's also add a group identifier to indicate that the sample is related to some other samples.

.. code-block:: console

    $ for file in *.coverage.bed; do echo "${file}"; chanjo load "${file}"; done


Extracting information
~~~~~~~~~~~~~~~~~~~~~~
We now have some information loaded for a few samples and we can now start exploring what coverage looks like! The output will be in the handy `JSON lines`_ format.

.. code-block:: console
{'fraction_non_alphanumeric': 0.11944749646837231, 'fraction_numerical': 0.00753413906765029, 'mean_word_length': 4.029202841357537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3474778', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1534, 'n_words': 860}