DataType

Sequence

A sequence in MotifLab represents a segment of a DNA strand spanning a specified number of bases. Usually, a sequence object will represent a "real sequence" where the location of the sequence segment and the genome build it originates from is known. For example, a sequence could span the segment from position 157,342,949 to position 157,343,321 on the reverse strand of chromosome 2 from the human genome build "hg19". Alternatively, a sequence object could represent an "artificial sequence" which is not tied to a specific location or genome build (or a "real sequence" whose actual location or genome build is simply not known). In either case, a sequence object in MotifLab is merely an "empty" template that contains very little information in itself. Specifically, even though it is referred to as a "sequence", it does not contain information about the actual DNA sequence found at the associated location. This information is contained in DNA Sequence Datasets, a type of Feature Datasets that can annotate sequence segments with additional information.

The required attributes of a Sequence object is: If the chromosome is not known (for instance for artificial sequences), it can be set to "?". In MotifLab, chromosomes always start at position 1, and both the start and end coordinates are inclusive (although certain data formats, like BED, might treat this differently).

A sequence can optionally be associated with a single gene and can then be annotated with the gene's name and the position of the transcription start site and end site. In MotifLab v2, sequences can also be annotated with Gene Ontology terms and other user-defined properties.

Creating Sequences

Sequences are normally created in MotifLab via the "Add Sequences" dialog which can be opened by selecting "Add Sequences" from the "Data" menu or by pressing the double-helix button in the tool bar. In protocol scripts, it is possible to create single (artificial) sequences with specified lengths or (real) sequences defined in BED or Location formats. Multiple sequences can be created with a single command by importing sequence definitions from a Location-, BED- or FASTA-file into the default sequence collection called "AllSequences". The Location-format supports all kinds of sequence metadata (including genome build and location of TSS/TES), but BED-files only contain information about the chromosomal location for each sequence and not its genome build. It is possible to update the genome build for each sequence afterwards, however, with the set[property] command. When importing sequences from FASTA files, the sequence metadata will be included if this information is present in the header of each sequence. If no metadata is present, MotifLab will just create artificial sequences based on the lengths of the sequences found in the FASTA file.
Note that even though the FASTA file contains the actual DNA sequences, only the metadata/length of the sequences will be used to create sequence objects. To include the actual DNA sequence you must also create an additional DNA Sequence Dataset based on the same FASTA file.
One final way to create new sequences is to extract subsegments from existing sequences with the split_sequences operation.

# Create an "artificial sequence" with length 2000bp and location "chr?:1-2000" from an unknown genome
Seq1 = new Sequence(2000)


# Create a new sequence specified in (comma-separated) BED-format with location "chr2:1001-2000"
# BED-format arguments: chr,start,end [,gene name,score,strand]
Seq2 = new Sequence(chr2,1000,2000)

# Create a new sequence specified in (comma-separated) BED-format with location "chr2:1001-2000",
# gene name "BRAC1" and reverse orientation. The score attribute in the fifth BED-column is ignored
Seq3 = new Sequence(chr2,1000,2000,BRAC1,100,-)


# Create a new sequence with location "chr22:36783864-36786063" (reverse strand) from human genome hg19
# associated with the gene "MYH9" with TSS at position 36784063 and TES at position 36677327
# Location-format arguments: Gene name, genome build, chromosome, start, end, TSS, TES, orientation
ENSG00000100345 = new Sequence(MYH9, hg19, 22, 36783864, 36786063, 36784063, 36677327, REVERSE)

# Same as previous example but the TSS and TES annotations are left out
ENSG00000100345 = new Sequence(MYH9, hg19, 22, 36783864, 36786063, - , - , REVERSE)


# Create a new sequence spanning 2000bp upstream to 200bp downstream around the transcription start
# site of gene "NTNG1" in genome hg18 (gene identifier provided in "HGNC Symbol" format)
# Location-format arguments: Gene identifier, identifier type, build, relative start, relative end, anchor
Seq4 = new Sequence(NTNG1, HGNC Symbol, hg18, -2000, 200, TSS)

# Create a new sequence spanning 100bp upstream to 100bp downstream around the transcription end site
# of Entrez gene "56475" from genome build hg18
Seq5 = new Sequence(56475, Entrez gene, hg18, -100, 100, TES)

# Create a new sequence spanning the full length of Ensembl gene ENSG00000111249 from hg19
Seq6 = new Sequence(ENSG00000111249, Ensembl Gene, hg19, 0, 0, full gene)

# Same as previous example but extended with 500bp additional flanking sequence on both sides
Seq7 = new Sequence(ENSG00000111249, Ensembl Gene, hg19, -500, 500, full gene)


# Load multiple sequences from file in Location format
AllSequences = new Sequence Collection(File:"C:\data\MuscleGenes_-2000+200.txt", format=Location)

# Load sequences from file in BED format. The genome build for all the sequences is set afterwards
AllSequences = new Sequence Collection(File:"C:\data\genes.bed", format=BED)
set AllSequences[genome build] to "mm9"


# Create new sequences based on the EnsemblGenes annotations (region track) of the current sequences,
# then delete the original sequences. The relationship between new and old sequences is recorded
# in the returned SequencePartition
SequencePartition1 = split_sequences based on EnsemblGenes. Delete original sequences

Modifying Sequences

Because so many other data objects depend on sequences and the locations represented by these objects, sequence objects are usually not allowed to be changed or even renamed after they have been created. Especially, new sequences cannot be created nor can existing sequences be extended after feature datasets have been added (since there would be no feature data for the new sequence segments). However, sequences can still be cropped and dropped.

In MotifLab v2, a few sequence properties – namely "genome build", "TSS", "TES", "orientation" and "gene name" – are allowed to be changed after creation. In addition, sequences can be annotated with gene ontology terms and other user-defined properties. The properties of a single sequence can be modified by right-clicking on the name label for a sequence in the Visualization panel (to the left of the tracks visualization) and then selecting "Display sequencename" from the context-menu to bring up a dialog window. Properties for single sequences or collections of sequences can also be updated with the set operation.

# Set the genome build of sequence "Seq1" to "mm9" (this will also update the organism)
set Seq1[genome build] to "mm9"

# Set the associated TSS position of sequence "Seq1" to 391829
set Seq1[TSS] to 391829

# Set the "gene name" property of every sequence based on corresponding strings in the Sequence Map NameMap1
set AllSequences[gene name] to NameMap1

# Set the TSS property of every sequence based on corresponding values in the Sequence Numeric Map TSSpos
set AllSequences[TSS] to TSSpos

# Set the strand orientation of all the sequences in the "Upregulated" collection to the reverse strand
set Upregulated[orientation] to "reverse"

Using Sequences

Individual sequence objects are rarely used directly in MotifLab, but are rather used as templates for other feature datasets or are referenced to (by name only) as part of collections, partitions and maps. Only a few types of analyses currently make use of information stored directly in sequence objects, such as gene ontology term enrichment analyses.