TFBS::...ix::PWM(3pm)
π TFBS::Matrix::PWM π
okay bestie, welcome to the TFBS::...ix::PWM(3pm) page β¨ (yes the manual name is literally truncated like that, we don't make the rules π«Ά) β it's part of the User Contributed Perl Documentation, and it's about to become your new personality.
β¨ NAME β¨
TFBS::Matrix::PWM β the class for position weight matrices of nucleotide patterns π
πΈ SYNOPSIS πΈ
π creating a TFBS::Matrix::PWM object manually
no cap, you got two ways to do this, and they're both cute:
my $matrixref = [ [ 0.61, -3.16, 1.83, -3.16, 1.21, -0.06],
[-0.15, -2.57, -3.16, -3.16, -2.57, -1.83],
[-1.57, 1.85, -2.57, -1.34, -1.57, 1.14],
[ 0.31, -3.16, -2.57, 1.76, 0.24, -0.83]
];
my $pwm = TFBS::Matrix::PWM->new(-matrix => $matrixref,
-name => "MyProfile",
-ID => "M0001"
);
# or
my $matrixstring = <<ENDMATRIX
0.61 -3.16 1.83 -3.16 1.21 -0.06
-0.15 -2.57 -3.16 -3.16 -2.57 -1.83
-1.57 1.85 -2.57 -1.34 -1.57 1.14
0.31 -3.16 -2.57 1.76 0.24 -0.83
ENDMATRIX
;
my $pwm = TFBS::Matrix::PWM->new(-matrixstring => $matrixstring,
-name => "MyProfile",
-ID => "M0001"
);
π¦ grabbing a TFBS::Matrix::PWM object from a database
lowkey you should go read the docs for the individual TFBS::DB::* modules if you wanna know how to connect to the different flavours of pattern database and pull TFBS::Matrix::* objects out of them:
my $db_obj = TFBS::DB::JASPAR2->new
(-connect => ["dbi:mysql:JASPAR2:myhost",
"myusername", "mypassword"]);
my $pwm = $db_obj->get_Matrix_by_ID("M0001", "PWM");
# or
my $pwm = $db_obj->get_Matrix_by_name("MyProfile", "PWM");
π pulling a whole list of individual TFBS::Matrix::PWM objects out of a TFBS::MatrixSet object
(go read the TFBS::MatrixSet documentation if you wanna know how to make objects for storing and manipulating a bunch of matrices at once)
my @pwm_list = $matrixset->all_patterns(-sort_by=>"name");
β scanning a nucleotide sequence with a matrix
my $siteset = $pwm->search_seq(-file =>"myseq.fa",
-threshold => "80%");
π₯ scanning a pairwise alignment with a matrix
my $site_pair_set = $pwm->search_aln(-file =>"myalign.aln",
-threshold => "80%",
-cutoff => "70%",
-window => 50);
π DESCRIPTION π
okay so. TFBS::Matrix::PWM is a class, and its instances are objects that represent position weight matrices, aka PWMs. A PWM is normally calculated from a raw position frequency matrix β go look at TFBS::Matrix::PFM if you want the whole explanation of what position frequency matrices are, it's giving prequel energy π.
For example, take this position frequency matrix:
A:[ 12 3 0 0 4 0 ]
C:[ 0 0 0 11 7 0 ]
G:[ 0 9 12 0 0 0 ]
T:[ 0 0 0 1 1 12 ]
The standard computational procedure gets applied to it and it turns into this position weight matrix:
A:[ 0.61 -3.16 1.83 -3.16 1.21 -0.06]
C:[-0.15 -2.57 -3.16 -3.16 -2.57 -1.83]
G:[-1.57 1.85 -2.57 -1.34 -1.57 1.14]
T:[ 0.31 -3.16 -2.57 1.76 0.24 -0.83]
and that is what holds the "weights" associated with each nucleotide showing up at a given position in a pattern. iconic, honestly.
A TFBS::Matrix::PWM object comes fully equipped with methods to search nucleotide sequences β and pairwise alignments of nucleotide sequences β with the pattern it represents, and hand you back a set of sites: a TFBS::SiteSet object when it's a single sequence search, and a TFBS::SitePairSet for the alignment search π«.
π¬ FEEDBACK π¬
Please send bug reports and other comments to the author. fr fr, they wanna hear from you π«Ά
π AUTHOR - Boris Lenhard π
Boris Lenhard <Boris.Lenhard@cgb.ki.se>
π§ APPENDIX π§
okay the rest of this doc goes deep on each of the object methods. Internal methods are preceded with an underscore, iykyk.
π new
- Title β
new - Usage β
my $pwm = TFBS::Matrix::PWM->new(%args) - Function β constructor for the
TFBS::Matrix::PWMobject - Returns β a new
TFBS::Matrix::PWMobject - Args β you must specify exactly one of these three:
-matrixβ reference to an array of arrays of integers- or
-matrixstringβ a string containing four lines of tab- or space-delimited integers - or
-matrixfileβ the name of a file containing four lines of tab- or space-delimited integers
and then, optionally:
-nameβ string, OPTIONAL-IDβ string, OPTIONAL-classβ string, OPTIONAL-tagsβ an array reference, OPTIONAL
π¦ search_seq
- Title β
search_seq - Usage β
my $siteset = $pwm->search_seq(%args) - Function β scans a nucleotide sequence with the pattern represented by the PWM
- Returns β a
TFBS::SiteSetobject - Args β you must specify exactly one of these three:
-fileβ the name of a fasta file (single sequence)- or
-seqobjβ aBio::Seqobject (more accurately, aBio::PrimarySeqobject or a subclass thereof) - or
-seqstringβ a string containing the sequence
plus:
-thresholdβ minimum score for the hit, either absolute (e.g.11.2) or relative (e.g."75%"). OPTIONAL: default"80%"-subpartβ subpart of the sequence to search, given as
-subpart => { start => 140,
end => 180 }
where start and end are coordinates in the sequence; the coordinate range is interpreted in the BioPerl tradition (1-based, inclusive). OPTIONAL: by default searches entire alignment
π search_aln
- Title β
search_aln - Usage β
my $site_pair_set = $pwm->search_aln(%args) - Function β scans a pairwise alignment of nucleotide sequences with the pattern represented by the PWM: it reports only those hits that are present in equivalent positions of both sequences and that exceed a specified threshold score in both, AND are found in regions of the alignment above the specified conservation cutoff value.
- Returns β a
TFBS::SitePairSetobject - Args β you must specify exactly one of these three:
-fileβ the name of the alignment file in Clustal format- or
-alignobjβ aBio::SimpleAlignobject (more accurately, aBio::PrimarySeqobject or a subclass thereof) - or
-alignstringβ a multi-line string containing the alignment in clustal format
plus:
-thresholdβ minimum score for the hit, either absolute (e.g.11.2) or relative (e.g."75%"). OPTIONAL: default"80%"-windowβ size of the sliding window (in nucleotides) for calculating local conservation in the alignment. OPTIONAL: default50-cutoffβ conservation cutoff (%) for including the region in the results of the pattern search. OPTIONAL: default"70%"-subpartβ subpart of the alignment to search, given as e.g.
-subpart => { relative_to => 1,
start => 140,
end => 180 }
where start and end are coordinates in the sequence indicated by relative_to (1 for the 1st sequence in the alignment, 2 for the 2nd). OPTIONAL: by default searches entire alignment
-conservationβ conservation profile, aTFBS::ConservationProfile. OPTIONAL: by default the conservation profile is computed internally on the fly (less efficient)
π name, ID, class, matrix, length, revcom, rawprint, prettyprint
The above methods are common to all matrix objects. Please consult TFBS::Matrix to find out how to use them π«Ά
and that's the whole page bestie, you ate π no cap, go forth and build PWMs. This gem of a manual was served up by perl v5.42.3 on 2026-08-21 β periodt. πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libtfbs-perl 0.7.1+ds-6build1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms