Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect clustering result in clusterMotifs function #13

Open
CrazyHsu opened this issue Oct 28, 2023 · 5 comments
Open

Incorrect clustering result in clusterMotifs function #13

CrazyHsu opened this issue Oct 28, 2023 · 5 comments

Comments

@CrazyHsu
Copy link

Hi Jianhong, thanks for developing motifStack which helps me a lot.
Recently, I want to cluster a list of motifs using motifStack. But when I replaced the test data with the motifs mentioned earlier in the tutorial, I found that the clustering results were not correct. My running environment is R 4.3.1, and the motifStack version is 1.44.1. The code is as follows:

motifs <- importMatrix(dir(path, "*.pcm", full.names = TRUE),
                       format = "pcm", to = "pcm")
hc <- clusterMotifs(motifs)
## convert the hclust to phylog object
library(ade4)
phylog <- hclust2phylog(hc)
## reorder the pfms by the order of hclust
leaves <- names(phylog$leaves)
motifs <- motifs[leaves]
## create a list of pfm objects
#motifs <- mapply(motifs, names(motifs),
#               FUN=function(.pfm, .name){
#                 new("pcm",mat=.pfm, name=.name)})
## extract the motif signatures
motifSig <- motifSignature(motifs, phylog, cutoffPval = 0.0001, min.freq=1)


sig <- signatures(motifSig)
## get the group color for each signature
gpCol <- sigColor(motifSig)

library(RColorBrewer)
color <- brewer.pal(12, "Set3")
## plot the logo stack with pile style.
motifPiles(phylog=phylog, pfms=motifs, pfms2=sig,
            col.tree=rep(color, each=5),
            col.leaves=rep(rev(color), each=5),
            col.pfms2=gpCol,
            r.anno=c(0.02, 0.03, 0.04),
            col.anno=list(sample(colors(), 50),
                          sample(colors(), 50),
                          sample(colors(), 50)),
            motifScale="logarithmic",
            plotIndex=TRUE)

The out plot displayed as below:
image
As seen from the plot, the "bin_SOLEXA" and "fkh_NAR" were clustered into cluster2 which should be composed of "bin_SOLEXA", "slp1_SOLEXA" and "FoxP_SOLEXA".
I think it was due to the incorrect clustering of the clusterMotifs that led to the subsequent visualization errors. Perhaps the result is correct, just because I did not use motifStack correctly. If that's the case, how can I cluster correctly by using motifStack? Thank you in advance.

Feng

@jianhong
Copy link
Owner

jianhong commented Oct 29, 2023 via email

@CrazyHsu
Copy link
Author

Hi, @jianhong. Actually I am new to R and motifStack, and I don't know how to close the reverse complement alignment. Can you show me a example? Thanks!

Feng

@jianhong
Copy link
Owner

jianhong commented Oct 30, 2023 via email

@CrazyHsu
Copy link
Author

CrazyHsu commented Nov 1, 2023

Hi, @jianhong. Thanks for your advice, I get the correct cluster plot as it should be with the following code:

hc <- clusterMotifs(motifs, revcomp=F)

And the plot is:
image
BTW, as can be seen from the plot, the first three motif were clustered into Cluster2. But actually, if these motifs are reverse complementary, they can be clustered into Cluster1. So how can I cluster all these motifs into one cluster? Thank you in advance.
Feng

@jianhong
Copy link
Owner

jianhong commented Nov 1, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants