Unsupervised KDM finding can be performed over a set of sequences using the following function, which factorizes the k-mer representation of the sequences by projective non-negative matrix factorization (PNMF).
KDMFind| Parameter | Meaning |
|---|---|
sequences | an array of sequences |
minrank | integer: the minimum factorization rank allowed |
maxrank | integer [1, number of sequences]: the maximum factorization rank allowed |
dictionary | the dictionary defining the k-mer space, as returned by KDMDictionary |
tol | double: the factorization iterations stopping criterion (default 1e-6) |
| Output | an object of class kdmotifs: a matrix [nkmers x rank]. Each column contains the Hellinger transformed probability distribution for a motif. The columns are named M-1, M-2, ... |
Using the sequences we have loaded for the NRF1 transcription factor, we can call
KDMFind passing both the positive and negative sequences from our
training set:
motifs<-KDMFind(c(NRF1$train$pseq,NRF1$train$nseq),minrank=100,maxrank=500,dictionaryTF,tol=1e-6)
The rank is chosen automatically between
minrankandmaxrank; discovery is unsupervised, which is why the unbound sequences are included too.
Once the function exits we can print the result:
motifskdm motifs matrix
#N motifs: 165
Kmer length: 8
N# gaps: 2
Double strand: TRUE
We can subset the results specifying the column indexes (motifs) we want:
motifs_subset<-motifs[,c(1,2,7)]
motifs_subsetkdm motifs matrix
#N motifs: 3
Kmer length: 8
N# gaps: 2
Double strand: TRUE
Please consider that the column names remain unchanged in the subset:
colnames(motifs_subset)[1] "M-1" "M-2" "M-7"
You can rename them explicitly:
colnames(motifs_subset)<-c("myname1","myname2","myname3")
It is possible to plot the probabilities for a motif as follows:
plot(motifs[,"M-105"]^2,type="h")
M-105, almost all the mass sits on a handful of k-mers.