Advanced Usage

Use the python APIs directly for more fine-grained control over the SPATS run.

Spats

Typically, you’ll create a spats.Spats instance:

from spats_shape_seq import Spats
spats = Spats()

Then, configure the run, if desired, based on the run.Run:

spats.run.minimum_target_length = 10
...

Add the .fa file with the target(s):

spats.addTargets(path_to_targets_fasta)

That sets up the Spats processor. To process input data, call spats.Spats.process_pair_data(), passing the path to the R1 and R2 input files:

spats.process_pair_data(path_to_R1_fastq, path_to_R2_fastq)

Finally, call spats.Spats.compute_profiles() to compute beta/theta values, and spats.Spats.write_reactivities() to output the results to a file:

spats.compute_profiles()
spats.write_reactivities(path_to_reactivities_out)

For a case that requires no non-default configuration or processing, you can use the run_spats() convenience function, which will perform all of the above steps.

For saving data for later analysis / output / visualization, use the spats.Spats.store() method:

spats.store('my_run.spats')

This can be later loaded using the spats.Spats.load() method.

Reads Analyzer

For reads analysis, first create a ReadsData instance, passing it the path to use for its database (.db) file:

from spats_shape_seq.reads import ReadsData, ReadsAnalyzer
data = ReadsData('~/path/to/reads.db')

Then, parse the reads data from the original input files: pass the target file you use for analysis (single target only – without linker – for cotrans experiments), and the R1/R2 input paths:

data.parse('~/path/to/target.fa', '~/path/to/data/R1.fastq', '~/path/to/data/R2.fastq')

Note that, by default, this only parses a sample of 100k of the R1/R2 pairs. This should be sufficient for analyzing the reads, and is required for reasonable performance of the interactive UI.

Once you have the data parsed, it needs to be analyzed (tagged); this is similar to a normal spats.Spats run, but more information is gathered for non-matching pairs:

analyzer = ReadsAnalyzer(data)

Configure the run, if desired, based on the run.Run; for example, to change the linker from the default for a cotrans experiment:

analyzer.run.cotrans_linker = 'CTGACTCGGGCACCAAGGAC'

Then, perform the analysis:

analyzer.process_tags()

Once that completes, your reads data will be ready for analysis.